Bad initscript on CentOS 6
I've installed gitlab-ci-multi-runner-0.5.0-1 on a CentOS 6 machine. When I try to start the service, I get:
# /etc/init.d/gitlab-runner start
Starting GitLab Runner: /etc/init.d/gitlab-runner: Usage: daemon [+/-nicelevel] {program}
It seems like the bug comes from the following initscript, where user
is empty but nonetheless specified as a command-line argument for daemon
:
# cat /etc/init.d/gitlab-runner
#!/bin/sh
# For RedHat and cousins:
# chkconfig: - 99 01
# description: GitLab Runner
# processname: /usr/bin/gitlab-ci-multi-runner
# Source function library.
. /etc/rc.d/init.d/functions
name="gitlab-runner"
desc="GitLab Runner"
user=""
cmd=/usr/bin/gitlab-ci-multi-runner
args=" "run" "--working-directory" "/home/gitlab-runner" "--config" "/etc/gitlab-runner/config.toml" "--service" "gitlab-runner" "--user" "gitlab-runner""
log_file="/var/log/$name.log"
lockfile=/var/lock/subsys/$name
# Source networking configuration.
[ -r /etc/sysconfig/$name ] && . /etc/sysconfig/$name
start() {
echo -n $"Starting $desc: "
daemon --user=$user bash --login -c "'exec $cmd $args 1>&3 2>&3 &'" 3>> $log_file
retval=$?
[ $retval -eq 0 ] && touch $lockfile
echo
return $retval
}
stop() {
echo -n $"Stopping $desc: "
killproc $cmd -TERM
retval=$?
[ $retval -eq 0 ] && rm -f $lockfile
echo
return $retval
}
restart() {
stop
start
}
reload() {
echo -n $"Reloading $desc: "
killproc $cmd -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
rh_status() {
status $cmd
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac