pptp cron jobs adding

pull/1/head
bedefaced 9 years ago
parent 9eec1fe052
commit f0c9312a89
  1. 26
      pptp/autostart.sh
  2. 7
      pptp/checkserver.sh
  3. 1
      pptp/env.sh
  4. 8
      pptp/install.sh
  5. 20
      pptp/iptables-setup.sh

@ -0,0 +1,26 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $DIR/env.sh
if [[ "$EUID" -ne 0 ]]; then
echo "Sorry, you need to run this as root"
exit 1
fi
TMPFILE=$(mktemp crontab.XXXXX)
crontab -l > $TMPFILE
RESTOREPATH=$(which iptables-restore)
RESTORPRESENTS=$(grep iptables-restore $TMPFILE)
if [ $? -ne 0 ]; then
echo "@reboot $RESTOREPATH <$IPTABLES >/dev/null 2>&1" >> $TMPFILE
fi
PPTPDPRESENTS=$(grep "$CHECKSERVER" $TMPFILE)
if [ $? -ne 0 ]; then
echo "*/5 * * * * $CHECKSERVER >/dev/null 2>&1" >> $TMPFILE
fi
crontab $TMPFILE > /dev/null
rm $TMPFILE

@ -0,0 +1,7 @@
#!/usr/bin/env bash
RET=$(pgrep pptpd)
if [ $? -eq 1 ]; then
/etc/init.d/pptpd restart
fi

@ -6,6 +6,7 @@ PPTPOPTIONS=/etc/ppp/options.pptp
CHAPSECRETS=/etc/ppp/chap-secrets
IPTABLES=/etc/iptables.rules
RCLOCAL=/etc/rc.local
CHECKSERVER=/etc/ppp/checkserver.sh
LOCALPREFIX="172.16"
LOCALIP="$LOCALPREFIX.0.0"

@ -10,7 +10,7 @@ fi
echo
echo "Installing PPTP server..."
apt-get install pptpd
apt-get install pptpd cron
ADDUSER="no"
ANSUSER="yes"
@ -45,9 +45,13 @@ echo
echo "Configuring DNS parameters..."
$DIR/dns.sh
echo
echo "Adding cron jobs..."
yes | cp -rf $DIR/checkserver.sh $CHECKSERVER
$DIR/autostart.sh
echo
echo "Starting pptpd..."
systemctl enable pptpd
service pptpd restart
echo

@ -75,25 +75,5 @@ iptables -A INPUT -p 47 -j ACCEPT
iptables -A OUTPUT -p 47 -j ACCEPT
iptables-save | awk '($0 !~ /^-A/)||!($0 in a) {a[$0];print}' > $IPTABLES
IPTABLESRESTOR=$(which iptables-restore)
RESTORPRESENTS=$(grep iptables-restore $RCLOCAL)
if [ $? -ne 0 ]; then
if [[ ! -z $IPTABLESRESTOR ]]; then
sed -i -e "/exit 0/d" $RCLOCAL
echo "$IPTABLESRESTOR < $IPTABLES" >> $RCLOCAL
echo "exit 0" >> $RCLOCAL
else
echo "Cannot save iptables-restore from $IPTABLES to $RCLOCAL."
fi
fi
RESTORPRESENTS=$(grep iptables-restore $RCLOCAL)
if [ $? -ne 0 ]; then
sed -i -e "/exit 0/d" $RCLOCAL
echo "iptables-restore < $IPTABLES" >> $RCLOCAL
echo "exit 0" >> $RCLOCAL
fi
iptables -F
iptables-restore < $IPTABLES

Loading…
Cancel
Save