ipsec cron jobs adding

pull/1/head
bedefaced 9 years ago
parent f0c9312a89
commit a424e43d6f
  1. 26
      ipsec/autostart.sh
  2. 13
      ipsec/checkserver.sh
  3. 1
      ipsec/env.sh
  4. 7
      ipsec/install.sh
  5. 8
      ipsec/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
SERVERSPRESENTS=$(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,13 @@
#!/usr/bin/env bash
RET=$(pgrep xl2tpd)
if [ $? -eq 1 ]; then
/etc/init.d/xl2tpd restart
fi
RET=$(pgrep strongswan)
if [ $? -eq 1 ]; then
/etc/init.d/strongswan restart
fi

@ -8,6 +8,7 @@ CHAPSECRETS=/etc/ppp/chap-secrets
IPTABLES=/etc/iptables.rules
RCLOCAL=/etc/rc.local
SECRETSFILE=/etc/ipsec.secrets
CHECKSERVER=/etc/xl2tpd/checkserver.sh
LOCALPREFIX="172.18"
LOCALIP="$LOCALPREFIX.0.0"

@ -52,10 +52,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 strongSwan and xl2tp..."
systemctl enable xl2tpd
systemctl enable strongswan
service xl2tpd restart
service strongswan restart

@ -73,13 +73,5 @@ iptables -A OUTPUT -o ppp+ -j ACCEPT
iptables -A INPUT -p tcp --dport 1701 -j ACCEPT
iptables-save | awk '($0 !~ /^-A/)||!($0 in a) {a[$0];print}' > $IPTABLES
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