From: Michael Mrozek Date: Mon, 12 Apr 2010 03:03:45 +0000 (+0200) Subject: op_usermanager: A new script, a very basic usermanager to add and remove users X-Git-Tag: Release-2010-05/1~60^2~4 X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=openpandora.oe.git;a=commitdiff_plain;h=97b333d4f8f7b7b8b230462d0f6994938ea53ba3 op_usermanager: A new script, a very basic usermanager to add and remove users --- diff --git a/recipes/pandora-system/pandora-scripts/op_usermanager.desktop b/recipes/pandora-system/pandora-scripts/op_usermanager.desktop new file mode 100644 index 0000000..78b7f66 --- /dev/null +++ b/recipes/pandora-system/pandora-scripts/op_usermanager.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=Usermanager +Comment=A very simple usermanager +StartupNotify=false +Exec=gksudo /usr/pandora/scripts/op_usermanager.sh +Icon=Terminal +Terminal=false +Type=Application +Categories=System; diff --git a/recipes/pandora-system/pandora-scripts/op_usermanager.sh b/recipes/pandora-system/pandora-scripts/op_usermanager.sh new file mode 100755 index 0000000..9743a34 --- /dev/null +++ b/recipes/pandora-system/pandora-scripts/op_usermanager.sh @@ -0,0 +1,64 @@ +#!/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 + + 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) + + 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 + + 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 + zenity --title="Error" --error --text="The passwords do not match.\n\nPlease try again." --timeout 6 + 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 + + passwd "$username" <