Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- list=()
- function torles() {
- read -p "Enter the User name: " username
- sed -i "/$username/d" ./users.txt
- echo $username torolve!
- }
- function givegid(){
- # előző gid-et adja vissza
- elozogid=$( tail -n 1 users.txt | cut -d':' -f 4 )
- #új gid
- gid=$(($elozogid+1))
- }
- function giveuid(){
- # előző uid-et adja vissza
- elozouid=$( tail -n 1 users.txt | cut -d':' -f 3 )
- #új uid
- uid=$(($elozouid+1))
- }
- function readusers(){
- while IFS= read -r line; do
- list+=("$line");
- done < users.txt
- }
- function listusers(){
- for i in "${list[@]}"
- do
- echo "${i}"
- done
- }
- while true
- do
- valasz='Mit szeretnel?'
- options=("Listazas" "Hozzaadas" "Torles" "Zarolas" "Engedelyezes" "Jelszovaltas" "Shellvaltas" "Quit")
- select opt in "${options[@]}"
- do
- case $opt in
- "Listazas")
- readusers
- listusers
- break;;
- "Torles")
- torles
- break;;
- "Zarolas")
- break;;
- "Engedelyezes")
- break;;
- "Jelszovaltas")
- break;;
- "Shellvaltas")
- break;;
- "Hozzaadas")
- ###########
- read -p "Enter a User name: " username
- read -p "Enter a Full name: " fullname
- read -p "Enter a Home directory: " homedir
- read -p "Enter a Bash name: " bashname
- read -p "Enter a Password: " password
- password="$(echo "$password" | md5sum | cut -d' ' -f1 )"
- giveuid
- givegid
- echo "$username:$password:$uid:$gid:$fullname:$homedir:$bashname" >> ./users.txt
- ###########
- break;;
- "Quit")
- exit;;
- *) echo "helytelen valasz";;
- esac
- done
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement