void-bash-installer/step1/20-users

85 lines
2.0 KiB
Plaintext

module "start" "users" "Configuring User"
repeat=""
index="0"
amount_of_usernames="0"
counter="0"
while echo $((index++)) > /dev/null; do
if [[ "${repeat}" == "1" ]] || [[ "${standalone}" == "1" ]]; then
while input "how many users?" "1"; do
if check num "${output}"; then
amount_of_usernames="${output}"
break
fi
done
elif [[ "${#additional_user[@]}" -gt 0 ]]; then
amount_of_usernames="${#additional_user[@]}"
else
amount_of_usernames=1
fi
for i in $(seq 1 "${amount_of_usernames}"); do
if [[ ! -z "${additional_user[$i]}" ]]; then
echo "additional_user: ${additional_user[$i]}"
output="${additional_user[$i]}"
additional_user+=( [$i]="" )
else
while input "Username:" "voiduser"; do
#if grep -q -w "${output}" /etc/passwd; then
# useradder "name" "${counter}" "${output}"
# echo user exists in the system
# continue
#fi
found=""
for n in ${usernames[@]}; do
if [[ "${n}" == "${output}" ]]; then
echo user was configured before
found=1
fi
done
test -z "${found}" || continue
if check alnum "${output}"; then
counter=$(( counter + 1 ))
useradder "name" "${counter}" "${output}"
usernames+=( "${output}" )
break
fi
done
fi
input "full name (optional)" "${output}"
useradder "desc" "${i}" "-c ${output}"
if [[ "${repeat}" == "1" ]] || [[ "${standalone}" == "1" ]]; then
if yesno "sudo?" n; then
useradder "sudo" "${counter}" "1"
else
useradder "sudo" "${counter}" "1"
fi
elif [[ ! "${repeat}" == "1" ]]; then
useradder "sudo" "${counter}" "1"
fi
useradder "shell" "${counter}" "/usr/bin/bash"
done
#input_pw "User ${users[name${counter}]} password"
output="oem"
#useradder "pw" "${counter}" "${output}"
users+=( [pw${counter}]="${output}" )
echo "${users[pw1]}"
if [[ "${standalone}" == "1" ]]; then
if ! yesno "More users?" "n"; then
break
fi
#set -x
repeat=1
additional_user=()
else
break
fi
done
useradder "am" "ount" "${counter}"
module end