这是一个自动安装脚本,for 大便系列。比如 大便和ubuntu(版权不是我的,我也只是拿来改改) :
- #!/bin/bash
- function installVPN(){
- apt-get update
- #remove ppp pptpd
- rm -rf /etc/pptpd.conf
- rm -rf /etc/ppp
- apt-get -y remove ppp pptpd
- apt-get -y install ppp pptpd iptables
- #注意,这里的一些refuse-pap之类的要注意,如果不能连接首先改这里。
- #如果一直出错,将require-mschap-v2和require-mppe-128 这两行加密注释掉,(对应源文件)
- echo name pptpd >> /etc/ppp/pptpd-options
- echo refuse-pap >> /etc/ppp/pptpd-options
- echo refuse-chap >> /etc/ppp/pptpd-options
- #refuse-mschap
- echo require-mschap-v2 >> /etc/ppp/pptpd-options
- echo require-mppe-128 >> /etc/ppp/pptpd-options
- echo proxyarp >> /etc/ppp/pptpd-options
- echo nodefaultroute >> /etc/ppp/pptpd-options
- echo lock >> /etc/ppp/pptpd-options
- echo nobsdcomp >> /etc/ppp/pptpd-options
- echo ms-dns 8.8.8.8 >> /etc/ppp/pptpd-options
- echo ms-dns 8.8.4.4 >> /etc/ppp/pptpd-options
- echo ms-dns 4.3.2.1 >> /etc/ppp/pptpd-options
- #写到pptpd.conf文件中
- echo option /etc/ppp/pptpd-options >> /etc/pptpd.conf
- echo logwtmp >> /etc/pptpd.conf
- echo localip 192.168.99.1 >> /etc/pptpd.conf
- echo remoteip 192.168.99.9-99 >> /etc/pptpd.conf
- #这个最好只能处理一次。否则每次都会修改,以防万一,改两次吧。。第一次应该失败
- sed -i 's/#net\.ipv4.ip_forward=0/net\.ipv4.ip_forward=1/' /etc/sysctl.conf
- sed -i 's/#net\.ipv4.ip_forward=1/net\.ipv4.ip_forward=1/' /etc/sysctl.conf
- #echo net.ipv4.ip_forward = 1 >> /etc/sysctl.conf
- sysctl -p
- #以下内容是for OPENVZ
- #iptables -t nat -A POSTROUTING -s 192.168.99.0/24 -j SNAT --to-source `ifconfig | grep 'inet addr:'| grep -v '127.0.0' | cut -d: -f2 | awk 'NR==1 { print $1}'`
- #sed -i 's/exit\ 0/#exit\ 0/' /etc/rc.local
- #echo iptables -t nat -A POSTROUTING -s 192.168.99.0/24 -j SNAT --to-source `ifconfig | grep 'inet addr:'| grep -v '127.0.0' | cut -d: -f2 | awk 'NR==1 { print $1}'` >> /etc/rc.local
- #echo exit 0 >> /etc/rc.local
- # --- the sentence below was remarked By yanwen , what are you doing ??-----
- }
- function installOpenVZ(){
- (installVPN)
- iptables -t nat -A POSTROUTING -s 192.168.99.0/24 -j SNAT --to-source `ifconfig | grep 'inet addr:'| grep -v '127.0.0' | cut -d: -f2 | awk 'NR==1 { print $1}'`
- sed -i 's/exit\ 0/#exit\ 0/' /etc/rc.local
- echo iptables -t nat -A POSTROUTING -s 192.168.99.0/24 -j SNAT --to-source `ifconfig | grep 'inet addr:'| grep -v '127.0.0' | cut -d: -f2 | awk 'NR==1 { print $1}'` >> /etc/rc.local
- echo exit 0 >> /etc/rc.local
- (setDefaultUser)
- }
- function installXen(){
- (installVPN)
- iptables -t nat -A POSTROUTING -s 192.168.99.0/24 -o eth0 -j MASQUERADE
- sed -i 's/exit\ 0/#exit\ 0/' /etc/rc.local
- echo iptables -t nat -A POSTROUTING -s 192.168.99.0/24 -o eth0 -j MASQUERADE >> /etc/rc.local
- echo exit 0 >> /etc/rc.local
- (setDefaultUser)
- }
- function setDefaultUser(){
- #默认用户
- echo gouki \* 123456 \* >> /etc/ppp/chap-secrets
- /etc/init.d/pptpd restart
- }
- function repaireVPN(){
- echo "begin to repaire VPN";
- mknod /dev/ppp c 108 0
- /etc/init.d/pptpd restart
- }
- function addVPNuser(){
- echo "input user name:"
- read username
- echo "input password:"
- read userpassword
- echo "${username} pptpd ${userpassword} *" >> /etc/ppp/chap-secrets
- /etc/init.d/pptpd restart
- }
- function disableEncyption(){
- sed -i 's/^require-mschap-v2/#require-mschap-v2/' /etc/ppp/pptpd-options
- sed -i 's/^require-mppe-128/#require-mppe-128/' /etc/ppp/pptpd-options
- /etc/init.d/pptpd restart
- }
- function enableEncyption(){
- sed -i 's/^#require-mschap-v2/require-mschap-v2/' /etc/ppp/pptpd-options
- sed -i 's/^#require-mppe-128/require-mppe-128/' /etc/ppp/pptpd-options
- /etc/init.d/pptpd restart
- }
- echo "which do you want to?input the number."
- echo "1. install Xen VPN service"
- echo "2. install OpenVz VPN service"
- echo "3. repaire VPN service"
- echo "4. add VPN user"
- echo "5. disable encryption"
- echo "6. disable encryption"
- read num
- case "$num" in
- [1] ) (installXen);;
- [2] ) (installOpenVZ);;
- [3] ) (repaireVPN);;
- [4] ) (addVPNuser);;
- [5] ) (disableEncyption);;
- [6] ) (enableEncyption);;
- *) echo "nothing,exit";;
- esac
第一次写和改。连参数都不会。将就点了。。嗯。上面的内容复制起来比较麻烦,所以我做一个文件,可以直接下载:
放到自己的目录下,chmod a+x 这个文件。再执行就OK了。
你可以先看一下这个文件。。。以防万一
下载地址:untitled.sh