@@ -12,24 +12,24 @@ USER_CREATE_GROUP_ADD_LIST=()
1212zsh_yes_or_no () {
1313 zsh_enable=" "
1414 if [ -f " /etc/nozsh" ]; then
15- echo " $0 : INFO: No shell change because file /etc/nozsh exists, ok."
15+ printf ' %s\n ' " $0 : INFO: No shell change because file /etc/nozsh exists, ok."
1616 zsh_enable=no
1717 return 0
1818 fi
1919 if [ -f " /usr/local/etc/nozsh" ]; then
20- echo " $0 : INFO: No shell change because file /usr/local/etc/nozsh exists, ok."
20+ printf ' %s\n ' " $0 : INFO: No shell change because file /usr/local/etc/nozsh exists, ok."
2121 zsh_enable=no
2222 return 0
2323 fi
2424
2525 if grep -q ' nozsh' /proc/cmdline; then
26- echo " $0 : INFO: No shell change because nozsh in kernel command line, ok."
26+ printf ' %s\n ' " $0 : INFO: No shell change because nozsh in kernel command line, ok."
2727 zsh_enable=no
2828 return 0
2929 fi
3030
3131 if ! test -x /usr/bin/zsh ; then
32- echo " $0 : INFO: No shell change because /usr/bin/zsh does not exist or is not executable, ok."
32+ printf ' %s\n ' " $0 : INFO: No shell change because /usr/bin/zsh does not exist or is not executable, ok."
3333 zsh_enable=no
3434 return 0
3535 fi
@@ -88,13 +88,13 @@ password_empty_for_user_account() {
8888
8989 # # No longer in use.
9090 # # Use --encrypted to be able to use a static, precalculated hash for reproducible builds.
91- # echo "${user_to_be_created}:${password}" | chpasswd --encrypted
91+ # printf '%s\n' "${user_to_be_created}:${password}" | chpasswd --encrypted
9292
9393 # # adduser '--disabled-password' is not the same as 'passwd --delete user'.
9494 # # /etc/shadow:
9595 # user:!:19932:0:99999:7:::
9696
97- echo " INFO: Set empty password for account '$USER_CREATE_USERNAME '..."
97+ printf ' %s\n ' " INFO: Set empty password for account '$USER_CREATE_USERNAME '..."
9898 passwd --delete " $USER_CREATE_USERNAME "
9999 # # /etc/shadow:
100100 # user::19932:0:99999:7:::
@@ -120,31 +120,38 @@ linux_user_account_shell_to_zsh() {
120120 return 0
121121 fi
122122
123- echo " $0 : INFO: For more information, see: https://www.kicksecure.com/shell#default"
123+ printf ' %s\n ' " $0 : INFO: For more information, see: https://www.kicksecure.com/shell#default"
124124
125- if ! id " $USER_CREATE_USERNAME " & > /dev/null ; then
126- echo " $0 : INFO: account '$USER_CREATE_USERNAME ' does not exist. Not setting shell to zsh."
127- return
125+ if ! id -- " $USER_CREATE_USERNAME " & > /dev/null ; then
126+ printf ' %s\n ' " $0 : INFO: account '$USER_CREATE_USERNAME ' does not exist. Not setting shell to ' zsh' ."
127+ return 0
128128 fi
129129
130130 # # Use getent to retrieve the account's entry from /etc/passwd
131131 user_passwd_entry=$( getent passwd " $USER_CREATE_USERNAME " )
132132
133133 # # Extract the shell field (the last field) from the account's entry
134- user_default_shell=$( echo " $user_passwd_entry " | awk -F: ' {print $NF}' )
134+ user_default_shell=$( printf ' %s\n ' " $user_passwd_entry " | awk -F: ' {print $NF}' )
135135
136136 if [ " $user_default_shell " = " /usr/bin/zsh" ]; then
137+ true " INFO: user_default_shell is already /usr/bin/zsh. Skipping. Ok."
137138 return 0
138139 fi
139140
140- echo " $0 : INFO: Setting shell for account '$USER_CREATE_USERNAME ' to zsh."
141- # # Use timeout to prevent unexplained bug password prompt caused by chsh.
142- if ! timeout --kill-after 5 5 chsh --shell /usr/bin/zsh " $USER_CREATE_USERNAME " ; then
143- if [ ! " $derivative_maker " = " true" ] && ! [ -f ' /var/lib/dist-base-files/live_build' ]; then
144- echo " $0 : ERROR: Command 'chsh --shell /usr/bin/zsh $USER_CREATE_USERNAME ' failed during the build process."
145- exit 1
146- else
147- echo " $0 : ERROR: Command 'chsh --shell /usr/bin/zsh $USER_CREATE_USERNAME ' failed. This is only a minor issue."
148- fi
141+ printf ' %s\n' " $0 : INFO: Setting shell for account '$USER_CREATE_USERNAME ' to 'zsh'..."
142+ # # Use 'timeout' to prevent unexplained bug password prompt caused by 'chsh'.
143+ if timeout --kill-after 5 5 chsh --shell /usr/bin/zsh " $USER_CREATE_USERNAME " ; then
144+ printf ' %s\n' " $0 : INFO: Shell for account '$USER_CREATE_USERNAME ' has been set to 'zsh', ok."
145+ else
146+ if [ " $derivative_maker " = " true" ]; then
147+ printf ' %s\n' " $0 : ERROR: Command 'chsh --shell /usr/bin/zsh $USER_CREATE_USERNAME ' failed during the build process. (return 1 because derivative_maker=true)"
148+ return 1
149+ fi
150+ if [ -f ' /var/lib/dist-base-files/live_build' ]; then
151+ printf ' %s\n' " $0 : ERROR: Command 'chsh --shell /usr/bin/zsh $USER_CREATE_USERNAME ' failed during the build process. (return 1 because /var/lib/dist-base-files/live_build exists)"
152+ return 1
153+ fi
154+ printf ' %s\n' " $0 : ERROR: Command 'chsh --shell /usr/bin/zsh $USER_CREATE_USERNAME ' failed. This is only a minor issue."
155+ return 0
149156 fi
150157}
0 commit comments