Advertisement
foriamrootgmail

disableuser.sh

Jan 22nd, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. #!/bin/bash
  2. # There are more reliable ways to check this, however, this should work for now.
  3. if [ `whoami` != "root" ]; then
  4. echo "$0 error: this script must be run as root." && exit 1
  5. fi
  6. # Check to see if the user is asking for help with -h or --help.
  7. case $1 in
  8. -h) echo "usage: $0 username email@address" && exit 0;;
  9. --help) echo "usage: $0 username email@address" && exit 0;;
  10. esac
  11. # Check to make sure the second argument contains @
  12. echo $2 | grep "@" > /dev/null
  13. if [ $? -ne 0 ]; then
  14. echo "$0 error: second argument must be an e-mail address." && echo "usage: $0 username email@address" && exit 1
  15. fi
  16. # Check to make sure that ONLY 2 arguments were supplied.
  17. case $# in
  18. 1) echo "the account of user $1 will be disabled.";;
  19. 2) echo "the account of user $1 with e-mail address $2 will be disabled.";;
  20. *) echo "$0 error: too few or too many arguments" && echo "usage: $0 username email@address" && exit 1;;
  21. esac
  22. echo "are you sure you want to disable the account of $1?"
  23. echo ""
  24. echo "To continue press Enter"
  25. echo "To cancel press CTRL+C"
  26. read answer
  27. kill $(pgrep -U `id -u $1` rtorrent) && passwd -l $1
  28. cat << EOF >> /home/cnz/userdetails/$1.disabled
  29. Your seedbox service account has been temporarily DISABLED due to non payment!
  30.  
  31. Our system shows your account has a past due balance.
  32.  
  33. Nothing has been deleted yet, however, your seedbox will be disabled until the past due balance has been paid.
  34.  
  35. Please note that during this time period you will be unable to utilize our services. This is included to, but not limited to, SSH, FTP, and torrent traffic.
  36.  
  37. Should you choose not to renew your subscription your account (and files) will be deleted in 7 days.
  38.  
  39. If you have paid the past due balance already your account will be restored shortly. We apologize for any inconvenience.
  40.  
  41. This is an automatically generated message.
  42.  
  43. Thanks!
  44. EOF
  45. su cnz -c "mutt -s 'Your seedbox service account has been DISABLED.' $2 < /home/cnz/userdetails/$1.disabled"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement