-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-teknika.sh
executable file
·48 lines (41 loc) · 1.18 KB
/
install-teknika.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
#!/bin/bash
cd "${0%/*}" || exit 1
if [[ "$EUID" != 0 ]]; then
printf "Please give me root privileges by running me with sudo or doas.\n"
exit 1
fi
TEKNIKABIN=/usr/local/bin/teknika
arch="$(uname -m)"
case "$arch" in
x86_64|aarch64)
archbin="teknika/teknika-$arch"
;;
armv7l)
archbin="teknika/teknika-armhf"
;;
*)
printf "your system arch %s is unknown\n" "$arch"
exit 1
;;
esac
cp -vf --preserve=mode,timestamps "$archbin" "$TEKNIKABIN"
mkdir -p /etc/teknika
# We avoid overwriting any user changes to the ports
if ! grep -sq "^PORT=" /etc/teknika/instance1; then
touch /etc/teknika/instance1
printf >/etc/teknika/instance1 "PORT=51112\n"
fi
if ! grep -sq "^PORT=" /etc/teknika/instance2; then
touch /etc/teknika/instance2
printf >/etc/teknika/instance2 "PORT=51113\n"
fi
sed >/etc/systemd/system/[email protected] \
-e "s,@TEKNIKABIN@,$TEKNIKABIN,g" \
teknika/[email protected]
systemctl daemon-reload
systemctl stop teknika@instance1 || true
systemctl stop teknika@instance2 || true
systemctl enable teknika@instance1
systemctl enable teknika@instance2
systemctl start teknika@instance1 || true
systemctl start teknika@instance2 || true