Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- echo "\nCreate user by pabblo"
- #menu
- echo "Select mode\n1. From file\n2.Manual\n3.From file with random password\n4.Manual with random password"
- read n
- case $n in
- 1) clear
- echo "Create from file"
- echo "File name:"
- read fileName
- while read line
- do
- userName=""
- userPassword=""
- i=0
- for word in $line
- do
- if [ $i -eq 0 ]; then
- userName=$word
- else
- userPassword=$word
- fi
- i=1
- done
- useradd -m -p $userPassword $userName
- #echo "create user $line[0]\n"
- done < $fileName
- echo "Done"
- ;;
- 2) clear
- echo "Create a User Manual"
- echo "User name:"
- read userName
- echo "User passwd:"
- read userPasswd
- useradd -m -p $userPasswd $userName
- ;;
- 3) clear
- echo "Auto with random passwd"
- echo "File name:"
- read fileName
- forFile=""
- while read line
- do
- userName=""
- userPassword=""
- i=0
- for word in $line
- do
- if [ $i -eq 0 ]; then
- userName=$word
- fi
- i=1
- done
- forFile=$forFile$userName" "
- userPassword=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 5 | head -n 1)
- forFile=$forFile" "$userPassword"\n"
- useradd -m -p $userPassword $userName
- #echo "create user $line[0]\n"
- done < $fileName
- echo $forFile > pass.txt
- echo "Done"
- ;;
- 4) clear
- echo "Manual with random passwd"
- echo "User name:"
- read userName
- userPassword=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 5 | head -n 1)
- useradd -m -p $userPassword $userName
- echo $userName" "$userPassword > pass.txt
- ;;
- *) echo "INVALID NUMBER!" ;;
- esac
- # create users from file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement