Laminar/cfg/jobs/navidrome.run

69 lines
2.3 KiB
Text
Raw Normal View History

2024-10-01 20:49:47 +09:00
#!/bin/env bash
# Upstream doc: https://www.navidrome.org/docs/installation/linux/
set -euxo pipefail
2024-10-01 20:56:45 +09:00
IMAGE="ubuntu/24.04"
DIST="${IMAGE%%/*}"
2024-10-01 20:49:47 +09:00
VER="${IMAGE#*/}"
VER="${VER%/*}"
VER="${VER//./-}"
2024-10-01 20:56:45 +09:00
UPSTREAM_VER="0.53.3"
2024-10-01 20:49:47 +09:00
UPSTREAM_VER_DASH="${UPSTREAM_VER//./-}"
UPSTREAM_NAME="navidrome"
2024-10-01 20:56:45 +09:00
SERIAL="1benoitjpnet"
2024-10-01 20:49:47 +09:00
CNAME="$UPSTREAM_NAME-$UPSTREAM_VER_DASH-$SERIAL-$DIST-$VER"
ALIAS="$UPSTREAM_NAME-$UPSTREAM_VER-$SERIAL"
2024-10-24 19:12:33 +09:00
cd "$WORKSPACE"
incus launch images:$IMAGE "$CNAME" --quiet
2024-10-01 20:49:47 +09:00
2024-10-24 19:12:33 +09:00
wait_network "$CNAME"
2024-10-01 20:49:47 +09:00
# Navidrome
2024-10-24 19:12:33 +09:00
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
"
2024-10-01 20:49:47 +09:00
# Syncthing
2024-10-24 19:12:33 +09:00
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 \
2024-10-01 20:49:47 +09:00
'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
2024-10-24 18:32:39 +09:00
# Next manual steps https://www.navidrome.org/docs/installation/linux/#create-configuration-file
2024-10-01 20:49:47 +09:00
# 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