From 97b333d4f8f7b7b8b230462d0f6994938ea53ba3 Mon Sep 17 00:00:00 2001 From: Michael Mrozek Date: Mon, 12 Apr 2010 05:03:45 +0200 Subject: [PATCH] op_usermanager: A new script, a very basic usermanager to add and remove users --- .../pandora-scripts/op_usermanager.desktop | 9 +++ .../pandora-scripts/op_usermanager.sh | 64 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 recipes/pandora-system/pandora-scripts/op_usermanager.desktop create mode 100755 recipes/pandora-system/pandora-scripts/op_usermanager.sh 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" <