forked from ffulm/server-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mesh.sh
executable file
·134 lines (110 loc) · 4.49 KB
/
mesh.sh
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
sha256check() {
local file="$1" hash="$2"
if [ "$(sha256sum $file | cut -b 1-64)" != "$hash" ]; then
echo "(E) ${red}Hash mismatch: $file${col_reset}"
exit 1
fi
}
echo "${green}***************************${col_reset}"
echo "${green}* set up meshing software *${col_reset}"
echo "${green}***************************${col_reset}"
{
echo "(I) ${green}Install batman-adv, batctl and alfred ($batman_version).${col_reset}"
apt install --assume-yes wget build-essential linux-headers-$(uname -r) pkg-config libnl-3-dev libjson-c-dev git libcap-dev pkg-config libnl-genl-3-dev
#install batman-adv
wget -N --no-check-certificate http://downloads.open-mesh.org/batman/releases/batman-adv-$batman_version/batman-adv-$batman_version.tar.gz
sha256check "batman-adv-$batman_version.tar.gz" "70c3f6a6cf88d2b25681a76768a52ed92d9fe992ba8e358368b6a8088757adc8"
tar -xzf batman-adv-$batman_version.tar.gz
cd batman-adv-$batman_version/
make CONFIG_BATMAN_ADV_DEBUGFS=y
make CONFIG_BATMAN_ADV_DEBUGFS=y install
cd ..
rm -rf batman-adv-$batman_version*
#install batctl
wget -N --no-check-certificate http://downloads.open-mesh.org/batman/releases/batman-adv-$batman_version/batctl-$batman_version.tar.gz
sha256check "batctl-$batman_version.tar.gz" "fb656208ff7d4cd8b1b422f60c9e6d8747302a347cbf6c199d7afa9b80f80ea3"
tar -xzf batctl-$batman_version.tar.gz
cd batctl-$batman_version/
make
make install
cd ..
rm -rf batctl-$batman_version*
#install alfred
wget -N --no-check-certificate http://downloads.open-mesh.org/batman/stable/sources/alfred/alfred-$batman_version.tar.gz
sha256check "alfred-$batman_version.tar.gz" "b656f0e9a97a99c7531b6d49ebfd663451c16cdd275bbf7d48ff8daed3880bf2"
tar -xzf alfred-$batman_version.tar.gz
cd alfred-$batman_version/
make CONFIG_ALFRED_GPSD=n CONFIG_ALFRED_VIS=n
make CONFIG_ALFRED_GPSD=n CONFIG_ALFRED_VIS=n install
cd ..
rm -rf alfred-$batman_version*
}
{
# set capablilities for alfred binary (create sockets and use elevated privs)
# got reset by installation of new alfred binary above
setcap cap_net_admin,cap_net_raw+ep `which alfred`
# create alfred group
addgroup --system alfred
echo "(I) ${green}Create user alfred for alfred daemon.${col_reset}"
adduser --system --home /var/run/alfred --shell /bin/false --ingroup alfred --disabled-password alfred
}
{
echo "(I) ${green}Install fastd prerequisites${col_reset}"
apt install --assume-yes git cmake-curses-gui libnacl-dev flex bison libcap-dev pkg-config zip libjson-c-dev
echo "(I) ${green}Build and install libsodium${col_reset}"
#install libsodium
wget -N --no-check-certificate -O libsodium-1.0.18.tar.gz https://github.com/jedisct1/libsodium/archive/1.0.18.tar.gz
sha256check "libsodium-1.0.18.tar.gz" "d59323c6b712a1519a5daf710b68f5e7fde57040845ffec53850911f10a5d4f4"
tar -xvzf libsodium-1.0.18.tar.gz
cd libsodium-1.0.18
./configure
make
make install
cd ..
rm -rf libsodium-1.0.18*
ldconfig
echo "(I) ${green}Build and install libuecc${col_reset}"
#install libuecc
wget -N --no-check-certificate https://projects.universe-factory.net/attachments/download/85 -O libuecc-7.tar.xz
sha256check "libuecc-7.tar.xz" "b94aef08eab5359d0facaa7ead2ce81b193eef0c61379d9835213ebc0a46257a"
tar xf libuecc-7.tar.xz
mkdir libuecc_build
cd libuecc_build
cmake ../libuecc-7
make
make install
cd ..
rm -rf libuecc_build libuecc-7*
ldconfig
echo "(I) ${green}Build and install fastd${col_reset}"
#install fastd
wget -N --no-check-certificate https://projects.universe-factory.net/attachments/download/86 -O fastd-18.tar.xz
sha256check "fastd-18.tar.xz" "714ff09d7bd75f79783f744f6f8c5af2fe456c8cf876feaa704c205a73e043c9"
tar xf fastd-18.tar.xz
mkdir fastd_build
cd fastd_build
# -D is workaround needed till fastd-19
cmake ../fastd-18 -DWITH_CIPHER_AES128_CTR_NACL=OFF
make
make install
cd ..
rm -rf fastd_build fastd-18*
}
{
echo "(I) ${green}Configure fastd${col_reset}"
cp -r etc/fastd /etc/
if [ -z "$fastd_secret" ]; then
echo "(I) ${green}Create fastd public/private key pair. This may take a while...${col_reset}"
fastd_secret=$(fastd --generate-key --machine-readable)
fi
echo "secret \"$fastd_secret\";" >> /etc/fastd/fastd.conf
fastd_key=$(echo "secret \"$fastd_secret\";" | fastd --config - --show-key --machine-readable)
echo "#key \"$fastd_key\";" >> /etc/fastd/fastd.conf
sed -i "s/eth0/$wan_iface/g" /etc/fastd/fastd.conf
}
if ! id nobody >/dev/null 2>&1; then
echo "(I) ${green}Create user nobody for fastd.${col_reset}"
useradd --system --no-create-home --shell /bin/false nobody
fi
exit 0