Advertisement
Guest User

Untitled

a guest
Aug 14th, 2011
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. #!/bin/bash
  2. if [ $(id -u) -eq 0 ]; then
  3. read -p "Friend username:" friend
  4. read -p "Friend email address:" friendemail
  5. read -p "Create VPN account for user : (yes/no)" yesno
  6. RPASS=$(makepasswd --char=6)
  7. egrep "^$friend" /etc/passwd >/dev/null
  8. if [ $? -eq 0 ]; then
  9. echo "$friend exists!"
  10. exit 1
  11. fi
  12. echo 'Adding user '$friend
  13. useradd -d /home/$friend -m -g friends -p -N $friend
  14. echo
  15. echo 'Setting random 6 letter password :'$RPASS
  16. echo $friend:$RPASS | chpasswd
  17. echo
  18. echo 'Applying 0750 to users home dir'
  19. chmod 0750 /home/$friend
  20.  
  21. echo 'servername : bomber.dyndns.org' > message.txt
  22. echo 'port : 666' >> message.txt
  23. echo 'username : '$friend >> message.txt
  24. echo 'password : '$RPASS >> message.txt
  25.  
  26. if [ $yesno = "yes" ]; then
  27. echo 'Adding user to VPN group'
  28. echo '$friend pptpd $RPASS *' >> /etc/ppp/chap-secrets
  29. fi
  30.  
  31. echo -e '\n\n' >> message.txt
  32. echo -e '\n\n Remember that ALL access is monitored and logged.\n Place nicely :)' >> message.txt
  33. echo -e '\n\nBomber' >> message.txt
  34. echo 'Sending friend Account Creation Email to '$friendemail''
  35.  
  36. sudo /usr/bin/mail -s 'bomber.dyndns.org | Account Created : '$friend $friendemail < message.txt
  37. rm message.txt
  38. echo
  39. echo
  40. echo 'Output of passwd & group files'
  41. cat /etc/passwd | grep $friend
  42. cat /etc/shadow | grep $friend
  43. cat /etc/group | grep friends
  44. echo 'Done with account creation...'
  45. else
  46. echo "Only root may add a user to the system"
  47. exit 2
  48. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement