Various scripts: Added license info
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts / op_usermanager.sh
index 56ab953..7637cb1 100755 (executable)
@@ -1,4 +1,9 @@
 #!/bin/bash
+# Released under the GPL
+# User-Manager, v1.0, written by Michael Mrozek aka EvilDragon 2010.
+# Partly based on the scripts by JohnX/Mer Project - http://wiki.maemo.org/Mer/
+# Reworked for the OpenPandora - John Willis/Michael Mrozek
+# This scripts allows you to create and remove users from the Pandora system.
 
 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
@@ -27,9 +32,9 @@ while selection=$(zenity --title="Usermanager" --list --column "id" --column "Pl
              fi
            done
 
-           passwd "$username" <<EOF
-           $password
-           $password
+passwd "$username" <<EOF
+$password
+$password
 EOF
            if zenity --question --title="User created" --text="The user $username has been successfully created.\n\nDo you want to set this user as default user for the login?" --ok-label="Yes, please!" --cancel-label="No, keep the old user as default"; then
              sed -i "s/.*default_user.*/default_user $username/g" /etc/slim.conf
@@ -38,13 +43,13 @@ EOF
          fi
        fi
   elif [ ${selection} = "remove" ]; then
-        xfceuser=$(ps u -C xfce4-session | tail -n1 | awk '{print $1}')
+        user2=$(cat /tmp/currentuser)
         echo "Remove User"
        amount=$(cat /etc/passwd | grep /home/ | grep -v root | awk -F\: '{print $1 }' | wc -l)
        if [ ${amount} = "1" ]; then
              zenity --title="Error" --error --text="Sorry! You can't remove the last normal user!" --timeout 6
        else
-             if selection=$(cat /etc/passwd | grep /home/ | grep -v root | grep -v $xfceuser | awk -F\: '{print $1 }' | zenity --width=100 --height=200 --title="Select the user to delete" --list  --column "Username"  --text "Select the user to delete\n\nPlease note: You can't remove the user that is currently logged in.") ; then
+             if selection=$(cat /etc/passwd | grep /home/ | grep -v root | grep -v $user2 | awk -F\: '{print $1 }' | zenity --width=100 --height=200 --title="Select the user to delete" --list  --column "Username"  --text "Select the user to delete\n\nPlease note: You can't remove the user that is currently logged in.") ; then
                if zenity --question --title="Confirm User Removal" --text="Are you REALLY sure you want to remove the user $selection?\n\nThere will be NO other confirmation and this can NOT be undone!" --ok-label="Yes, remove user!" --cancel-label="Don't remove the user"; then
                  echo "Really remove $selection"
                  userdel -fr $selection