From 2e730506e017365bea0b7198ea8cafac81a97173 Mon Sep 17 00:00:00 2001 From: natemaia Date: Thu, 17 Oct 2019 19:53:32 -0700 Subject: [PATCH] Make dwm install into a function to save space --- archlabs-installer | 52 +++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/archlabs-installer b/archlabs-installer index fc3a768..9b8a0bf 100755 --- a/archlabs-installer +++ b/archlabs-installer @@ -5,7 +5,7 @@ # Some ideas and code reworked from other resources # AIF, Cnichi, Calamares, Arch Wiki.. Credit where credit is due -VER=2.0.80 +VER=2.0.81 # bulk default values { @@ -1334,6 +1334,8 @@ install_boot() install_user() { + local groups='audio,floppy,log,network,rfkill,scanner,storage,optical,power,wheel' + rm -f $MNT/root/.zshrc # remove welcome message from root zshrc chrun "chpasswd <<< 'root:$ROOT_PASS'" 2>$ERR @@ -1342,28 +1344,22 @@ install_user() chrun "usermod -s /bin/$MYSHELL root" 2>$ERR errshow 1 "usermod -s /bin/$MYSHELL root" # copy the default mkshrc to /root if it was selected - [[ $MYSHELL == 'mksh' ]] && cp -fv $MNT/etc/skel/.mkshrc $MNT/root/.mkshrc + [[ $MYSHELL == 'mksh' ]] && cp -fv "$MNT/etc/skel/.mkshrc" "$MNT/root/.mkshrc" fi echo "Creating new user $NEWUSER and setting password" - local groups='audio,floppy,log,network,rfkill,scanner,storage,optical,power,wheel' - chrun "useradd -m -u 1000 -g users -G $groups -s /bin/$MYSHELL $NEWUSER" 2>$ERR errshow 1 "useradd -m -u 1000 -g users -G $groups -s /bin/$MYSHELL $NEWUSER" chrun "chpasswd <<< '$NEWUSER:$USER_PASS'" 2>$ERR errshow 1 "set $NEWUSER password" if [[ $INSTALL_WMS == *dwm* ]];then - mkdir -pv "$MNT/home/$NEWUSER/suckless" - for i in dwm dmenu st; do - if chrun "git clone https://git.suckless.org/$i /home/$NEWUSER/suckless/$i"; then - chrun "cd /home/$NEWUSER/suckless/$i; make prefix=/usr install; make clean" - else - printf "failed to clone %s repo\n" "$i" - fi - done + install_suckless "/home/$NEWUSER" chroot + [[ $INSTALL_WMS == 'dwm' ]] && rm -rf "$MNT/home/$NEWUSER/.config/xfce4" fi + [[ $INSTALL_WMS != *bspwm* && $INSTALL_WMS != *openbox* ]] && rm -rf "$MNT/home/$NEWUSER/.config/"{jgmenu,tint2} + [[ $USER_PKGS != *geany* ]] && rm -rf "$MNT/home/$NEWUSER/.config/geany" [[ $MYSHELL != 'bash' ]] && rm -rf "$MNT/home/$NEWUSER/.bash"* [[ $MYSHELL != 'zsh' ]] && rm -rf "$MNT/home/$NEWUSER/.z"* @@ -1519,6 +1515,32 @@ install_background() trap "kill $BG_PID 2>/dev/null" EXIT } +install_suckless() +{ + local dir="$1/suckless" + shift + + if [[ $2 == 'chroot' ]]; then + chrun "mkdir -pv '$dir'" + for i in dwm dmenu st; do + if chrun "git clone 'https://git.suckless.org/$i' '$dir/$i'"; then + chrun "cd '$dir/$i' && make PREFIX=/usr install" + else + printf "failed to clone %s repo\n" "$i" + fi + done + else + mkdir -pv "$dir" + for i in dwm dmenu st; do + if git clone "https://git.suckless.org/$i" "$dir/$i"; then + cd "$dir/$i" && make PREFIX=/usr install + else + printf "failed to clone %s repo\n" "$i" + fi + done + fi +} + ############################################################################### # display manager config # these are called based on which DM is chosen after it is installed @@ -2164,10 +2186,7 @@ live() case "$ses" in dwm) pacman -S git --needed --noconfirm || die 1 - mkdir -pv /root/suckless - for i in dwm dmenu st; do - git clone https://git.suckless.org/$i /root/suckless/$i && cd /root/suckless/$i && make PREFIX=/usr install - done + install_suckless "/root" nochroot ;; i3-gaps|oepnbox|fluxbox|bspwm|awesome) pacman -S "$ses" $WM_BASE_PKGS ${WM_EXT[$ses]} xterm --needed --noconfirm || die 1 @@ -2447,7 +2466,6 @@ elif ! net_connect; then msg "Not Connected" "\nThis installer requires an active internet connection.\n\nExiting..\n" 2 die 1 fi - FORMATTED="" while :; do