osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ci/+/42961?usp=email )
Change subject: contrib/obs-mirror: log to systemd journal ......................................................................
contrib/obs-mirror: log to systemd journal
Instead of having a lot of logfiles in /home/pkgmirror and starting the obs-mirror scripts via cronjob, add systemd services and timers and let them log to the systemd journal.
Change-Id: I3a567770ef6d98bb3fdc2d52214cacbfe59640ad --- D contrib/obs-mirror/README A contrib/obs-mirror/README.md M contrib/obs-mirror/obs-mirror.sh M contrib/obs-mirror/rm-old-nightly-archives.sh A contrib/obs-mirror/systemd/obs-mirror.service A contrib/obs-mirror/systemd/obs-mirror.timer A contrib/obs-mirror/systemd/rm-old-nightly-archives.service A contrib/obs-mirror/systemd/rm-old-nightly-archives.timer 8 files changed, 56 insertions(+), 13 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/61/42961/1
diff --git a/contrib/obs-mirror/README b/contrib/obs-mirror/README deleted file mode 100644 index 4cab14b..0000000 --- a/contrib/obs-mirror/README +++ /dev/null @@ -1,7 +0,0 @@ -The scripts in this directory are used to create an archive of Osmocom related -packages from OBS, at: https://downloads.osmocom.org/obs-mirror/ - -There is no mechanism in place to deploy updated scripts after updating them -here in osmo-ci.git, so this must be done manually. - -See OS#4862 for more information. diff --git a/contrib/obs-mirror/README.md b/contrib/obs-mirror/README.md new file mode 100644 index 0000000..01c9615 --- /dev/null +++ b/contrib/obs-mirror/README.md @@ -0,0 +1,19 @@ +The scripts in this directory are used to create an archive of Osmocom related +packages from OBS, at: https://downloads.osmocom.org/obs-mirror/ + +There is no mechanism in place to deploy updated scripts after updating them +here in osmo-ci.git, so this must be done manually: + +``` +$ ssh pkgmirror@package-archive.osmocom.org +pkgmirror@package-archive:~$ git -C osmo-ci pull +``` + +After changing the systemd services or timers, deploy them as follows: +``` +$ scp systemd/* root@package-archive.osmocom.org:/etc/systemd/system +$ ssh root@@package-archive.osmocom.org +root@package-archive:~# systemctl daemon-reload +``` + +See OS#4862 for more information. diff --git a/contrib/obs-mirror/obs-mirror.sh b/contrib/obs-mirror/obs-mirror.sh index 85336ab..090ff26 100755 --- a/contrib/obs-mirror/obs-mirror.sh +++ b/contrib/obs-mirror/obs-mirror.sh @@ -9,10 +9,7 @@ # # See also: OS#4862
-DATE=`date +%Y%m%d-%H%M%S` -LOGFILE="/home/pkgmirror/obs-mirror-$DATE.log" -echo "Redirecting all output to: $LOGFILE" -exec >$LOGFILE 2>&1 +DATE="$(date +%Y%m%d-%H%M%S)"
set -e -x SCRIPT_DIR="$(realpath "$(dirname "$(realpath "$0")")")" diff --git a/contrib/obs-mirror/rm-old-nightly-archives.sh b/contrib/obs-mirror/rm-old-nightly-archives.sh index 485788f..cde4223 100755 --- a/contrib/obs-mirror/rm-old-nightly-archives.sh +++ b/contrib/obs-mirror/rm-old-nightly-archives.sh @@ -1,7 +1,5 @@ #!/bin/sh -e # Remove nightly archives older than one month (OS#4862) -echo "Redirecting all output to: /home/pkgmirror/rm-old-nightly-archives.log" -exec >"/home/pkgmirror/rm-old-nightly-archives.log" 2>&1
DRY=0
diff --git a/contrib/obs-mirror/systemd/obs-mirror.service b/contrib/obs-mirror/systemd/obs-mirror.service new file mode 100644 index 0000000..6a2f8a0 --- /dev/null +++ b/contrib/obs-mirror/systemd/obs-mirror.service @@ -0,0 +1,10 @@ +[Unit] +Description=obs-mirror + +[Service] +Type=oneshot +User=pkgmirror +ExecStart=/home/pkgmirror/osmo-ci/contrib/obs-mirror/obs-mirror.sh + +[Install] +WantedBy=multi-user.target diff --git a/contrib/obs-mirror/systemd/obs-mirror.timer b/contrib/obs-mirror/systemd/obs-mirror.timer new file mode 100644 index 0000000..5005e2f --- /dev/null +++ b/contrib/obs-mirror/systemd/obs-mirror.timer @@ -0,0 +1,8 @@ +[Unit] +Description=Run obs-mirror.service + +[Timer] +OnCalendar=*-*-* 06:19:00 + +[Install] +WantedBy=timers.target diff --git a/contrib/obs-mirror/systemd/rm-old-nightly-archives.service b/contrib/obs-mirror/systemd/rm-old-nightly-archives.service new file mode 100644 index 0000000..57342cc --- /dev/null +++ b/contrib/obs-mirror/systemd/rm-old-nightly-archives.service @@ -0,0 +1,10 @@ +[Unit] +Description=obs-mirror + +[Service] +Type=oneshot +User=pkgmirror +ExecStart=/home/pkgmirror/osmo-ci/contrib/obs-mirror/rm-old-nightly-archives.sh + +[Install] +WantedBy=multi-user.target diff --git a/contrib/obs-mirror/systemd/rm-old-nightly-archives.timer b/contrib/obs-mirror/systemd/rm-old-nightly-archives.timer new file mode 100644 index 0000000..58e8266 --- /dev/null +++ b/contrib/obs-mirror/systemd/rm-old-nightly-archives.timer @@ -0,0 +1,8 @@ +[Unit] +Description=Run rm-old-nightly-archives.service + +[Timer] +OnCalendar=*-*-* 07:10:00 + +[Install] +WantedBy=timers.target