OSDN Git Service

Fix: live() being passed $@ without first shifting
authornatemaia <natemaia10@gmail.com>
Sun, 15 Sep 2019 17:30:44 +0000 (10:30 -0700)
committernatemaia <natemaia10@gmail.com>
Sun, 15 Sep 2019 17:30:44 +0000 (10:30 -0700)
archlabs-installer

index 08a5e9c..5c49891 100755 (executable)
@@ -14,7 +14,7 @@
 # will result in "My Distro Linux" used where needed
 : ${DIST="ArchLabs"}
 
-VER="2.0.69"     # installer version
+VER="2.0.70"     # installer version
 MNT="/mnt"       # install mountpoint
 ANS="/tmp/ans"   # dialog answer file
 
@@ -73,7 +73,7 @@ USER_PASS=''      # new user's password
 ROOT_PASS=''      # root password
 
 KERNEL=''         # linux kernel, can be: linux, linux-lts, linux-zen, or linux-hardened
-MYSHELL=''        # full path for the shell, eg. /usr/bin/zsh
+MYSHELL=''        # shell to use for the system, eg. zsh
 UCODE=''          # cpu microcode (if any), can be: amd-ucode, intel-ucode
 
 LUKS=''           # empty when not using encryption
@@ -447,9 +447,9 @@ select_config()
        until [[ $CONFIG_DONE ]]; do
                case $i in
                        0) dlg MYSHELL menu "Shell" "\nChoose which shell to use." \
-                                       /usr/bin/zsh  'A very advanced and programmable command interpreter (shell) for UNIX' \
-                                       /bin/bash     'The GNU Bourne Again shell, standard in many GNU/Linux distributions' \
-                                       /usr/bin/mksh 'The MirBSD Korn Shell - an enhanced version of the public domain ksh' || return 1
+                                       zsh  'A very advanced and programmable command interpreter (shell) for UNIX' \
+                                       bash 'The GNU Bourne Again shell, standard in many GNU/Linux distributions' \
+                                       mksh 'The MirBSD Korn Shell - an enhanced version of the public domain ksh' || return 1
                                ;;
                        1) dlg MYHOST input "Hostname" "$_hostname" "${DIST,,}" limit || { i=0; continue; } ;;
                        2) dlg MYLOCALE menu "Locale" "$_locale" $LOCALES || { i=1; continue; } ;;
@@ -470,7 +470,7 @@ select_config()
                (( i++ )) # progress through to the next choice
        done
 
-       case $MYSHELL in *bash) LOGINRC='.bash_profile' ;; *zsh) LOGINRC='.zprofile' ;; *mksh) LOGINRC='.profile' ;; esac
+       case $MYSHELL in bash) LOGINRC='.bash_profile' ;; zsh) LOGINRC='.zprofile' ;; mksh) LOGINRC='.profile' ;; esac
 
        return 0
 }
@@ -1485,18 +1485,18 @@ install_user()
 
        chrun "chpasswd <<< 'root:$ROOT_PASS'" 2>$ERR
        errshow 1 "set root password"
-       if [[ $MYSHELL != "/usr/bin/zsh" ]]; then # root uses zsh by default, change it if something else was chosen
-               chrun "usermod -s $MYSHELL root" 2>$ERR
-               errshow 1 "usermod -s $MYSHELL root"
+       if [[ $MYSHELL != 'zsh' ]]; then # root uses zsh by default, change it if something else was chosen
+               chrun "usermod -s /bin/$MYSHELL root" 2>$ERR
+               errshow 1 "usermod -s /bin/$MYSHELL root"
                # copy the default mkshrc to /root if mksh was picked
-               [[ $MYSHELL == '/usr/bin/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 $MYSHELL $NEWUSER" 2>$ERR
-       errshow 1 "useradd -m -u 1000 -g users -G $groups -s $MYSHELL $NEWUSER"
+       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"
 
@@ -1572,11 +1572,7 @@ install_packages()
        local rmpkg="archlabs-installer "
        local inpkg="$BASE_PKGS ${LOGIN_PKGS[$LOGIN_TYPE]} $PACKAGES $USER_PKGS "
 
-       case $MYSHELL in
-               *zsh) inpkg+="zsh-completions " ;;
-               *mksh) inpkg+="mksh " rmpkg+="zsh " ;;
-               *bash) inpkg+="bash-completion " rmpkg+="zsh " ;;
-       esac
+       case $MYSHELL in zsh) inpkg+="zsh-completions " ;; mksh) inpkg+="mksh " rmpkg+="zsh " ;; bash) inpkg+="bash-completion " rmpkg+="zsh " ;; esac
 
        # using a different kernel, remove the stock one
        [[ $KERNEL != 'linux' ]] && inpkg+="$KERNEL " rmpkg+="linux "
@@ -2281,16 +2277,27 @@ live()
        trap - INT
        pacman -Syyu --noconfirm || die 1
        pacman -S $AL_BASE_PKGS $WM_BASE_PKGS xorg-xinit xorg-server --needed --noconfirm || die 1
-       case "$1" 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 ;;
-               i3-gaps|oepnbox|fluxbox|bspwm|xfce4|gnome|plasma|cinnamon|awesome) pacman -S "$1" ${WM_EXT[$1]} xterm --needed --noconfirm ;;
-               *) echo "error: invalid session for -l, --live, see -h, --help"; die 1 ;;
-       esac
-       pacman -Scc --noconfirm  # these get back some space
+       for ses; do
+               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
+                               ;;
+                       i3-gaps|oepnbox|fluxbox|bspwm|xfce4|gnome|plasma|cinnamon|awesome)
+                               pacman -S "$1" ${WM_EXT[$1]} xterm --needed --noconfirm || die 1
+                               ;;
+                       *)
+                               echo "error: invalid session for -l, --live, see -h, --help"
+                               die 1
+                               ;;
+               esac
+       done
+       pacman -Scc --noconfirm
        rm -rf /var/cache/pacman/pkg/*
        cp -rfT /etc/skel /root || die 1
        sed -i "/exec/ c exec ${WM_SESSIONS[$1]}" /root/.xinitrc
@@ -2526,6 +2533,7 @@ elif [[ $1 =~ (-h|--help) ]]; then
 elif [[ $1 =~ (-d|--debug) ]]; then
        debug
 elif [[ $1 =~ (-l|--live) ]]; then
+       shift
        live "$@"
 fi