-
Notifications
You must be signed in to change notification settings - Fork 787
Expand file tree
/
Copy pathinit.sh
More file actions
executable file
·45 lines (36 loc) · 750 Bytes
/
init.sh
File metadata and controls
executable file
·45 lines (36 loc) · 750 Bytes
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
#!/bin/sh -e
#
# initialize server profile
#
if [ -f /etc/tinc/${NETNAME}/rsa_key.priv ]
then
echo 'Initialized!'
exit 0
else
echo 'Initializing...'
fi
mkdir -p /etc/tinc/${NETNAME}/hosts
cd /etc/tinc/${NETNAME}
cat > tinc.conf <<_EOF_
Name = server
Interface = tun0
_EOF_
cat > tinc-up <<_EOF_
#!/bin/sh
ip link set \$INTERFACE up
ip addr add ${ADDRESS} dev \$INTERFACE
ip route add ${NETWORK} dev \$INTERFACE
_EOF_
cat > tinc-down <<_EOF_
#!/bin/sh
ip route del ${NETWORK} dev \$INTERFACE
ip addr del ${ADDRESS} dev \$INTERFACE
ip link set \$INTERFACE down
_EOF_
cat > hosts/server <<_EOF_
Address = ${IP_ADDR}
Subnet = ${ADDRESS}
Subnet = 0.0.0.0/0
_EOF_
chmod +x tinc-up tinc-down
tincd -n${NETNAME} -K${KEYSIZE} < /dev/null