mirror of
https://gitlab.archlinux.org/tpowa/archboot.git
synced 2024-09-20 03:50:37 +02:00
add autoconfig progressbar
This commit is contained in:
parent
57fcf115d3
commit
ce6d808a18
2 changed files with 133 additions and 136 deletions
|
@ -4,46 +4,15 @@
|
|||
# preprocess fstab file
|
||||
# comments out old fields and inserts new ones
|
||||
# according to partitioning/formatting stage
|
||||
_auto_fstab(){
|
||||
# Modify fstab
|
||||
_dialog --no-mouse --infobox "Create new fstab on installed system..." 3 70
|
||||
if [[ -f /tmp/.device-names ]]; then
|
||||
sort /tmp/.device-names >>"${_DESTDIR}"/etc/fstab
|
||||
fi
|
||||
if [[ -f /tmp/.fstab ]]; then
|
||||
# clean fstab first from entries
|
||||
sed -i -e '/^\#/!d' "${_DESTDIR}"/etc/fstab
|
||||
sort /tmp/.fstab >>"${_DESTDIR}"/etc/fstab
|
||||
fi
|
||||
sleep 2
|
||||
}
|
||||
|
||||
# add udev rule for schedulers by default
|
||||
_auto_scheduler () {
|
||||
if [[ ! -f ${_DESTDIR}/etc/udev/rules.d/70-ioschedulers.rules ]]; then
|
||||
_dialog --no-mouse --infobox "Enable performance ioscheduler settings on installed system..." 3 70
|
||||
cp /etc/udev/rules.d/60-ioschedulers.rules "${_DESTDIR}"/etc/udev/rules.d/60-ioschedulers.rules
|
||||
_auto_timesetting() {
|
||||
if [[ -e /etc/localtime && ! -e "${_DESTDIR}"/etc/localtime ]]; then
|
||||
_progress "5" "Enable timezone setting on installed system..."
|
||||
cp -a /etc/localtime "${_DESTDIR}"/etc/localtime
|
||||
sleep 2
|
||||
fi
|
||||
}
|
||||
|
||||
# add sysctl file for swaps
|
||||
_auto_swap () {
|
||||
if [[ ! -f ${_DESTDIR}/etc/sysctl.d/99-sysctl.conf ]]; then
|
||||
_dialog --no-mouse --infobox "Enable sysctl swap settings on installed system..." 3 70
|
||||
cp /etc/sysctl.d/99-sysctl.conf "${_DESTDIR}"/etc/sysctl.d/99-sysctl.conf
|
||||
sleep 2
|
||||
fi
|
||||
}
|
||||
|
||||
# add mdadm setup to existing /etc/mdadm.conf
|
||||
_auto_mdadm()
|
||||
{
|
||||
if [[ -e ${_DESTDIR}/etc/mdadm.conf ]]; then
|
||||
if grep -q ^md /proc/mdstat 2>"${_NO_LOG}"; then
|
||||
_dialog --no-mouse --infobox "Enable mdadm settings on installed system..." 3 70
|
||||
mdadm -Ds >> "${_DESTDIR}"/etc/mdadm.conf
|
||||
fi
|
||||
if [[ -f /etc/adjtime && ! -f "${_DESTDIR}"/etc/adjtime ]]; then
|
||||
_progress "8" "Enable clock setting on installed system..."
|
||||
cp /etc/adjtime "${_DESTDIR}"/etc/adjtime
|
||||
sleep 2
|
||||
fi
|
||||
}
|
||||
|
@ -55,7 +24,7 @@ _auto_network()
|
|||
if [[ ! -e /.network ]]; then
|
||||
return 1
|
||||
fi
|
||||
_dialog --no-mouse --infobox "Enable network and proxy settings on installed system..." 3 70
|
||||
_progress "13" "Enable network and proxy settings on installed system..."
|
||||
# copy iwd keys and enable iwd
|
||||
if grep -q 'wlan' /.network-interface; then
|
||||
cp -r /var/lib/iwd "${_DESTDIR}"/var/lib
|
||||
|
@ -75,10 +44,67 @@ _auto_network()
|
|||
sleep 2
|
||||
}
|
||||
|
||||
_auto_fstab(){
|
||||
# Modify fstab
|
||||
_progress "20" "Create new fstab on installed system..."
|
||||
if [[ -f /tmp/.device-names ]]; then
|
||||
sort /tmp/.device-names >>"${_DESTDIR}"/etc/fstab
|
||||
fi
|
||||
if [[ -f /tmp/.fstab ]]; then
|
||||
# clean fstab first from entries
|
||||
sed -i -e '/^\#/!d' "${_DESTDIR}"/etc/fstab
|
||||
sort /tmp/.fstab >>"${_DESTDIR}"/etc/fstab
|
||||
fi
|
||||
sleep 2
|
||||
}
|
||||
|
||||
# add udev rule for schedulers by default
|
||||
_auto_scheduler () {
|
||||
if [[ ! -f ${_DESTDIR}/etc/udev/rules.d/70-ioschedulers.rules ]]; then
|
||||
_progress "24" "Enable performance ioscheduler settings on installed system..."
|
||||
cp /etc/udev/rules.d/60-ioschedulers.rules "${_DESTDIR}"/etc/udev/rules.d/60-ioschedulers.rules
|
||||
sleep 2
|
||||
fi
|
||||
}
|
||||
|
||||
# add sysctl file for swaps
|
||||
_auto_swap () {
|
||||
if [[ ! -f ${_DESTDIR}/etc/sysctl.d/99-sysctl.conf ]]; then
|
||||
_progress "29" "Enable sysctl swap settings on installed system..."
|
||||
cp /etc/sysctl.d/99-sysctl.conf "${_DESTDIR}"/etc/sysctl.d/99-sysctl.conf
|
||||
sleep 2
|
||||
fi
|
||||
}
|
||||
|
||||
# add mdadm setup to existing /etc/mdadm.conf
|
||||
_auto_mdadm()
|
||||
{
|
||||
if [[ -e ${_DESTDIR}/etc/mdadm.conf ]]; then
|
||||
if grep -q ^md /proc/mdstat 2>"${_NO_LOG}"; then
|
||||
_progress "34" "Enable mdadm settings on installed system..."
|
||||
mdadm -Ds >> "${_DESTDIR}"/etc/mdadm.conf
|
||||
fi
|
||||
sleep 2
|
||||
fi
|
||||
}
|
||||
|
||||
_auto_luks() {
|
||||
# remove root device from crypttab
|
||||
if [[ -e /tmp/.crypttab && "$(grep -v '^#' "${_DESTDIR}"/etc/crypttab)" == "" ]]; then
|
||||
_progress "40" "Enable luks settings on installed system..."
|
||||
# add to temp crypttab
|
||||
sed -i -e "/^$(basename "${_ROOTDEV}") /d" /tmp/.crypttab
|
||||
cat /tmp/.crypttab >> "${_DESTDIR}"/etc/crypttab
|
||||
chmod 700 /tmp/passphrase-* 2>"${_NO_LOG}"
|
||||
cp /tmp/passphrase-* "${_DESTDIR}"/etc/ 2>"${_NO_LOG}"
|
||||
sleep 2
|
||||
fi
|
||||
}
|
||||
|
||||
_auto_pacman_keyring()
|
||||
{
|
||||
if ! [[ -d ${_DESTDIR}/etc/pacman.d/gnupg ]]; then
|
||||
_dialog --no-mouse --infobox "Enable pacman's GPG keyring files on installed system..." 3 70
|
||||
_progress "47" "Enable pacman's GPG keyring files on installed system..."
|
||||
cp -ar /etc/pacman.d/gnupg "${_DESTDIR}"/etc/pacman.d &>"${_NO_LOG}"
|
||||
sleep 2
|
||||
fi
|
||||
|
@ -87,7 +113,7 @@ _auto_pacman_keyring()
|
|||
_auto_testing()
|
||||
{
|
||||
if grep -q "^\[.*testing\]" /etc/pacman.conf; then
|
||||
_dialog --no-mouse --infobox "Enable [testing] repository on installed system..." 3 70
|
||||
_progress "53" "Enable [testing] repository on installed system..."
|
||||
sed -i -e '/^#\[core-testing\]/ { n ; s/^#// }' "${_DESTDIR}"/etc/pacman.conf
|
||||
sed -i -e '/^#\[extra-testing\]/ { n ; s/^#// }' "${_DESTDIR}"/etc/pacman.conf
|
||||
sed -i -e 's:^#\[core-testing\]:\[core-testing\]:g' -e 's:^#\[extra-testing\]:\[extra-testing\]:g' "${_DESTDIR}"/etc/pacman.conf
|
||||
|
@ -95,6 +121,70 @@ _auto_testing()
|
|||
fi
|
||||
}
|
||||
|
||||
_auto_pacman_mirror() {
|
||||
# /etc/pacman.d/mirrorlist
|
||||
# add installer-selected mirror to the top of the mirrorlist
|
||||
if grep -q '^Server' /etc/pacman.d/mirrorlist; then
|
||||
_progress "62" "Enable pacman mirror on installed system..."
|
||||
_SYNC_URL=$(grep '^Server' /etc/pacman.d/mirrorlist | sed -e 's#.*\ ##g')
|
||||
#shellcheck disable=SC2027,SC2086
|
||||
awk "BEGIN { printf(\"# Mirror used during installation\nServer = "${_SYNC_URL}"\n\n\") } 1 " "${_DESTDIR}"/etc/pacman.d/mirrorlist > /tmp/inst-mirrorlist
|
||||
mv /tmp/inst-mirrorlist "${_DESTDIR}/etc/pacman.d/mirrorlist"
|
||||
sleep 2
|
||||
fi
|
||||
}
|
||||
|
||||
_auto_vconsole() {
|
||||
if [[ ! -f ${_DESTDIR}/etc/vconsole.conf ]]; then
|
||||
_progress "69" "Setting keymap and font on installed system..."
|
||||
cp /etc/vconsole.conf "${_DESTDIR}"/etc/vconsole.conf
|
||||
sleep 2
|
||||
fi
|
||||
}
|
||||
|
||||
_auto_hostname() {
|
||||
if [[ ! -f ${_DESTDIR}/etc/hostname ]]; then
|
||||
_progress "76" "Set default hostname on installed system..."
|
||||
echo "myhostname" > "${_DESTDIR}"/etc/hostname
|
||||
sleep 2
|
||||
fi
|
||||
}
|
||||
|
||||
_auto_locale() {
|
||||
_progress "83" "Set default locale on installed system..."
|
||||
if [[ ! -f ${_DESTDIR}/etc/locale.conf ]]; then
|
||||
if [[ -n ${_DESTDIR} && -e /.localize ]]; then
|
||||
cp /etc/locale.conf "${_DESTDIR}"/etc/locale.conf
|
||||
else
|
||||
echo "LANG=C.UTF-8" > "${_DESTDIR}"/etc/locale.conf
|
||||
echo "LC_COLLATE=C" >> "${_DESTDIR}"/etc/locale.conf
|
||||
sleep 2
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
_auto_set_locale() {
|
||||
# enable glibc locales from locale.conf
|
||||
_progress "90" "Enable glibc locales based on locale.conf on installed system..."
|
||||
#shellcheck disable=SC2013
|
||||
for i in $(grep "^LANG" "${_DESTDIR}"/etc/locale.conf | sed -e 's/.*=//g' -e's/\..*//g'); do
|
||||
sed -i -e "s/^#${i}/${i}/g" "${_DESTDIR}"/etc/locale.gen
|
||||
done
|
||||
sleep 2
|
||||
}
|
||||
|
||||
_auto_bash(){
|
||||
if [[ ! -f ${_DESTDIR}/etc/profile.d/custom-bash-prompt.sh ]]; then
|
||||
_progress "99" "Setup bash with custom options on installed system..."
|
||||
! grep -qw 'custom-bash-options.sh' "${_DESTDIR}/etc/skel/.bashrc" &&\
|
||||
echo ". /etc/profile.d/custom-bash-options.sh" >> "${_DESTDIR}/etc/skel/.bashrc"
|
||||
! grep -qw 'custom-bash-options.sh' "${_DESTDIR}/root/.bashrc" &&\
|
||||
echo ". /etc/profile.d/custom-bash-options.sh" >> "${_DESTDIR}/root/.bashrc"
|
||||
cp /etc/profile.d/custom-bash-options.sh "${_DESTDIR}"/etc/profile.d/
|
||||
sleep 2
|
||||
fi
|
||||
}
|
||||
|
||||
_auto_mkinitcpio() {
|
||||
_FBPARAMETER=""
|
||||
_HWPARAMETER=""
|
||||
|
@ -145,96 +235,4 @@ _auto_mkinitcpio() {
|
|||
_printk on
|
||||
fi
|
||||
}
|
||||
|
||||
_auto_vconsole() {
|
||||
if [[ ! -f ${_DESTDIR}/etc/vconsole.conf ]]; then
|
||||
_dialog --no-mouse --infobox "Setting keymap and font on installed system..." 3 70
|
||||
cp /etc/vconsole.conf "${_DESTDIR}"/etc/vconsole.conf
|
||||
sleep 2
|
||||
fi
|
||||
}
|
||||
|
||||
_auto_luks() {
|
||||
# remove root device from crypttab
|
||||
if [[ -e /tmp/.crypttab && "$(grep -v '^#' "${_DESTDIR}"/etc/crypttab)" == "" ]]; then
|
||||
_dialog --no-mouse --infobox "Enable luks settings on installed system..." 3 70
|
||||
# add to temp crypttab
|
||||
sed -i -e "/^$(basename "${_ROOTDEV}") /d" /tmp/.crypttab
|
||||
cat /tmp/.crypttab >> "${_DESTDIR}"/etc/crypttab
|
||||
chmod 700 /tmp/passphrase-* 2>"${_NO_LOG}"
|
||||
cp /tmp/passphrase-* "${_DESTDIR}"/etc/ 2>"${_NO_LOG}"
|
||||
sleep 2
|
||||
fi
|
||||
}
|
||||
|
||||
_auto_timesetting() {
|
||||
if [[ -e /etc/localtime && ! -e "${_DESTDIR}"/etc/localtime ]]; then
|
||||
_dialog --no-mouse --infobox "Enable timezone setting on installed system..." 3 70
|
||||
cp -a /etc/localtime "${_DESTDIR}"/etc/localtime
|
||||
sleep 2
|
||||
fi
|
||||
if [[ -f /etc/adjtime && ! -f "${_DESTDIR}"/etc/adjtime ]]; then
|
||||
_dialog --no-mouse --infobox "Enable clock setting on installed system..." 3 70
|
||||
cp /etc/adjtime "${_DESTDIR}"/etc/adjtime
|
||||
sleep 2
|
||||
fi
|
||||
}
|
||||
|
||||
_auto_pacman_mirror() {
|
||||
# /etc/pacman.d/mirrorlist
|
||||
# add installer-selected mirror to the top of the mirrorlist
|
||||
if grep -q '^Server' /etc/pacman.d/mirrorlist; then
|
||||
_dialog --no-mouse --infobox "Enable pacman mirror on installed system..." 3 70
|
||||
_SYNC_URL=$(grep '^Server' /etc/pacman.d/mirrorlist | sed -e 's#.*\ ##g')
|
||||
#shellcheck disable=SC2027,SC2086
|
||||
awk "BEGIN { printf(\"# Mirror used during installation\nServer = "${_SYNC_URL}"\n\n\") } 1 " "${_DESTDIR}"/etc/pacman.d/mirrorlist > /tmp/inst-mirrorlist
|
||||
mv /tmp/inst-mirrorlist "${_DESTDIR}/etc/pacman.d/mirrorlist"
|
||||
sleep 2
|
||||
fi
|
||||
}
|
||||
|
||||
_auto_hostname() {
|
||||
if [[ ! -f ${_DESTDIR}/etc/hostname ]]; then
|
||||
_dialog --no-mouse --infobox "Set default hostname on installed system..." 3 70
|
||||
echo "myhostname" > "${_DESTDIR}"/etc/hostname
|
||||
sleep 2
|
||||
fi
|
||||
}
|
||||
|
||||
_auto_locale() {
|
||||
_dialog --no-mouse --infobox "Set default locale on installed system..." 3 70
|
||||
if [[ ! -f ${_DESTDIR}/etc/locale.conf ]]; then
|
||||
if [[ -n ${_DESTDIR} && -e /.localize ]]; then
|
||||
cp /etc/locale.conf "${_DESTDIR}"/etc/locale.conf
|
||||
else
|
||||
echo "LANG=C.UTF-8" > "${_DESTDIR}"/etc/locale.conf
|
||||
echo "LC_COLLATE=C" >> "${_DESTDIR}"/etc/locale.conf
|
||||
sleep 2
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
_auto_set_locale() {
|
||||
# enable glibc locales from locale.conf
|
||||
_dialog --no-mouse --infobox "Enable glibc locales based on locale.conf on installed system..." 3 70
|
||||
#shellcheck disable=SC2013
|
||||
for i in $(grep "^LANG" "${_DESTDIR}"/etc/locale.conf | sed -e 's/.*=//g' -e's/\..*//g'); do
|
||||
sed -i -e "s/^#${i}/${i}/g" "${_DESTDIR}"/etc/locale.gen
|
||||
done
|
||||
sleep 2
|
||||
}
|
||||
|
||||
_auto_bash(){
|
||||
if [[ ! -f ${_DESTDIR}/etc/profile.d/custom-bash-prompt.sh ]]; then
|
||||
_dialog --no-mouse --infobox "Setup bash with custom options on installed system..." 3 70
|
||||
cp "${_DESTDIR}"/etc/skel/.bash* "${_DESTDIR}"/root/
|
||||
! grep -qw 'custom-bash-options.sh' "${_DESTDIR}/etc/skel/.bashrc" &&\
|
||||
echo ". /etc/profile.d/custom-bash-options.sh" >> "${_DESTDIR}/etc/skel/.bashrc"
|
||||
! grep -qw 'custom-bash-options.sh' "${_DESTDIR}/root/.bashrc" &&\
|
||||
echo ". /etc/profile.d/custom-bash-options.sh" >> "${_DESTDIR}/root/.bashrc"
|
||||
cp /etc/profile.d/custom-bash-options.sh "${_DESTDIR}"/etc/profile.d/
|
||||
sleep 2
|
||||
fi
|
||||
}
|
||||
|
||||
# vim: set ft=sh ts=4 sw=4 et:
|
||||
|
|
|
@ -50,8 +50,7 @@ _install_packages() {
|
|||
_chroot_mount
|
||||
# automagic time!
|
||||
# any automatic configuration should go here
|
||||
_dialog --no-mouse --infobox "Writing base configuration..." 6 40
|
||||
_auto_timesetting
|
||||
(_auto_timesetting
|
||||
_auto_network
|
||||
_auto_fstab
|
||||
_auto_scheduler
|
||||
|
@ -65,7 +64,7 @@ _install_packages() {
|
|||
_auto_hostname
|
||||
_auto_locale
|
||||
_auto_set_locale
|
||||
_auto_bash
|
||||
_auto_bash) | _dialog --title " Autoconfiguration " --no-mouse --gauge "Writing base configuration..." 6 75 0
|
||||
# tear down the chroot environment
|
||||
_chroot_umount
|
||||
_run_locale_gen
|
||||
|
|
Loading…
Reference in a new issue