Commit ad33aa14 authored by ale's avatar ale

Add a timer (cron job) to the Debian package for update-gitlab-deps

parent cd449dbd
#!/bin/sh
deps_file=/var/lib/gitlab-deps/deps.json
if [ -z "$GITLAB_URL" ]; then
echo "Gitlab-deps is not configured (GITLAB_URL empty)" >&2
exit 0
fi
if [ ! -e /var/lib/gitlab-deps/deps.json ]; then
if [ ! -e $deps_file ]; then
echo "No deps.json file, executing update..." >&2
/usr/sbin/update-gitlab-deps
/usr/sbin/update-gitlab-deps --no-reload
if [ $? -gt 0 ]; then
echo "update-gitlab-deps failed" >&2
exit 1
......@@ -16,4 +18,6 @@ fi
exec /usr/bin/gitlab-deps server \
--token-file=$GITLAB_TOKEN_FILE --url=$GITLAB_URL \
< /var/lib/gitlab-deps/deps.json
--addr=${ADDR:-0.0.0.0} --port=${PORT:-3535} \
--webhook-auth-token=$WEBHOOK_AUTH_TOKEN \
< $deps_file
#!/bin/sh
deps_file=/var/lib/gitlab-deps/deps.json
reload=1
ret=0
if [ "x$1" = "x--no-reload" ]; then
reload=0
fi
[ -e /etc/default/gitlab-deps ] && . /etc/default/gitlab-deps
if [ -z "$GITLAB_URL" -o -z "$GITLAB_TOKEN_FILE" ]; then
......@@ -9,7 +17,20 @@ fi
opts="--token-file=$GITLAB_TOKEN_FILE --url=$GITLAB_URL"
tmp_file="${deps_file}.tmp.$$"
trap "rm -f $tmp_file 2>/dev/null" EXIT
gitlab-deps list-projects $opts \
| egrep "${PROJECT_REGEXP:-.*}" \
| gitlab-deps deps $opts \
> $deps_file
> $tmp_file
if ! cmp $tmp_file $deps_file; then
mv -f $tmp_file $deps_file
if [ $reload -eq 1 ]; then
systemctl reload-or-restart gitlab-deps
ret=$?
fi
fi
exit $ret
[Unit]
Description=A/I account server
After=slapd.service
[Service]
EnvironmentFile=-/etc/default/accountserver
ExecStart=/usr/bin/accountserver $DAEMON_OPTS
Restart=always
[Install]
WantedBy=multi-user.target
[Unit]
Description=Update gitlab-deps dependency map
After=gitlab-deps.service
[Service]
Type=oneshot
ExecStart=/usr/sbin/update-gitlab-deps
User=gitlab-deps
Group=gitlab-deps
[Unit]
Description=Timer for update-gitlab-deps
[Timer]
OnCalendar="18 2 * * *"
Persistent=true
[Install]
WantedBy=timers.target
......@@ -7,3 +7,10 @@ GITLAB_TOKEN_FILE=/var/lib/gitlab-deps/auth_token
# Set to a regular expression (extended) if you want to filter the
# project list.
#PROJECT_REGEXP=
# Set to the X-Gitlab-Token to be used for request authentication.
#WEBHOOK_AUTH_TOKEN=
# Address and port to bind to.
ADDR=0.0.0.0
PORT=3535
#!/usr/bin/make -f
# -*- makefile -*-
SYSTEMD_UNITS = \
gitlab-deps.service \
gitlab-deps-update.timer \
gitlab-deps-update.service
export PYBUILD_NAME=gitlab-deps
%:
......@@ -13,3 +18,6 @@ override_dh_auto_install:
$(CURDIR)/debian/gitlab-deps/usr/sbin/gitlab-deps-server-wrapper
install -o root -g root -m 755 $(CURDIR)/contrib/update.sh \
$(CURDIR)/debian/gitlab-deps/usr/sbin/update-gitlab-deps
override_dh_install_systemd:
dh_install_systemd $(SYSTEMD_UNITS)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment