aboutsummaryrefslogtreecommitdiffstats
path: root/roles/ttrss/templates/usr
diff options
context:
space:
mode:
Diffstat (limited to 'roles/ttrss/templates/usr')
-rw-r--r--roles/ttrss/templates/usr/local/sbin/ttrss-update.sh.j227
1 files changed, 27 insertions, 0 deletions
diff --git a/roles/ttrss/templates/usr/local/sbin/ttrss-update.sh.j2 b/roles/ttrss/templates/usr/local/sbin/ttrss-update.sh.j2
new file mode 100644
index 0000000..663558c
--- /dev/null
+++ b/roles/ttrss/templates/usr/local/sbin/ttrss-update.sh.j2
@@ -0,0 +1,27 @@
+#!/usr/bin/env bash
+
+set -eu
+
+SRCDIR={{ ttrss_home | quote }}
+
+if (( $EUID != 0 )); then
+ echo 'must be superuser' 1>&2
+ exit 1
+fi
+
+cd "$SRCDIR"
+
+git fetch
+
+local_rev=$(git rev-parse HEAD)
+upstream_rev=$(git rev-parse '@{u}')
+
+echo "local: $local_rev"
+echo "upstream: $upstream_rev"
+
+if [ "$local_rev" != "$upstream_rev" ]; then
+ git reset --hard HEAD
+ systemctl restart ttrss
+else
+ echo "ttrss is already up to date"
+fi