Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- user_modify()
- {
- while :
- do
- # Visar menyn för att redigera en användare.
- dialog --clear --backtitle "User and Group Manager" --title "Modify user properties" \
- --menu "What do you want to do?" 0 0 0 \
- "Change username" "-" \
- "Change user-ID" "-" \
- "Change password" "-" \
- "Change group-ID" "-" \
- "Add a comment" "-" \
- "Edit home directory" "-" \
- "Set default shell" "-" 2> /tmp/CHOICE.$$
- # "OK" (0) för att fortsätta.
- if [ $? -eq "0" ]
- then
- CHOICE=$(</tmp/CHOICE.$$)
- if [ "$CHOICE" = "Change username" ]
- then
- dialog --clear --backtitle "User and Group Manager" --title "Change username" \
- --inputbox "Please enter a username:" 0 0 2> /tmp/USER.$$
- # "OK" (0) för att fortsätta.
- if [ $? -eq "0" ]
- then
- USER=$(</tmp/USER.$$)
- # Kontrollerar om användaren finns.
- if grep $USER /etc/passwd > /dev/null
- then
- dialog --clear --backtitle "User and Group Manager" --title "Change username" \
- --inputbox "Please enter a new username:" 0 0 2> /tmp/NEWNAME.$$
- # "OK" (0) för att fortsätta.
- if [ $? -eq "0" ]
- then
- NEWNAME=$(</tmp/NEWNAME.$$)
- usermod -l $NEWNAME $USER
- dialog --clear --backtitle "User and Group Manager" --title "Done!" \
- --msgbox "Username was changed to $NEWNAME. This however does not rename the user's home directory!" 0 0
- # "Cancel" för att återgå till menyn för att redigera en användare.
- else
- user_modify
- break
- fi
- else
- # Om användaren inte finns skrivs ett felmeddelande ut och återgår till menyn för att redigera en användare.
- dialog --clear --backtitle "User and Group Manager" --title "Error!" \
- --msgbox "User $USER does not exist on the system!" 0 0
- user_modify
- break
- fi
- # "Cancel" för att återgå till menyn för att redigera en användare.
- else
- user_modify
- break
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement