ipsec cron jobs adding
This commit is contained in:
parent
f0c9312a89
commit
a424e43d6f
26
ipsec/autostart.sh
Normal file
26
ipsec/autostart.sh
Normal file
@ -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
|
||||||
13
ipsec/checkserver.sh
Normal file
13
ipsec/checkserver.sh
Normal file
@ -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
|
IPTABLES=/etc/iptables.rules
|
||||||
RCLOCAL=/etc/rc.local
|
RCLOCAL=/etc/rc.local
|
||||||
SECRETSFILE=/etc/ipsec.secrets
|
SECRETSFILE=/etc/ipsec.secrets
|
||||||
|
CHECKSERVER=/etc/xl2tpd/checkserver.sh
|
||||||
|
|
||||||
LOCALPREFIX="172.18"
|
LOCALPREFIX="172.18"
|
||||||
LOCALIP="$LOCALPREFIX.0.0"
|
LOCALIP="$LOCALPREFIX.0.0"
|
||||||
|
|||||||
@ -52,10 +52,13 @@ echo
|
|||||||
echo "Configuring DNS parameters..."
|
echo "Configuring DNS parameters..."
|
||||||
$DIR/dns.sh
|
$DIR/dns.sh
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Adding cron jobs..."
|
||||||
|
yes | cp -rf $DIR/checkserver.sh $CHECKSERVER
|
||||||
|
$DIR/autostart.sh
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Starting strongSwan and xl2tp..."
|
echo "Starting strongSwan and xl2tp..."
|
||||||
systemctl enable xl2tpd
|
|
||||||
systemctl enable strongswan
|
|
||||||
service xl2tpd restart
|
service xl2tpd restart
|
||||||
service strongswan 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 -A INPUT -p tcp --dport 1701 -j ACCEPT
|
||||||
|
|
||||||
iptables-save | awk '($0 !~ /^-A/)||!($0 in a) {a[$0];print}' > $IPTABLES
|
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 -F
|
||||||
iptables-restore < $IPTABLES
|
iptables-restore < $IPTABLES
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user