more logging

This commit is contained in:
Bernhard Landauer 2017-02-21 23:40:40 +01:00
parent 94791411dd
commit 6a1ffacdc6
2 changed files with 32 additions and 36 deletions

View File

@ -9,7 +9,7 @@ set_keymap() {
KEYMAP=$(cat ${ANSWER})
loadkeys $KEYMAP 2>$ERR
check_for_error
check_for_error "loadkeys $KEYMAP" "$?"
biggest_resolution=$(head -n 1 /sys/class/drm/card*/*/modes | awk -F'[^0-9]*' '{print $1}' | awk 'BEGIN{a= 0}{if ($1>a) a=$1 fi} END{print a}')
# Choose terminus font size depending on resolution
if [[ $biggest_resolution -gt 1920 ]]; then
@ -53,7 +53,7 @@ set_locale() {
echo "LANG=\"${LOCALE}\"" > ${MOUNTPOINT}/etc/locale.conf
sed -i "s/#${LOCALE}/${LOCALE}/" ${MOUNTPOINT}/etc/locale.gen 2>$ERR
arch_chroot "locale-gen" >/dev/null 2>$ERR
check_for_error
check_for_error "$FUNCNAME" "$?"
}
# Set Zone and Sub-Zone
@ -78,7 +78,7 @@ set_timezone() {
if [[ $? -eq 0 ]]; then
arch_chroot "ln -s /usr/share/zoneinfo/posix/${ZONE}/${SUBZONE} /etc/localtime" 2>$ERR
check_for_error
check_for_error "$FUNCNAME" "$?"
else
config_base_menu
fi
@ -89,7 +89,7 @@ set_hw_clock() {
"utc" "-" \
"localtime" "-" 2>${ANSWER}
[[ $(cat ${ANSWER}) != "" ]] && arch_chroot "hwclock --systohc --$(cat ${ANSWER})" 2>$ERR && check_for_error
[[ $(cat ${ANSWER}) != "" ]] && arch_chroot "hwclock --systohc --$(cat ${ANSWER})" 2>$ERR && check_for_error "$FUNCNAME" "$?"
}
# Function will not allow incorrect UUID type for installed system.
@ -106,7 +106,7 @@ generate_fstab() {
generate_fstab
else
$(cat ${ANSWER}) ${MOUNTPOINT} > ${MOUNTPOINT}/etc/fstab 2>$ERR
check_for_error
check_for_error "$FUNCNAME" "$?"
[[ -f ${MOUNTPOINT}/swapfile ]] && sed -i "s/\\${MOUNTPOINT}//" ${MOUNTPOINT}/etc/fstab
fi
fi
@ -120,7 +120,7 @@ set_hostname() {
echo "$(cat ${ANSWER})" > ${MOUNTPOINT}/etc/hostname 2>$ERR
echo -e "#<ip-address>\t<hostname.domain.org>\t<hostname>\n127.0.0.1\tlocalhost.localdomain\tlocalhost\t$(cat \
${ANSWER})\n::1\tlocalhost.localdomain\tlocalhost\t$(cat ${ANSWER})" > ${MOUNTPOINT}/etc/hosts 2>$ERR
check_for_error
check_for_error "$FUNCNAME" "$?"
}
# Adapted and simplified from the Manjaro 0.8 and Antergos 2.0 installers
@ -137,7 +137,7 @@ set_root_password() {
echo -e "${PASSWD}\n${PASSWD}" > /tmp/.passwd
arch_chroot "passwd root" < /tmp/.passwd >/dev/null 2>$ERR
rm /tmp/.passwd
check_for_error
check_for_error "$FUNCNAME" "$?"
else
DIALOG " $_ErrTitle " --msgbox "$_PassErrBody" 0 0
set_root_password
@ -189,11 +189,11 @@ create_new_user() {
# Create the user, set password, then remove temporary password file
arch_chroot "groupadd ${USER}"
arch_chroot "useradd ${USER} -m -g ${USER} -G wheel,storage,power,network,video,audio,lp -s /bin/$shell" 2>$ERR
check_for_error
check_for_error "add user to groups" "$?"
echo -e "${PASSWD}\n${PASSWD}" > /tmp/.passwd
arch_chroot "passwd ${USER}" < /tmp/.passwd >/dev/null 2>$ERR
rm /tmp/.passwd
check_for_error
check_for_error "create user pwd" "$?"
# Set up basic configuration files and permissions for user
#arch_chroot "cp /etc/skel/.bashrc /home/${USER}"
@ -210,10 +210,10 @@ run_mkinitcpio() {
([[ $LVM -eq 1 ]] && [[ $LUKS -eq 0 ]]) && sed -i 's/block filesystems/block lvm2 filesystems/g' ${MOUNTPOINT}/etc/mkinitcpio.conf 2>$ERR
([[ $LVM -eq 1 ]] && [[ $LUKS -eq 1 ]]) && sed -i 's/block filesystems/block encrypt lvm2 filesystems/g' ${MOUNTPOINT}/etc/mkinitcpio.conf 2>$ERR
([[ $LVM -eq 0 ]] && [[ $LUKS -eq 1 ]]) && sed -i 's/block filesystems/block encrypt filesystems/g' ${MOUNTPOINT}/etc/mkinitcpio.conf 2>$ERR
check_for_error
check_for_error "lVM/LUKS hooks" "$?"
arch_chroot "mkinitcpio -P" 2>$ERR
check_for_error
check_for_error "$FUNCNAME" "$?"
}
install_base() {
@ -326,7 +326,7 @@ uefi_bootloader() {
if [[ $(cat ${PACKAGES}) != "" ]]; then
clear
basestrap ${MOUNTPOINT} $(cat ${PACKAGES} | grep -v "systemd-boot") efibootmgr dosfstools 2>$ERR
check_for_error
check_for_error "uefi_bootloader" "$?"
case $(cat ${PACKAGES}) in
"grub")
@ -342,7 +342,7 @@ uefi_bootloader() {
# Generate config file
arch_chroot "grub-mkconfig -o /boot/grub/grub.cfg" 2>$ERR
check_for_error
check_for_error "grub-mkconfig" "$?"
# Ask if user wishes to set Grub as the default bootloader and act accordingly
DIALOG " $_InstUefiBtTitle " --yesno \
@ -351,14 +351,14 @@ uefi_bootloader() {
if [[ $? -eq 0 ]]; then
arch_chroot "mkdir ${UEFI_MOUNT}/EFI/boot" 2>$ERR
arch_chroot "cp -r ${UEFI_MOUNT}/EFI/arch_grub/grubx64.efi ${UEFI_MOUNT}/EFI/boot/bootx64.efi" 2>$ERR
check_for_error
check_for_error "Install GRUB" "$?"
DIALOG " $_InstUefiBtTitle " --infobox "\nGrub $_SetDefDoneBody" 0 0
sleep 2
fi
;;
"systemd-boot")
arch_chroot "bootctl --path=${UEFI_MOUNT} install" 2>$ERR
check_for_error
check_for_error "systemd-boot" "$?"
# Deal with LVM Root
[[ $(echo $ROOT_PART | grep "/dev/mapper/") != "" ]] && bl_root=$ROOT_PART \
@ -404,7 +404,7 @@ bios_bootloader() {
if [[ $(cat ${PACKAGES}) != "" ]]; then
sed -i 's/+\|\"//g' ${PACKAGES}
basestrap ${MOUNTPOINT} $(cat ${PACKAGES}) 2>$ERR
check_for_error
check_for_error "$FUNCNAME" "$?"
# If Grub, select device
if [[ $(cat ${PACKAGES} | grep "grub") != "" ]]; then
@ -428,7 +428,7 @@ bios_bootloader() {
sed -e '/GRUB_SAVEDEFAULT/ s/^#*/#/' -i ${MOUNTPOINT}/etc/default/grub
arch_chroot "grub-mkconfig -o /boot/grub/grub.cfg" 2>$ERR
check_for_error
check_for_error "grub-mkconfig" "$?"
fi
else
# Syslinux
@ -438,7 +438,7 @@ bios_bootloader() {
# If an installation method has been chosen, run it
if [[ $(cat ${PACKAGES}) != "" ]]; then
arch_chroot "$(cat ${PACKAGES})" 2>$ERR
check_for_error
check_for_error "syslinux-install" "$?"
# Amend configuration file. First remove all existing entries, then input new ones.
sed -i '/^LABEL.*$/,$d' ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
@ -484,7 +484,7 @@ install_bootloader() {
# Set the default PATH variable
arch_chroot "PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl" 2>$ERR
check_for_error
check_for_error "set PATH" "$?"
if [[ $SYSTEM == "BIOS" ]]; then
bios_bootloader
@ -520,7 +520,7 @@ install_wireless_packages() {
if [[ $(cat ${PACKAGES}) != "" ]]; then
clear
basestrap ${MOUNTPOINT} $(cat ${PACKAGES}) 2>$ERR
check_for_error
check_for_error "$FUNCNAME" "$?"
fi
}
@ -535,7 +535,7 @@ install_cups() {
if [[ $(cat ${PACKAGES}) != "" ]]; then
clear
basestrap ${MOUNTPOINT} $(cat ${PACKAGES}) 2>$ERR
check_for_error
check_for_error "$FUNCNAME" "$?"
if [[ $(cat ${PACKAGES} | grep "cups") != "" ]]; then
DIALOG " $_InstNMMenuCups " --yesno "$_InstCupsQ" 0 0
@ -547,7 +547,7 @@ install_cups() {
else
arch_chroot "systemctl enable org.cups.cupsd.service" 2>$ERR
fi
check_for_error
check_for_error "enable cups" "$?"
DIALOG " $_InstNMMenuCups " --infobox "\n$_Done!\n\n" 0 0
sleep 2
fi
@ -635,7 +635,7 @@ install_xorg_input() {
# If at least one package, install.
if [[ $(cat ${PACKAGES}) != "" ]]; then
basestrap ${MOUNTPOINT} $(cat ${PACKAGES}) 2>$ERR
check_for_error
check_for_error "$FUNCNAME" "$?"
fi
# now copy across .xinitrc for all user accounts
@ -671,7 +671,7 @@ setup_graphics_card() {
sed -i 's/MODULES=""/MODULES="nouveau"/' ${MOUNTPOINT}/etc/mkinitcpio.conf
fi
check_for_error
check_for_error "$FUNCNAME" "$?"
install_graphics_menu
}

View File

@ -95,7 +95,7 @@ import(){
else
echo "Could not import $1"
fi
}
DIALOG() {
dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --column-separator "|" --title "$@"
@ -143,15 +143,11 @@ id_system() {
[[ $H_INIT == "systemd" ]] && [[ $(systemctl is-active NetworkManager) == "active" ]] && NW_CMD=nmtui
}
LOG(){
echo "$(date +%D\ %T\ %Z) ##$1" >> $LOGFILE
}
# If there is an error, display it and go back to main menu. In any case, write to logfile.
check_for_error() {
local _msg="[$1]"
local _err="$2"
[[ -f "${ERR}" ]] && {
[[ -f "${ERR}" ]] && {
_msg="${_msg}: $(head -n1 ${ERR})"
rm "${ERR}"
}
@ -291,7 +287,7 @@ rank_mirrors() {
"unstable" "-" off 2>${BRANCH}
clear
[[ ! -z "$(cat ${BRANCH})" ]] && pacman-mirrors -gib "$(cat ${BRANCH})" && \
LOG "branch selected: $(cat ${BRANCH})"
check_for_error "branch selected: $(cat ${BRANCH})" "$?"
}
# Originally adapted from AIS. Added option to allow users to edit the mirrorlist.
@ -305,14 +301,14 @@ configure_mirrorlist() {
case $(cat ${ANSWER}) in
"1") rank_mirrors
LOG "rank mirrors"
check_for_error "rank mirrors" "$?"
;;
"2") nano /etc/pacman-mirrors.conf
LOG "edit pacman-mirrors.conf"
check_for_error "edit pacman-mirrors.conf" "$?"
;;
"3") nano /etc/pacman.conf
DIALOG " $_MirrorPacman " --yesno "$_MIrrorPacQ" 0 0 \
&& LOG "edit pacman.conf" && COPY_PACCONF=1 || COPY_PACCONF=0
&& check_for_error "edit pacman.conf" "$?" && COPY_PACCONF=1 || COPY_PACCONF=0
pacman -Syy
;;
*) install_base_menu
@ -352,11 +348,11 @@ check_base() {
# install a pkg in the live session if not installed
inst_needed() {
[[ ! $(pacman -Q $1 2>/dev/null) ]] && pacman -Sy --noconfirm $1
LOG "Install needed pkg $1."
check_for_error "Install needed pkg $1." "$?"
}
# install a pkg in the chroot if not installed
check_pkg() {
arch_chroot "[[ ! $(pacman -Q $1 2>/dev/null) ]] && pacman -Sy --noconfirm $1" 2>$ERR
LOG "Install missing pkg $1 to target."
check_for_error "install missing pkg $1 to target." "$?"
}