-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathipsec_start
executable file
·50 lines (40 loc) · 947 Bytes
/
ipsec_start
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# Traps are to handle if we are waiting on pipework
trap int INT
int() {
echo "Caught INT, exiting"
exit 255
}
trap term TERM
term(){
echo "Gracefully shutting down"
exit 0
}
pid=/var/run/starter.charon.pid
if [ -f $pid ]; then
rm $pid
fi
: ${IPSEC_DEFAULT_PSK_LENGTH=32}
if [ ! -f /etc/ipsec.secrets ]; then
ln -s /etc/ipsec.d/ipsec.secrets /etc/ipsec.secrets
fi
if [ -d /etc/ipsec.d/strongswan.d ]; then
if [ -L /etc/strongswan.d ]; then
rm /etc/strongswan.d
fi
ln -s /etc/ipsec.d/strongswan.d /etc/strongswan.d
fi
WAIT_INT=$1
if [ ! -z $WAIT_INT ]; then
echo "Waiting for pipework"
pipework --wait $WAIT_INT
fi
sysctl -w net.ipv4.conf.all.rp_filter=2
iptables --table nat --append POSTROUTING --jump MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
for each in /proc/sys/net/ipv4/conf/*
do
echo 0 > $each/accept_redirects
echo 0 > $each/send_redirects
done
exec /usr/libexec/ipsec/starter --nofork