package/gitlab-runner: fix inconsistency of systemd and sysv daemons

Copy default $DAEMON_ARGS from systemd service to sysv init script.

Make GITLAB_RUNNER_USER home directory the same as default
--work-directory (-d) flag.

Run sysv daemon process using root user (remove -c option)
This is needed to correctly access config files as specified.
System access can still be limited with gitlab-runner `--user` flag.

Use same $DAEMON_ARGS variable name so it can be overwritten in
/etc/default/gitlab-runner environment file in both cases.

Signed-off-by: Marek Metelski <marek.metelski@grinn-global.com>
Reviewed-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
Marek Metelski 2022-11-07 10:16:58 +01:00 committed by Thomas Petazzoni
parent 47659b4f34
commit ef6c9da9d2
2 changed files with 4 additions and 5 deletions

View File

@ -3,7 +3,7 @@
DAEMON="gitlab-runner"
PIDFILE="/var/run/$DAEMON.pid"
GITLAB_RUNNER_ARGS="run"
DAEMON_ARGS="run --syslog --user gitlab-runner -d /var/lib/gitlab-runner -c /etc/gitlab-runner/config.toml"
# shellcheck source=/dev/null
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
@ -11,8 +11,8 @@ GITLAB_RUNNER_ARGS="run"
start() {
printf 'Starting %s: ' "$DAEMON"
# shellcheck disable=SC2086 # we need the word splitting
start-stop-daemon -S -q -m -b -p "$PIDFILE" -c "$DAEMON:$DAEMON" -x "/usr/bin/$DAEMON" \
-- $GITLAB_RUNNER_ARGS
start-stop-daemon -S -q -m -b -p "$PIDFILE" -x "/usr/bin/$DAEMON" \
-- $DAEMON_ARGS
status=$?
if [ "$status" -eq 0 ]; then
echo "OK"

View File

@ -12,9 +12,8 @@ GITLAB_RUNNER_LICENSE_FILES = LICENSE
GITLAB_RUNNER_LDFLAGS = \
-X gitlab.com/gitlab-org/gitlab-runner/common.VERSION=$(GITLAB_RUNNER_VERSION)
# Don't run gitlab runner as root.
define GITLAB_RUNNER_USERS
gitlab-runner -1 gitlab-runner -1 * /var/run/dbus /bin/false - Gitlab Runner
gitlab-runner -1 gitlab-runner -1 * /var/lib/gitlab-runner /bin/false - Gitlab Runner
endef
define GITLAB_RUNNER_INSTALL_INIT_SYSV