-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.sh
executable file
·64 lines (47 loc) · 1.33 KB
/
make.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
#!/bin/sh
set -e
argv0="$(basename "$0")"
[ -z "$DJINN_CONF_DIR" ] && DJINN_CONF_DIR="/etc/djinn"
[ -z "$DJINN_USER" ] && DJINN_USER="djinn"
[ -z "$DJINN_GROUP" ] && DJINN_GROUP="djinn"
[ ! -d bin ] && mkdir bin
build() {
ldflags="-X 'djinn-ci.com/x/tools/internal.ConfigDir=$DJINN_CONF_DIR'"
for d in $(ls cmd); do
set -x
go build -ldflags "$ldflags" -tags "netgo osusergo" -o bin/"$d" ./cmd/"$d"
set +x
done
}
install_bootstrap() {
timers=$(ls bootstrap/systemd/*.timer | sed 's|bootstrap/systemd/||')
install -m 0644 bootstrap/systemd/* /usr/lib/systemd/system
install -m 0644 -o "$DJINN_USER" -g "$DJINN_GROUP" bootstrap/driver.conf "$DJINN_CONF_DIR"/bootstrap.conf
systemctl enable $timers
systemctl start $timers
}
install() {
[ $(whoami) != "root" ] && {
>&2 printf "%s: install must be run as root\n" "$argv0"
exit 1
}
[ ! -d "$DJINN_CONF_DIR" ] && {
>&2 printf "%s: no such directory %s\n" "$argv0" "$DJINN_CONF_DIR"
exit 1
}
[ ! -d bin || $(ls bin | wc -l ) -eq 0 ] && {
>&2 printf "%s: no binaries to install, make sure you run './make.sh'\n" "$argv0"
exit 1
}
if systemctl status djinn-worker &> /dev/null; then
install_bootstrap
fi
install -m 0755 djinn-ps /usr/local/bin
for b in $(ls bin); do
install -m 0755 bin/"$b" /usr/local/bin
done
}
if [ "$1" = "install" ]; then
install
fi
build