Split off new user creation into seperate script

This commit is contained in:
2025-12-31 23:23:34 -05:00
parent d186c475b0
commit 9a32510698
2 changed files with 53 additions and 36 deletions

52
adduser.sh Executable file
View File

@@ -0,0 +1,52 @@
#!/bin/bash
set -euo pipefail
baseDir="$(realpath "$(dirname "${0}")")"
source \
/etc/os-release
source \
"${baseDir}/system.conf"
printf \
'Adding user account...\n'
adduser ${username}
if [[ "${ID}" == 'fedora' ]]; then
printf \
'\033[?47h\033[2J\033[H'
cat << EOF
Enter a password for the new user account:
EOF
passwd \
${username}
printf \
'\033[?47l'
usermod \
-a \
-G \
audio,cdrom,dip,floppy,wheel,video,dialout \
${username}
else
if [[ -z "$(cat /etc/group | grep 'lpadmin')" ]]; then
groupadd --gid 108 lpadmin
fi
groups='audio,cdrom,dip,floppy,plugdev,sudo,video,dialout,lpadmin'
if [[ "${ID}" == 'debian' ]]; then
groups+=',netdev'
fi
usermod \
-a \
-G \
${groups} \
${username}
fi

View File

@@ -73,42 +73,7 @@ source \
# adduser --no-create-home ${username} # adduser --no-create-home ${username}
# fi # fi
if [[ "${ID}" == 'fedora' ]]; then "${baseDir}/adduser.sh"
printf \
'\033[?47h\033[2J\033[H'
cat << EOF
Enter a password for the new user account:
EOF
passwd \
${username}
printf \
'\033[?47l'
usermod \
-a \
-G \
audio,cdrom,dip,floppy,wheel,video,dialout \
${username}
else
if [[ -z "$(cat /etc/group | grep 'lpadmin')" ]]; then
groupadd --gid 108 lpadmin
fi
groups='audio,cdrom,dip,floppy,plugdev,sudo,video,dialout,lpadmin'
if [[ "${ID}" == 'debian' ]]; then
groups+=',netdev'
fi
usermod \
-a \
-G \
${groups} \
${username}
fi
if [[ "${ID}" == 'elementary' ]]; then if [[ "${ID}" == 'elementary' ]]; then
"${baseDir}/namarupa.sh" "${baseDir}/namarupa.sh"