-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·66 lines (56 loc) · 1.55 KB
/
entrypoint.sh
File metadata and controls
executable file
·66 lines (56 loc) · 1.55 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
set -e
# check required env variables
: "${FASTD_MTU:? must be set}"
# set some defaults
: "${FASTD_LOG_LEVEL:=info}"
: "${FASTD_PEER_LIMIT:=100}"
umask 600
mkdir -p /config/secret
if [ ! -f /config/secret/secret.txt ]; then
fastd --generate-key > /config/secret/secret.txt
fi
mkdir -p /config/fastd/peers
chmod 0770 /config/fastd/peers
cat << EOF > /config/fastd/fastd.conf
log level ${FASTD_LOG_LEVEL};
drop capabilities yes;
bind any:10061;
mode multitap;
interface "mesh-vpn";
method "salsa2012+umac";
method "salsa2012+gmac";
method "null+salsa2012+umac";
method "null@l2tp";
persist interface no;
offload l2tp yes;
mtu ${FASTD_MTU};
secret "$( cat /config/secret/secret.txt | grep -e Secret | awk '{ print $2 }' )";
peer limit ${FASTD_PEER_LIMIT};
on verify sync "true";
forward yes;
on up "
ip link set up dev mesh-vpn
batctl meshif add mesh-vpn
ifconfig bat0 up
$( test -z "${IPV6_PREFIX}" || echo "/config/static_v6.sh" )
";
include peers from "peers";
EOF
if [ ! -z "${IPV6_PREFIX}" ]; then
cat << EOF > "/config/static_v6.sh"
MAC=\$( cat /sys/class/net/bat0/address )
IPV6=\$( ipv6calc --action prefixmac2ipv6 --in prefix+mac --out ipv6addr ${IPV6_PREFIX} \${MAC})
ip -6 addr add \${IPV6} dev bat0
EOF
chmod 0755 /config/static_v6.sh
fi
# create tun device
mkdir -p /dev/net
if [ ! -c /dev/net/tun ]; then
mknod /dev/net/tun c 10 200
fi
# Setup sysctl
echo "0" > /proc/sys/net/ipv6/conf/all/disable_ipv6
echo "1" > /proc/sys/net/ipv6/conf/all/forwarding
exec fastd --config /config/fastd/fastd.conf --status-socket /config/fastd/fastd.status