Minor improvements and fixes
Was missing a few forgotten variables
This commit is contained in:
parent
bb6dd68dd2
commit
0eb08ba8c0
60
autouser.sh
60
autouser.sh
|
@ -90,25 +90,27 @@ createUser() {
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteGroup() {
|
deleteGroup() {
|
||||||
if [[ "$DRYRUN" == true ]]; then
|
COMMAND=""
|
||||||
read -p "Enter group name: " GROUPNAME
|
if [[ "$DRYRUN" == false ]]; then
|
||||||
echo "groupadd $GROUPNAME"
|
|
||||||
else
|
|
||||||
rootCheck
|
rootCheck
|
||||||
read -p "Enter group name: " GROUPNAME
|
COMMAND="groupdel"
|
||||||
groupadd $GROUPNAME
|
else
|
||||||
|
COMMAND="echo groupdel"
|
||||||
fi
|
fi
|
||||||
|
read -p "Enter group name: " GROUPNAME
|
||||||
|
$COMMAND $GROUPNAME
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteUser() {
|
deleteUser() {
|
||||||
if [[ "$DRYRUN" == true ]]; then
|
COMMAND=""
|
||||||
read -p "Enter username: " USERNAME
|
if [[ "$DRYRUN" == false ]]; then
|
||||||
echo "userdel -r $USERNAME"
|
|
||||||
else
|
|
||||||
rootCheck
|
rootCheck
|
||||||
read -p "Enter username: " USERNAME
|
COMMAND="userdel"
|
||||||
userdel -r $USERNAME
|
else
|
||||||
|
COMMAND="echo userdel"
|
||||||
fi
|
fi
|
||||||
|
read -p "Enter username: " USERNAME
|
||||||
|
$COMMAND -r $USERNAME
|
||||||
}
|
}
|
||||||
|
|
||||||
rootCheck ()
|
rootCheck ()
|
||||||
|
@ -238,25 +240,20 @@ createUsers ()
|
||||||
deleteUsers ()
|
deleteUsers ()
|
||||||
{
|
{
|
||||||
checkFile
|
checkFile
|
||||||
|
COMMAND=""
|
||||||
if [[ "$DRYRUN" == false ]]; then
|
if [[ "$DRYRUN" == false ]]; then
|
||||||
rootCheck
|
rootCheck
|
||||||
USERADDER="useradd"
|
USERDELER="userdel"
|
||||||
CHFNER="chfn"
|
GROUPDELER="groupdel"
|
||||||
else
|
else
|
||||||
USERADDER="echo useradd"
|
USERDELER="echo userdel"
|
||||||
CHFNER="echo chfn"
|
GROUPDELER="echo groupdel"
|
||||||
USERMOD="echo usermod"
|
|
||||||
fi
|
fi
|
||||||
while read line; do
|
while read line; do
|
||||||
USERNAME=$(turnLowercase $(cutter "${line}" "$COL_USERNAME"))
|
USERNAME=$(turnLowercase $(cutter "${line}" "$COL_USERNAME"))
|
||||||
echo "[+] Deleting user $USERNAME..."
|
echo "[+] Deleting user $USERNAME..."
|
||||||
if [[ "$DRYRUN" == true ]]; then
|
$USERDELER -r $USERNAME 2>/dev/null
|
||||||
echo "userdel -r $USERNAME"
|
$GROUPDELER $USERNAME 2>/dev/null
|
||||||
echo "groupdel $USERNAME"
|
|
||||||
else
|
|
||||||
userdel -r $USERNAME 2>/dev/null
|
|
||||||
groupdel $USERNAME 2>/dev/null
|
|
||||||
fi
|
|
||||||
done <<< "$FILE_CONTENTS"
|
done <<< "$FILE_CONTENTS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,6 +292,11 @@ do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ "$ACTION_TO_TAKE" == "" ]]; then
|
||||||
|
usage
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
case "$ACTION_TO_TAKE" in
|
case "$ACTION_TO_TAKE" in
|
||||||
create-groups)
|
create-groups)
|
||||||
createGroups
|
createGroups
|
||||||
|
@ -320,10 +322,16 @@ case "$ACTION_TO_TAKE" in
|
||||||
createUser
|
createUser
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
delete-group)
|
||||||
|
deleteGroup
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
delete-user)
|
||||||
|
deleteUser
|
||||||
|
exit
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Invalid parameter! Exiting..."
|
echo "Invalid parameter! Exiting..."
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
usage
|
|
||||||
|
|
Loading…
Reference in New Issue