1
0

vpnuser 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #! /bin/sh
  2. #
  3. # vpnuser Add/Del user to chap-secrets for VPN
  4. # Version 1.0 beta by Richard de Vroede - Linvision BV
  5. # Ideas or worshipping to: richard@linvision.com
  6. #
  7. config="/etc/ppp/chap-secrets"
  8. ERROR="Usage:\n$0 add <username> <passwd> or\n$0 del <username> or\n$0 show [<username>] or\n$0 domain <username> <domain>"
  9. # See how we were called.
  10. case "$1" in
  11. add)
  12. if [ "$(echo $2)" != "" ] & [ "$(echo $3)" != "" ]; then
  13. echo -e "$2\t*\t$3\t*" >> $config
  14. chmod 600 $config
  15. else
  16. echo -e $ERROR
  17. exit 1
  18. fi
  19. ;;
  20. del)
  21. if [ "$(echo $2)" != "" ]; then
  22. grep -vw "$2" $config > /tmp/vpnblaat
  23. mv /tmp/vpnblaat $config
  24. chmod 600 $config
  25. else
  26. echo -e $ERROR
  27. exit 1
  28. fi
  29. ;;
  30. show)
  31. echo -e "User\tServer\tPasswd\tIPnumber"
  32. echo "---------------------------------"
  33. if [ "$(echo $2)" != "" ]; then
  34. grep -w $2 $config
  35. else
  36. cat $config
  37. fi
  38. ;;
  39. domain)
  40. if [ "$(echo $2)" != "" ] & [ "$(echo $3)" != "" ]; then
  41. grep -vw "$2" $config > /tmp/vpnblaat
  42. DATA=`grep -w "$2" $config`
  43. mv /tmp/vpnblaat $config
  44. DOM=`echo $3 | tr a-z A-Z`
  45. dom=`echo $3 | tr A-Z a-z`
  46. echo "$DOM\\\\$DATA" >> $config
  47. echo "$dom\\\\$DATA" >> $config
  48. chmod 600 $config
  49. else
  50. echo -e $ERROR
  51. exit 1
  52. fi
  53. ;;
  54. *)
  55. echo -e $ERROR
  56. exit 1
  57. esac