From 9a3251069867abad94d31d4a6e49213882581bb3 Mon Sep 17 00:00:00 2001 From: "Jean (east-high-Nerd)" Date: Wed, 31 Dec 2025 23:23:34 -0500 Subject: [PATCH] Split off new user creation into seperate script --- adduser.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ post-inst.sh | 37 +------------------------------------ 2 files changed, 53 insertions(+), 36 deletions(-) create mode 100755 adduser.sh diff --git a/adduser.sh b/adduser.sh new file mode 100755 index 0000000..dd086c5 --- /dev/null +++ b/adduser.sh @@ -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 diff --git a/post-inst.sh b/post-inst.sh index a9f9d17..1e94c71 100755 --- a/post-inst.sh +++ b/post-inst.sh @@ -73,42 +73,7 @@ source \ # adduser --no-create-home ${username} # fi -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 +"${baseDir}/adduser.sh" if [[ "${ID}" == 'elementary' ]]; then "${baseDir}/namarupa.sh"