-
Notifications
You must be signed in to change notification settings - Fork 0
/
set-up-luci.sh
executable file
·99 lines (81 loc) · 2.48 KB
/
set-up-luci.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
#!/bin/sh
GO_VERSION=go123
createuser() {
if userinfo -e $1; then
echo "==> User $1 already exists." >&2
else
echo "==> Creating user $1." >&2
useradd -m -p '*' $1
fi
}
make_dir() {
dir=$1
shift
if [ -e $dir ]; then
echo "==> Directory $dir already exists." >&2
else
echo "==> Creating directory $dir." >&2
install -d $* $dir
fi
}
copy_file() {
src=$1
dest=$2
srcfile=`basename $1`
if [ -e $dest/$srcfile ]; then
echo "==> file $dest/$srcfile already exists." >&2
elif [ ! -e $src ]; then
echo "==> missing file $src!" >&2
else
echo "==> copying $src to $dest." >&2
cp $src $dest
fi
}
install_go_bin() {
echo "==> Installing $1." >&2
env GOBIN=/usr/local/bin go install -v $1@latest
}
###############################
echo "==> Installing useful packages." >&2
if [ -x /usr/pkg/bin/pkgin ]; then
pkgin -y install emacs-nox11 watch estd screen sysupgrade bash go123 w3m vim llvm git-base htop sudo mosh pkg_alternatives clang daemontools daemontools-run node_exporter doas
else
echo "pkgin not found, please install packages manually" >&2
fi
make_dir /usr/local/bin
make_dir /usr/local/sbin
createuser swarming
createuser lucitoken
install_go_bin golang.org/x/build/cmd/genbotcert
install_go_bin golang.org/x/build/cmd/bootstrapswarm
install_go_bin go.chromium.org/luci/tokenserver/cmd/luci_machine_tokend
make_dir /var/lib/luci_machine_tokend -o lucitoken
if [ -e /service ]; then
echo "==> Directory /service already exists." >&2
else
echo "==> Installing directory /service." >&2
pax -rw -pp service /
fi
copy_file /usr/pkg/share/examples/rc.d/svscan /etc/rc.d
copy_file /usr/pkg/share/examples/rc.d/node_exporter /etc/rc.d
chmod 555 /etc/rc.d/svscan
chmod 555 /etc/rc.d/node_exporter
copy_file rcd/newfs_scratch /etc/rc.d
chmod 555 /etc/rc.d/newfs_scratch
if grep -q "Go builder settings" /etc/rc.conf; then
echo "==> /etc/rc.conf already contains Go builder settings." >&2
else
echo "==> Installing Go builder settings to /etc/rc.conf, please verify!" >&2
cat rcd/rc.conf >> /etc/rc.conf
fi
if grep -q "Go builder settings" /usr/pkg/etc/sudoers; then
echo "==> /usr/pkg/etc/sudoers already contains Go builder settings." >&2
else
echo "==> Installing Go builder settings to /usr/pkg/etc/sudoers, please verify!" >&2
cat rcd/sudoers >> /usr/pkg/etc/sudoers
fi
. ./rcd/rc.conf
copy_file ${builder_name}.cert /home/lucitoken
copy_file ${builder_name}.key /home/lucitoken
chown lucitoken /home/lucitoken/${builder_name}.cert
chown lucitoken /home/lucitoken/${builder_name}.key