43 lines
1.3 KiB
Bash
Executable File
43 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
PUID="${PUID:-1000}"
|
|
PGID="${PGID:-1000}"
|
|
|
|
# Create a matching group/user if needed.
|
|
if ! getent group "$PGID" >/dev/null 2>&1; then
|
|
groupadd -g "$PGID" beets
|
|
fi
|
|
|
|
if ! id -u "$PUID" >/dev/null 2>&1; then
|
|
useradd -u "$PUID" -g "$PGID" -d /music/beets -s /bin/zsh beets
|
|
fi
|
|
|
|
mkdir -p \
|
|
/music/beets/config \
|
|
/music/beets/cache \
|
|
/music/beets/logs \
|
|
/music/beets/.config \
|
|
/music/library \
|
|
/music/inbox \
|
|
/music/pruned
|
|
|
|
# Make ~/.config/beets resolve to the repo config directory.
|
|
# This preserves your current mental model and helps scripts that expect it.
|
|
if [[ ! -e /music/beets/.config/beets ]]; then
|
|
ln -s ../config /music/beets/.config/beets
|
|
fi
|
|
|
|
# Compatibility shim for your existing beets config.
|
|
# You can later change config.yaml to call /music/beets/scripts/check-audio-decode directly.
|
|
if [[ -x /music/beets/scripts/check-audio-decode && ! -e /usr/local/bin/check-audio-decode ]]; then
|
|
ln -s /music/beets/scripts/check-audio-decode /usr/local/bin/check-audio-decode
|
|
fi
|
|
|
|
# Do not recursively chown /music/library. That can be huge and dangerous.
|
|
# Only touch small beets-owned state directories.
|
|
chown -h "$PUID:$PGID" /music/beets /music/beets/.config /music/beets/.config/beets 2>/dev/null || true
|
|
chown -R "$PUID:$PGID" /music/beets/cache /music/beets/logs 2>/dev/null || true
|
|
|
|
exec gosu "$PUID:$PGID" "$@"
|