Split off new user creation into seperate script
This commit is contained in:
52
adduser.sh
Executable file
52
adduser.sh
Executable 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
|
||||||
37
post-inst.sh
37
post-inst.sh
@@ -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"
|
||||||
|
|||||||
Reference in New Issue
Block a user