-
Notifications
You must be signed in to change notification settings - Fork 1
/
swarm-client-nutci.openbsd.rcd
executable file
·66 lines (55 loc) · 2.18 KB
/
swarm-client-nutci.openbsd.rcd
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
#!/bin/ksh
#
# OpenBSD rc.d for jenkins swarm client
# Symlink as /etc/rc.d/swarm_client_nutci and then
# rcctl enable swarm_client_nutci
# rcctl start swarm_client_nutci
#exec >> /var/log/swarm_client_nutci.rcctl.log 2>&1
#echo "===== `date`: $0 $*"
#set -x
# These lines run as root, regardless of daemon_user
if [ -n "`/sbin/mount | grep /dev/shm`" ] ; then : ; else
# This can be automated in /etc/fstab with such line:
# swap /dev/shm mfs rw,nodev,nosuid,-s=1536000 0 0
mkdir /dev/shm
/sbin/mount_mfs -o rw,nodev,nosuid,-s=1536000 swap /dev/shm
fi
if [ -d /dev/shm ]; then chmod 1777 /dev/shm ; fi
daemon_user="abuild"
touch /var/log/swarm-client-nutci
chown ${daemon_user} /var/log/swarm-client-nutci
# allow larger resource limits (consider even "daemon" for unlimited?)
# see /etc/login.conf for standard definitions
usermod -L pbuild ${daemon_user}
downloader="/home/abuild/jenkins-swarm/swarm-client-download.sh >> /var/log/swarm-client-nutci 2>&1"
daemon="/home/abuild/jenkins-swarm/swarm-client-nutci.sh"
#daemon="cd /dev/shm && nohup /home/abuild/jenkins-swarm/swarm-client-nutci.sh >> /var/log/swarm-client-nutci 2>&1 &"
#daemon="/bin/sh -c \\' cd /dev/shm && nohup /home/abuild/jenkins-swarm/swarm-client-nutci.sh >> /var/log/swarm-client-nutci 2>&1 \\' &"
# Allow to restart the service on command line (or via rcctl)
INRC=1
. /etc/rc.d/rc.subr
rc_pre() {
echo "`date`: Starting $0" >> /var/log/swarm-client-nutci
# exec >> /var/log/swarm_client_nutci.rcctl.log 2>&1
# set -x
# set -v
PATH="$PATH:/usr/local/sbin:/usr/local/bin" ${downloader}
#cd /dev/shm || exit
}
rc_start() {
# Leading single-token no-op due to shell inlining peculiarities generally
cd /dev/shm && nohup su - ${daemon_user} -cx ' true; ulimit -a >&2; /home/abuild/jenkins-swarm/swarm-client-nutci.sh' >> /var/log/swarm-client-nutci 2>&1 &
sleep 2
rc_check
}
rc_stop() {
echo "`date`: Stopping $0" >> /var/log/swarm-client-nutci
kill -15 `ps -xawwu | grep java | grep swarm-client | grep "${daemon_user}" | awk '{print $2}'`
while test -n "`rc_check`" ; do sleep 2 ; done
return 0
}
rc_check() {
ps -xawwu | grep java | grep swarm-client | grep "${daemon_user}" | awk '{print $2}'
}
#set -x
rc_cmd $1