From: Michael Mrozek Date: Thu, 15 Apr 2010 02:09:23 +0000 (+0200) Subject: op_usermanager: Changed the behaviour to make it more comfortable X-Git-Tag: Release-2010-05/1~44 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=faa96679ba1cdb1751e39afee40afa9be17f792a;p=openpandora.oe.git op_usermanager: Changed the behaviour to make it more comfortable --- diff --git a/recipes/pandora-system/pandora-scripts/op_usermanager.sh b/recipes/pandora-system/pandora-scripts/op_usermanager.sh index 9743a34..56ab953 100755 --- a/recipes/pandora-system/pandora-scripts/op_usermanager.sh +++ b/recipes/pandora-system/pandora-scripts/op_usermanager.sh @@ -1,64 +1,63 @@ #!/bin/bash -if zenity --question --title="Usermanager" --text="Do you wish to add or remove a user?" --ok-label="Add user" --cancel-label="Remove User"; then - +while selection=$(zenity --title="Usermanager" --list --column "id" --column "Please select" --hide-column=1 --text="What do you want to do?" "add" "Add a user" "remove" "Remove a user" ); do + if [ ${selection} = "add" ]; then echo "Add user" - while ! name=$(zenity --title="Enter full name" --entry --text "Please enter a full name for the new user.") || [ "x$name" = "x" ] ; do - zenity --title="Error" --error --text="Please try again." --timeout 6 - done - - username_guess=$(echo "$name" | cut -d" " -f1 | tr A-Z a-z) + if name=$(zenity --title="Enter full name" --entry --text "Please enter a full name for the new user.") ; then + username_guess=$(echo "$name" | cut -d" " -f1 | tr A-Z a-z) - while ! username=$(zenity --title="Enter the new username" --entry --text "Please choose a short username.\n\nIt should be all lowercase and contain only letters and numbers." --entry-text "$username_guess") || [ "x$username" = "x" ] ; do - zenity --title="Error" --error --text="Please try again." --timeout 6 - done + if username=$(zenity --title="Enter the new username" --entry --text "Please choose a short username.\n\nIt should be all lowercase and contain only letters and numbers." --entry-text "$username_guess") || [ "x$username" = "x" ] ; then - while ! useradd -c "$name,,," -G adm,audio,video,wheel,netdev,plugdev,users "$username" ; do - username=$(zenity --title="Please check username" --entry --text "Please ensure that your username consists of only\nletters and numbers and is not already in use on the system." --entry-text "$username") - done + while ! useradd -c "$name,,," -G adm,audio,video,wheel,netdev,plugdev,users "$username" ; do + username=$(zenity --title="Please check username" --entry --text "Please ensure that your username consists of only\nletters and numbers and is not already in use on the system." --entry-text "$username") + done - password="" - while [ x$password = x ] ; do - password1=$(zenity --title=Password --entry --text="Please choose a new password." --hide-text) - password2=$(zenity --title=Confirm --entry --text="Confirm your new password." --hide-text) - if [ $password1 != $password2 ] ; then + password="" + while [ x$password = x ] ; do + password1=$(zenity --title=Password --entry --text="Please choose a new password." --hide-text) + password2=$(zenity --title=Confirm --entry --text="Confirm your new password." --hide-text) + if [ $password1 != $password2 ] ; then zenity --title="Error" --error --text="The passwords do not match.\n\nPlease try again." --timeout 6 - else + else if [ x$password1 = x ] ; then zenity --title="Error" --error --text="Password cannot be blank!\n\nPlease try again." --timeout 6 else password=$password1 fi - fi - done + fi + done - passwd "$username" <