Created
September 26, 2017 13:01
-
-
Save uilianries/e51790fb2b8be76b459df335965c9a15 to your computer and use it in GitHub Desktop.
Gitlab Runner service for FreeBSD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# PROVIDE: gitlab_runner | |
# REQUIRE: DAEMON NETWORKING | |
# BEFORE: | |
# KEYWORD: | |
. /etc/rc.subr | |
name="gitlab_runner" | |
rcvar="gitlab_runner_enable" | |
load_rc_config $name | |
user="gitlab-runner" | |
user_home="/home/gitlab-runner" | |
command="/usr/local/bin/gitlab-runner run" | |
pidfile="/var/run/${name}.pid" | |
start_cmd="gitlab_runner_start" | |
stop_cmd="gitlab_runner_stop" | |
status_cmd="gitlab_runner_status" | |
gitlab_runner_start() | |
{ | |
export USER=${user} | |
export HOME=${user_home} | |
if checkyesno ${rcvar}; then | |
cd ${user_home} | |
/usr/sbin/daemon -u ${user} -p ${pidfile} ${command} > /var/log/gitlab_runner.log 2>&1 | |
fi | |
} | |
gitlab_runner_stop() | |
{ | |
if [ -f ${pidfile} ]; then | |
kill `cat ${pidfile}` | |
fi | |
} | |
gitlab_runner_status() | |
{ | |
if [ ! -f ${pidfile} ] || kill -0 `cat ${pidfile}`; then | |
echo "Service ${name} is not running." | |
else | |
echo "${name} appears to be running." | |
fi | |
} | |
run_rc_command $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment