Compare commits
9 Commits
a3ccb1f3b4
...
jbomb-auto
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d0b3477cd | ||
|
|
e1f056a294 | ||
| e4f761b133 | |||
| aa297095b0 | |||
| 104a59c52c | |||
| 29adac2e70 | |||
| 9e3a36aa0e | |||
| 3ea86d7e35 | |||
| a1e8a03f60 |
64
jconf
Normal file → Executable file
64
jconf
Normal file → Executable 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
|
||||
|
||||
Reference in New Issue
Block a user