[projects/git-slug] Move slug_watch to subdir and add its init scripts

baggins baggins at pld-linux.org
Wed Dec 31 15:31:02 CET 2025


commit 0e95f11bd36a87484075b8a127eec58d893036c8
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Wed Dec 31 15:30:27 2025 +0100

    Move slug_watch to subdir and add its init scripts

 watch/crontab                  |  5 +++
 slug_watch => watch/slug_watch |  0
 watch/slug_watch-cron          |  9 +++++
 watch/slug_watch.init          | 76 ++++++++++++++++++++++++++++++++++++++++++
 watch/slug_watch.service       | 14 ++++++++
 watch/slug_watch.sysconfig     |  6 ++++
 6 files changed, 110 insertions(+)
---
diff --git a/watch/crontab b/watch/crontab
new file mode 100644
index 0000000..8ceda79
--- /dev/null
+++ b/watch/crontab
@@ -0,0 +1,5 @@
+SHELL=/bin/sh
+MAILTO=root
+
+# 03 5 * * *     git /usr/bin/slug_watch-cron --aggressive
+*/15 * * * *   git /usr/bin/slug_watch-cron
diff --git a/slug_watch b/watch/slug_watch
similarity index 100%
rename from slug_watch
rename to watch/slug_watch
diff --git a/watch/slug_watch-cron b/watch/slug_watch-cron
new file mode 100644
index 0000000..258accf
--- /dev/null
+++ b/watch/slug_watch-cron
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+if [ -f /etc/sysconfig/slug_watch ]; then
+	. /etc/sysconfig/slug_watch
+fi
+
+if [ -n "$REFREPODIR" ]; then
+	git --git-dir="$REFREPODIR/Refs.git" gc "$@"
+fi
diff --git a/watch/slug_watch.init b/watch/slug_watch.init
new file mode 100644
index 0000000..ce90822
--- /dev/null
+++ b/watch/slug_watch.init
@@ -0,0 +1,76 @@
+#!/bin/sh
+#
+# slug_watch	daemon to update Refs list
+#
+# chkconfig:	345 99 01
+#
+# description:	daemon for PLD gitolite setup
+#
+# processname:	slug_watch
+# pidfile: /var/run/slug_watch.pid
+#
+# $Id$
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Source slug_watch configuration
+. /etc/sysconfig/slug_watch
+
+
+pidfile="/var/run/slug_watch.pid"
+
+if [ ! -n "$WATCHDIR"  -o ! -n "$REFREPODIR" ]; then
+	echo "WATCHDIR or REFREPODIR variable not set"
+	exit 1
+fi
+
+start() {
+	# Check if the service is already running?
+	if [ -f /var/lock/subsys/slug_watch ]; then
+		msg_already_running "slug_watch"
+		return
+	fi
+
+	msg_starting "slug_watch"
+	daemon /usr/bin/slug_watch -u git -w "$WATCHDIR" -r "$REFREPODIR" $OTHER_OPTIONS -d start 
+	RETVAL=$?
+	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/slug_watch
+}
+
+stop() {
+	if [ ! -f /var/lock/subsys/slug_watch ]; then
+		msg_not_running "slug_watch"
+		return
+	fi
+
+	# Stop daemons.
+	msg_stopping "slug_watch"
+	killproc slug_watch
+	rm -f /var/lock/subsys/slug_watch
+}
+
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+	start
+	;;
+  stop)
+	stop
+	;;
+  restart)
+	stop
+	start
+	;;
+  status)
+	status --pidfile $pidfile slug_watch
+	RETVAL=$?
+	;;
+  *)
+	msg_usage "$0 {start|stop|restart|status}"
+	exit 3
+esac
+
+exit $RETVAL
diff --git a/watch/slug_watch.service b/watch/slug_watch.service
new file mode 100644
index 0000000..713bb22
--- /dev/null
+++ b/watch/slug_watch.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=PLD gitolite setup deamon for updating Refs list
+
+[Install]
+WantedBy=multi-user.target
+
+[Service]
+EnvironmentFile=/etc/sysconfig/slug_watch
+ConditionEnvironment=WATCHDIR
+ConditionEnvironment=REFREPODIR
+Type=exec
+User=git
+ExecStart=/usr/bin/slug_watch -w ${WATCHDIR} -r ${REFREPODIR} $OTHER_OPTIONS
+Restart=on-failure
diff --git a/watch/slug_watch.sysconfig b/watch/slug_watch.sysconfig
new file mode 100644
index 0000000..299c62c
--- /dev/null
+++ b/watch/slug_watch.sysconfig
@@ -0,0 +1,6 @@
+# If the path is not absolute it is interpret in respect of home directory of
+# user running slug_watch daemon
+WATCHDIR="watchdir"
+REFREPODIR="repositories"
+
+OTHER_OPTIONS="-m root -s git"
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/git-slug.git/commitdiff/0e95f11bd36a87484075b8a127eec58d893036c8



More information about the pld-cvs-commit mailing list