lowercase usernames
All checks were successful
/ Lint Check Shellscripts (push) Successful in 16s
/ Lint Check Shellscripts (pull_request) Successful in 12s

This commit is contained in:
Phani Pavan K
2026-01-13 20:32:34 +05:30
parent e1f056a294
commit 0d0b3477cd

29
jconf
View File

@@ -48,17 +48,18 @@ fi
cmd=$1
case "$cmd" in
adduser)
exist=$(awk -F: -v username="$2" '{if ($1 == username && $3 >= 1000 && $1 != "nobody") {print 1; found=1; exit}} END {if (!found) print 0}' /etc/passwd)
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 "$2 user already exists"
echo "$USER user already exists"
else
read -rp "Do you want to create an user account $2 [y/N]:" yn
read -rp "Do you want to create an user account $USER [y/N]:" yn
case $yn in
[Yy])
useradd "$2"
echo "Enter the password for $2"
passwd "$2"
echo "$2 user account created successfully"
useradd "$USER"
echo "Enter the password for $USER"
passwd "$USER"
echo "$USER user account created successfully"
;;
[Nn])
exit 1
@@ -71,13 +72,13 @@ case "$cmd" in
exit 1
;;
deluser)
exist=$(awk -F: -v username="$2" '{if ($1 == username && $3 >= 1000 && $1 != "nobody") {print 1; found=1; exit}} END {if (!found) print 0}' /etc/passwd)
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 "$2 user doesn't exist"
echo "$USER user doesn't exist"
exit 1
else
read -rp "Do you want to delete $2 user account? [y/N]:" yn
read -rp "Do you want to delete $USER user account? [y/N]:" yn
case $yn in
[Yy])
;;
@@ -85,11 +86,11 @@ case "$cmd" in
exit 1
;;
esac
read -rp "This DELETES $2's data, are you sure? [y/N]:" yn
read -rp "This DELETES $USER's data, are you sure? [y/N]:" yn
case $yn in
[Yy])
userdel -rRZ "$2";
echo "$2 user account deleted successfully"
userdel -rRZ "$USER";
echo "$USER user account deleted successfully"
;;
[Nn])
exit 1