-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·70 lines (59 loc) · 1.31 KB
/
install.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
#!/bin/sh
PREFIX=${PREFIX:-"/usr/local"}
BIN=${BIN:-"$PREFIX/bin"}
SYSTEMD=${SYSTEMD:-"/etc/systemd/system"}
set -e
fail() {
echo "$1" 1>&2
exit 1
}
check() {
type "install_$1" >/dev/null 2>&1 || fail "\"$1\" is unknown"
}
config() {
file="$1"
dir="$2"
sed=""
while test -n "$3"; do
var="$3"
val="$4"
sed="$sed -e \"s%^$var=.*%$var=$val%\""
shift 2
done
eval sed $sed < "$file" > "$dir/$file"
}
enable() {
service="$1"
systemctl daemon-reload
systemctl enable "$service"
systemctl is-active "$service" && systemctl restart "$service" || :
}
install_gw() {
install -d "$BIN"
install -m 755 gw "$BIN"
config gateway.sh "$BIN" "GW" "$BIN/gw"
test -d "$SYSTEMD" || return
config chaosnet-gateway.service "$SYSTEMD" "WorkingDirectory" "$BIN"
enable chaosnet-gateway
}
install_mlftp() {
install -d "$BIN"
install -m 755 mlftp "$BIN"
}
install_rtape() {
install -d "$BIN"
install -m 755 rtape "$BIN"
test -d "$SYSTEMD" || return
config chaosnet-rtape.service "$SYSTEMD" "ExecStart" "$BIN/rtape -v"
enable chaosnet-rtape
}
install_shutdown() {
install -d "$BIN"
install -m 755 shutdown "$BIN"
}
while test -n "$1"; do
check "$1"
echo "Installing \"$1\""
install_"$1"
shift
done