aboutsummaryrefslogtreecommitdiffstats
path: root/roles/photostructure/templates/opt
diff options
context:
space:
mode:
authorStonewall Jackson <stonewall@sacredheartsc.com>2023-02-04 01:23:43 -0500
committerStonewall Jackson <stonewall@sacredheartsc.com>2023-02-04 01:52:13 -0500
commit0261e875679f1bf63c8d689da7fc7e014597885d (patch)
tree3f19cd74a0c1070944f75437f30b098d6ef2ffcb /roles/photostructure/templates/opt
downloadselfhosted-0261e875679f1bf63c8d689da7fc7e014597885d.tar.gz
selfhosted-0261e875679f1bf63c8d689da7fc7e014597885d.zip
initial commit
Diffstat (limited to 'roles/photostructure/templates/opt')
-rw-r--r--roles/photostructure/templates/opt/photostructure/photostructure-update.sh.j248
1 files changed, 48 insertions, 0 deletions
diff --git a/roles/photostructure/templates/opt/photostructure/photostructure-update.sh.j2 b/roles/photostructure/templates/opt/photostructure/photostructure-update.sh.j2
new file mode 100644
index 0000000..114a145
--- /dev/null
+++ b/roles/photostructure/templates/opt/photostructure/photostructure-update.sh.j2
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+
+set -Eeu -o pipefail
+
+SRCDIR={{ photostructure_install_dir | quote }}
+PHOTOSTRUCTURE_USER={{ photostructure_user | quote }}
+PHOTOSTRUCTURE_INSTALL_DIR={{ photostructure_install_dir | quote }}
+PHOTOSTRUCTURE_HOME={{ photostructure_home | quote }}
+
+as-photostructure() {
+ runuser -u "$PHOTOSTRUCTURE_USER" -- "$@"
+}
+
+if (( $EUID != 0 )); then
+ echo 'must be superuser' 1>&2
+ exit 1
+fi
+
+cd "$SRCDIR"
+
+as-photostructure 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
+ systemctl stop photostructure
+
+ as-photostructure git pull --ff-only
+
+ echo "building photostructure..."
+ rm -rf "${PHOTOSTRUCTURE_INSTALL_DIR}/node_modules" \
+ "$PHOTOSTRUCTURE_HOME/.electron" \
+ "$PHOTOSTRUCTURE_HOME/.electron-gyp" \
+ "$PHOTOSTRUCTURE_HOME/.npm/_libvips" \
+ "$PHOTOSTRUCTURE_HOME/.node-gyp" \
+ "$PHOTOSTRUCTURE_HOME/.cache/yarn/*/*sharp*"
+
+ cd "$PHOTOSTRUCTURE_INSTALL_DIR"
+ as-photostructure npx yarn install --yes
+
+ systemctl start photostructure
+else
+ echo "photostructure is already up to date"
+fi