1515# Check whether true or false is assigned to the variable.
1616function check_bool() {
1717 local
18- case $( eval echo ' $' ${1} ) in
18+ case $( eval echo ' $' " ${1} " ) in
1919 true | false) : ;;
2020 * ) echo " The value ${boot_splash} set is invalid" >&2 ;;
2121 esac
@@ -60,13 +60,8 @@ _groupadd(){
6060# Create a user.
6161# create_user <username> <password>
6262function create_user () {
63- local _password
64- local _username
63+ local _username=" ${1-" " } " _password=" ${2-" " } "
6564
66- _username=${1}
67- _password=${2}
68-
69- set +u
7065 if [[ -z " ${_username} " ]]; then
7166 echo " User name is not specified." >&2
7267 return 1
@@ -75,19 +70,18 @@ function create_user () {
7570 echo " No password has been specified." >&2
7671 return 1
7772 fi
78- set -u
7973
8074 if ! user_check " ${_username} " ; then
81- useradd -m -s ${usershell} ${_username}
75+ useradd -m -s " ${usershell} " " ${_username} "
8276 _groupadd sudo
83- usermod -U -g ${_username} ${_username}
84- usermod -aG sudo ${_username}
85- usermod -aG storage ${_username}
86- cp -aT /etc/skel/ /home/${_username} /
77+ usermod -U -g " ${_username} " " ${_username} "
78+ usermod -aG sudo " ${_username} "
79+ usermod -aG storage " ${_username} "
80+ cp -aT " /etc/skel/" " /home/${_username} /"
8781 fi
88- chmod 700 -R /home/${_username}
89- chown ${_username} :${_username} -R /home/${_username}
90- echo -e " ${_password} \n${_password} " | passwd ${_username}
82+ chmod 700 -R " /home/${_username} "
83+ chown " ${_username} :${_username} " -R " /home/${_username} "
84+ echo -e " ${_password} \n${_password} " | passwd " ${_username} "
9185 set -u
9286}
9387
@@ -100,7 +94,7 @@ _safe_systemctl(){
10094 for _service in " ${@ } " ; do
10195 # https://unix.stackexchange.com/questions/539147/systemctl-check-if-a-unit-service-or-target-exists
10296 if (( "$(systemctl list- unit- files "${_service} " | wc - l)" > 3 )) ; then
103- systemctl ${_command} " ${_service} "
97+ systemctl " ${_command} " " ${_service} "
10498 else
10599 echo " ${_service} was not found" >&2
106100 fi
0 commit comments