Merge pull request 'jbomb-automate' (#4) from jbomb-automate into master
All checks were successful
/ Lint Check Shellscripts (push) Successful in 11s

Reviewed-on: #4
This commit was merged in pull request #4.
This commit is contained in:
2026-01-13 15:03:35 +00:00

64
jconf Normal file → Executable file
View File

@@ -39,16 +39,72 @@ if [ "$#" -lt 1 ]; then
exit 1
fi
if [[ "$EUID" -ne 0 ]]; then
echo "Run the script as root"
exit 2
fi
cmd=$1
case "$cmd" in
adduser)
echo
USER=$(echo "$2" | tr "[:upper:]" "[:lower:]")
exist=$(awk -F: -v username="$USER" '{if ($1 == username && $3 >= 1000 && $1 != "nobody") {print 1; found=1; exit}} END {if (!found) print 0}' /etc/passwd)
if [ "$exist" -eq 1 ]; then
echo "$USER user already exists"
else
read -rp "Do you want to create an user account $USER [y/N]:" yn
case $yn in
[Yy])
useradd "$USER"
echo "Enter the password for $USER"
passwd "$USER"
echo "$USER user account created successfully"
;;
[Nn])
exit 1
;;
* )
echo "Please answer Y or N."
;;
esac
fi
exit 1
;;
deluser)
echo
USER=$(echo "$2" | tr "[:upper:]" "[:lower:]")
exist=$(awk -F: -v username="$USER" '{if ($1 == username && $3 >= 1000 && $1 != "nobody") {print 1; found=1; exit}} END {if (!found) print 0}' /etc/passwd)
if [ "$exist" -eq 0 ]; then
echo "$USER user doesn't exist"
exit 1
else
read -rp "Do you want to delete $USER user account? [y/N]:" yn
case $yn in
[Yy])
;;
*)
exit 1
;;
esac
read -rp "This DELETES $USER's data, are you sure? [y/N]:" yn
case $yn in
[Yy])
userdel -rRZ "$USER";
echo "$USER user account deleted successfully"
;;
[Nn])
exit 1
;;
* )
echo "Please answer Y or N."
;;
esac
fi
exit 1
;;
listusers)
echo
listusers|ls)
husers=$(awk -F: '{ if ($3 >= 1000 && $1 != "nobody" ) {print $1}}' /etc/passwd)
echo "$husers"
;;
start)
echo