kyroskoh

PoPToP install script for an OpenVZ VPS

Nov 2nd, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. #!/bin/bash
  2. # Interactive PoPToP install script for an OpenVZ VPS
  3. # Tested on Debian 5, 6, and Ubuntu 11.04
  4. # April 2, 2013 v1.11
  5. # http://www.putdispenserhere.com/pptp-debian-ubuntu-openvz-setup-script/
  6.  
  7. echo "######################################################"
  8. echo "Interactive PoPToP Install Script for an OpenVZ VPS"
  9. echo
  10. echo "Make sure to contact your provider and have them enable"
  11. echo "IPtables and ppp modules prior to setting up PoPToP."
  12. echo "PPP can also be enabled from SolusVM."
  13. echo
  14. echo "You need to set up the server before creating more users."
  15. echo "A separate user is required per connection or machine."
  16. echo "######################################################"
  17. echo
  18. echo
  19. echo "######################################################"
  20. echo "Select on option:"
  21. echo "1) Set up new PoPToP server AND create one user"
  22. echo "2) Create additional users"
  23. echo "######################################################"
  24. read x
  25. if test $x -eq 1; then
  26. echo "Enter username that you want to create (eg. client1 or john):"
  27. read u
  28. echo "Specify password that you want the server to use:"
  29. read p
  30.  
  31. # get the VPS IP
  32. ip=`ifconfig venet0:0 | grep 'inet addr' | awk {'print $2'} | sed s/.*://`
  33.  
  34. echo
  35. echo "######################################################"
  36. echo "Downloading and Installing PoPToP"
  37. echo "######################################################"
  38. apt-get update
  39. apt-get -y install pptpd
  40.  
  41. echo
  42. echo "######################################################"
  43. echo "Creating Server Config"
  44. echo "######################################################"
  45. cat > /etc/ppp/pptpd-options <<END
  46. name pptpd
  47. refuse-pap
  48. refuse-chap
  49. refuse-mschap
  50. require-mschap-v2
  51. require-mppe-128
  52. ms-dns 8.8.8.8
  53. ms-dns 8.8.4.4
  54. proxyarp
  55. nodefaultroute
  56. lock
  57. nobsdcomp
  58. END
  59.  
  60. # setting up pptpd.conf
  61. echo "option /etc/ppp/pptpd-options" > /etc/pptpd.conf
  62. echo "logwtmp" >> /etc/pptpd.conf
  63. echo "localip $ip" >> /etc/pptpd.conf
  64. echo "remoteip 10.1.0.1-100" >> /etc/pptpd.conf
  65.  
  66. # adding new user
  67. echo "$u * $p *" >> /etc/ppp/chap-secrets
  68.  
  69. echo
  70. echo "######################################################"
  71. echo "Forwarding IPv4 and Enabling it on boot"
  72. echo "######################################################"
  73. cat >> /etc/sysctl.conf <<END
  74. net.ipv4.ip_forward=1
  75. END
  76. sysctl -p
  77.  
  78. echo
  79. echo "######################################################"
  80. echo "Updating IPtables Routing and Enabling it on boot"
  81. echo "######################################################"
  82. iptables -t nat -A POSTROUTING -j SNAT --to-source $ip
  83. # saves iptables routing rules and enables them on-boot
  84. iptables-save > /etc/iptables.conf
  85.  
  86. cat > /etc/network/if-pre-up.d/iptables <<END
  87. #!/bin/sh
  88. iptables-restore < /etc/iptables.conf
  89. END
  90.  
  91. chmod +x /etc/network/if-pre-up.d/iptables
  92. cat >> /etc/ppp/ip-up <<END
  93. ifconfig ppp0 mtu 1400
  94. END
  95.  
  96. echo
  97. echo "######################################################"
  98. echo "Restarting PoPToP"
  99. echo "######################################################"
  100. sleep 5
  101. /etc/init.d/pptpd restart
  102.  
  103. echo
  104. echo "######################################################"
  105. echo "Server setup complete!"
  106. echo "Connect to your VPS at $ip with these credentials:"
  107. echo "Username:$u ##### Password: $p"
  108. echo "######################################################"
  109.  
  110. # runs this if option 2 is selected
  111. elif test $x -eq 2; then
  112. echo "Enter username that you want to create (eg. client1 or john):"
  113. read u
  114. echo "Specify password that you want the server to use:"
  115. read p
  116.  
  117. # get the VPS IP
  118. ip=`ifconfig venet0:0 | grep 'inet addr' | awk {'print $2'} | sed s/.*://`
  119.  
  120. # adding new user
  121. echo "$u * $p *" >> /etc/ppp/chap-secrets
  122.  
  123. echo
  124. echo "######################################################"
  125. echo "Addtional user added!"
  126. echo "Connect to your VPS at $ip with these credentials:"
  127. echo "Username:$u ##### Password: $p"
  128. echo "######################################################"
  129.  
  130. else
  131. echo "Invalid selection, quitting."
  132. exit
  133. fi
Add Comment
Please, Sign In to add comment