| Server IP : 82.148.16.210 / Your IP : 216.73.216.19 Web Server : nginx/1.29.5 System : Linux mail.sarafai.ru 6.1.0-43-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.162-1 (2026-02-08) x86_64 User : root ( 0) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /usr/share/gitlab-runner/ |
Upload File : |
#!/bin/sh
set -e
# Check if service management is available by testing gitlab-runner status.
# This will fail if neither systemctl nor service commands are available.
check_service_management() {
set +e
error_output=$(gitlab-runner status 2>&1)
status_exit_code=$?
set -e
# Check the error message to see if it's a service management issue
if [ $status_exit_code -eq 0 ]; then
# Command succeeded
return 0
fi
if echo "$error_output" | grep -q "executable file not found"; then
return 1
fi
# If status command works but returns non-zero (e.g., service not installed yet), that's fine
return 0
}
# detect user: first try to use gitlab_ci_multi_runner
for USER in gitlab_ci_multi_runner gitlab-runner; do
if id -u "$USER" >/dev/null 2>/dev/null; then
echo "GitLab Runner: detected user $USER"
break
fi
done
# Disable
# [skel](https://www.thegeekdiary.com/understanding-the-etc-skel-directory-in-linux/)
# for distributions like Debian buster
# https://gitlab.com/gitlab-org/gitlab-runner/-/issues/1379
GITLAB_RUNNER_DISABLE_SKEL=${GITLAB_RUNNER_DISABLE_SKEL:-true}
# create user if doesn't exist: it will create gitlab-runner if not found
if ! id -u "$USER" >/dev/null 2>/dev/null; then
echo "GitLab Runner: creating $USER..."
if [ $GITLAB_RUNNER_DISABLE_SKEL = true ]; then
echo "Home directory skeleton not used"
useradd --system --shell /bin/bash --comment 'GitLab Runner' --create-home --skel /dev/null $USER
else
useradd --system --shell /bin/bash --comment 'GitLab Runner' --create-home $USER
fi
fi
# add user to docker group to allow Docker access (insecure)
if id -nG "$USER" | grep -q docker; then
echo "WARNING: $USER belongs to group docker which is insecure, because allows to have root access to host"
fi
# get USER home directory
eval HOMEDIR=~$USER
# create empty config and re-register runner
mkdir -p /etc/gitlab-runner
chmod 0700 /etc/gitlab-runner
if [ -f $HOMEDIR/config.toml ] && [ ! -f /etc/gitlab-runner/config.toml ]; then
echo "GitLab Runner: importing configuration to /etc/gitlab-runner/config.toml"
cp $HOMEDIR/config.toml /etc/gitlab-runner/config.toml
chmod 0600 /etc/gitlab-runner/config.toml
fi
# Verify service management is available before proceeding
if ! check_service_management; then
echo "GitLab Runner: WARNING - Service management is not available on this system."
echo "GitLab Runner: Neither 'systemctl' nor 'service' command found."
echo "GitLab Runner: The runner binary has been installed, but automatic service setup is skipped."
echo "GitLab Runner: You may need to manually configure the runner or install a service manager."
echo "GitLab Runner: For systemd systems, install 'systemd'. For SysV init systems, install 'initscripts' or 'sysvinit-utils'."
exit 0
fi
# uninstall old service
if gitlab-runner status --service="gitlab-runner"; then
gitlab-runner stop --service="gitlab-runner" >/dev/null 2>/dev/null || :
gitlab-runner uninstall --service="gitlab-runner" >/dev/null 2>/dev/null || :
fi
# if migrating from pre 10.0.0 installation
if gitlab-runner status --service="gitlab-ci-multi-runner"; then
gitlab-runner stop --service="gitlab-ci-multi-runner" >/dev/null 2>/dev/null || :
gitlab-runner uninstall --service="gitlab-ci-multi-runner" >/dev/null 2>/dev/null || :
fi
# re-register runner
gitlab-runner stop >/dev/null 2>/dev/null || :
gitlab-runner uninstall >/dev/null 2>/dev/null || :
# Fix https://gitlab.com/gitlab-org/gitlab-runner/-/issues/37000 by installing gitlab-runner with --init-user if
# $USE_INIT_USER was specified.
if [ -z "${USE_INIT_USER}" ];
then
gitlab-runner install --user=$USER --working-directory="${HOMEDIR}"
else
gitlab-runner install --init-user=$USER --working-directory="${HOMEDIR}"
# If a config.toml does not already exist in the user's $HOMEDIR, copy it from the default config location. This
# will only be true when using $USE_INIT_USER for the first time.
targetPath="${HOMEDIR}/config.toml"
if [ ! -f "${targetPath}" ] && [ -f /etc/gitlab-runner/config.toml ]; then
cp /etc/gitlab-runner/config.toml "${targetPath}"
chown $USER:$USER "${targetPath}"
fi
fi
# start runner service
gitlab-runner start || :