obosdi-pkg/config/accounts/users/menu

48 lines
1.2 KiB
Text
Raw Permalink Normal View History

2015-08-20 14:37:06 -06:00
#!/bin/bash
. ./lib
options=()
options+=("Add User" "")
options+=("List Users" "")
options+=("Delete User" "")
defaultitem=""
2022-11-10 14:27:23 -07:00
sel=$(dialog --backtitle "$apptitle" --title "Users Menu :" --default-item "$defaultitem" --cancel-button "Back" --menu "" 0 0 0 \
2015-08-20 14:37:06 -06:00
"${options[@]}" \
3>&1 1>&2 2>&3)
if [ ! "$?" = "0" ]; then
exit 1
fi
sed -i "/^defaultitem=/c\defaultitem=\"$sel\"" $0
case $sel in
'List Users')
clear
awk -F: '{if ($3 >= 1000 && $3 <= 5000) { print $1 } }' /etc/passwd
2015-08-20 14:37:06 -06:00
read -n1 -p "press a key to continue"
;;
'Add User')
2022-11-10 14:27:23 -07:00
username=$(dialog --backtitle "$apptitle" --title "Add User" --inputbox "Enter the new user name :" 0 0 3>&1 1>&2 2>&3)
2015-08-20 14:37:06 -06:00
if [ "$?" = "0" ]; then
useradd -d /home/$username -s /bin/bash -m -N $username
clear
echo "User $username created."
echo ""
echo "Choose a password for $username :"
echo ""
passwd $username
2015-10-13 13:59:09 -06:00
grpck
2015-08-20 14:37:06 -06:00
pressanykey
fi
;;
'Delete User')
2022-11-10 14:27:23 -07:00
username=$(dialog --backtitle "$apptitle" --title "Delete User" --inputbox "Enter the user name to delete :" 0 0 3>&1 1>&2 2>&3)
2015-08-20 14:37:06 -06:00
if [ "$?" = "0" ]; then
userdel -r -f $username
2015-10-13 13:59:09 -06:00
grpck
2015-08-20 14:37:06 -06:00
fi
;;
esac
exit 0