From ea2f41dd774a6d2ad6a4ed4ddaf1fe1096987061 Mon Sep 17 00:00:00 2001 From: Benoit Date: Thu, 24 Oct 2024 19:12:33 +0900 Subject: [PATCH 1/3] Navidrome: Apply Shellcheck --- cfg/jobs/navidrome.run | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/cfg/jobs/navidrome.run b/cfg/jobs/navidrome.run index f11ac2f..efc58cc 100755 --- a/cfg/jobs/navidrome.run +++ b/cfg/jobs/navidrome.run @@ -14,27 +14,27 @@ SERIAL="1benoitjpnet" CNAME="$UPSTREAM_NAME-$UPSTREAM_VER_DASH-$SERIAL-$DIST-$VER" ALIAS="$UPSTREAM_NAME-$UPSTREAM_VER-$SERIAL" -cd $WORKSPACE -incus launch images:$IMAGE $CNAME --quiet +cd "$WORKSPACE" +incus launch images:$IMAGE "$CNAME" --quiet -wait_network $CNAME +wait_network "$CNAME" # Navidrome -incus exec $CNAME -- apt update -incus exec $CNAME -- apt upgrade -y -incus exec $CNAME -- apt install -y --no-install-recommends ffmpeg wget -incus exec $CNAME -- useradd -m -s /sbin/nologin -d /var/lib/navidrome navidrome -incus exec $CNAME -- install -d -o navidrome -g navidrome /opt/navidrome -incus exec $CNAME -- wget -q \ - "https://github.com/navidrome/navidrome/releases/download/v${UPSTREAM_VER}/navidrome_${UPSTREAM_VER}_linux_amd64.tar.gz" \ - -O /tmp/Navidrome.tar.gz -incus exec $CNAME -- tar -xvzf /tmp/Navidrome.tar.gz -C /opt/navidrome/ -incus exec $CNAME -- chown -R navidrome:navidrome /opt/navidrome +incus exec "$CNAME" -- bash -c "apt update && \ + apt upgrade -y && \ + apt install -y --no-install-recommends ffmpeg wget && \ + useradd -m -s /sbin/nologin -d /var/lib/navidrome navidrome && \ + install -d -o navidrome -g navidrome /opt/navidrome && \ + wget -q https://github.com/navidrome/navidrome/releases/download/v${UPSTREAM_VER}/navidrome_${UPSTREAM_VER}_linux_amd64.tar.gz \ + -O /tmp/Navidrome.tar.gz && \ + tar -xvzf /tmp/Navidrome.tar.gz -C /opt/navidrome/ && \ + chown -R navidrome:navidrome /opt/navidrome +" # Syncthing -incus exec $CNAME -- apt install -y --no-install-recommends syncthing -incus exec $CNAME -- cp /lib/systemd/system/syncthing\@.service /etc/systemd/system/ -incus exec $CNAME -- sed -i \ +incus exec "$CNAME" -- apt install -y --no-install-recommends syncthing +incus exec "$CNAME" -- cp /lib/systemd/system/syncthing\@.service /etc/systemd/system/ +incus exec "$CNAME" -- sed -i \ 's/\(ExecStart=\/usr\/bin\/syncthing serve --no-browser --no-restart --logflags=0\)/\1 --gui-address=0.0.0.0:8384/' \ /etc/systemd/system/syncthing\@.service From f98ca9361932f38a1abb452a24940583af34676f Mon Sep 17 00:00:00 2001 From: Benoit Date: Thu, 24 Oct 2024 19:12:57 +0900 Subject: [PATCH 2/3] Navidrome: Call job incus_publish --- cfg/jobs/navidrome.run | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/cfg/jobs/navidrome.run b/cfg/jobs/navidrome.run index efc58cc..439886e 100755 --- a/cfg/jobs/navidrome.run +++ b/cfg/jobs/navidrome.run @@ -40,29 +40,10 @@ incus exec "$CNAME" -- sed -i \ # Next manual steps https://www.navidrome.org/docs/installation/linux/#create-configuration-file -# Clean -incus exec $CNAME -- \ - rm -rf \ - /etc/machine-id \ - /var/cache/apt \ - /var/log/journal - -# Publish -incus stop $CNAME -incus config metadata show $CNAME > metadata.yaml -# Get the current Unix timestamp -current_timestamp=$(date +%s) -# Calculate expiry date as current timestamp + 1 week (604800 seconds) -expiry_date=$(($current_timestamp + 604800)) -# Update metadata values -sed -i \ - -e "s/creation_date: .*/creation_date: $current_timestamp/" \ - -e "s/expiry_date: .*/expiry_date: $expiry_date/" \ - -e "s#description: .*#description: $UPSTREAM_NAME v$UPSTREAM_VER on $IMAGE release $SERIAL#" \ - -e "s/name: .*/name: $CNAME/" \ - -e "s/serial: .*/serial: $SERIAL/" \ - metadata.yaml - -incus config metadata edit $CNAME < metadata.yaml -incus publish $CNAME --alias $ALIAS --public -incus rm $CNAME +laminarc run incus_publish \ + CNAME="$CNAME" \ + UPSTREAM=$UPSTREAM_NAME \ + UPSTREAM_VER=$UPSTREAM_VER \ + IMAGE=$IMAGE \ + SERIAL=$SERIAL \ + ALIAS=$ALIAS From 1bca4ee0f5335a47d8723342bd90b069e8152320 Mon Sep 17 00:00:00 2001 From: Benoit Date: Thu, 24 Oct 2024 19:13:20 +0900 Subject: [PATCH 3/3] Add Incus publish job --- cfg/jobs/incus_publish.run | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 cfg/jobs/incus_publish.run diff --git a/cfg/jobs/incus_publish.run b/cfg/jobs/incus_publish.run new file mode 100644 index 0000000..8e4ff3b --- /dev/null +++ b/cfg/jobs/incus_publish.run @@ -0,0 +1,32 @@ +#!/bin/env bash +set -euxo pipefail + +# Clean +incus exec "$CNAME" -- \ + rm -rf \ + /etc/machine-id \ + /var/cache/apt \ + /var/log/journal + +# Publish +incus stop "$CNAME" +incus config metadata show "$CNAME" > "$ARCHIVE"/metadata.yaml +# Get the current Unix timestamp +current_timestamp=$(date +%s) +# Calculate expiry date as current timestamp + 1 week (604800 seconds) +expiry_date=$((current_timestamp + 604800)) +# Update metadata values +sed -i \ + -e "s/creation_date: .*/creation_date: $current_timestamp/" \ + -e "s/expiry_date: .*/expiry_date: $expiry_date/" \ + -e "s#description: .*#description: $UPSTREAM_NAME v$UPSTREAM_VER on $IMAGE release $SERIAL#" \ + -e "s/name: .*/name: $CNAME/" \ + -e "s/serial: .*/serial: $SERIAL/" \ + "$ARCHIVE"/metadata.yaml + +incus config metadata edit "$CNAME" < "$ARCHIVE"/metadata.yaml +incus publish "$CNAME" \ + --alias "$ALIAS" \ + --public \ + --quiet +incus rm "$CNAME"