Updated ownership under liquidsoap user

This commit is contained in:
G. Gibson 2026-09-01 19:29:06 -07:00
commit 49ab0b725e
4 changed files with 354 additions and 156 deletions

View file

@ -40,7 +40,7 @@ fi
CONFIG_JSON="${INSTALL_DIR}/config.json"
prompt() {
local var_name="$1" prompt_text="$2" default="${3:-}"
local prompt_text="$1" default="${2:-}"
local current=""
if [[ -n "$default" ]]; then
read -rp "${prompt_text} [${default}]: " current || true
@ -71,22 +71,22 @@ fi
echo ""
echo "--- Storage ---"
STORAGE_PATH=$(prompt storage_path "Storage path (media + state + logs)" "/mnt/storage/radio${existing_storage:+|$existing_storage}")
STORAGE_PATH=$(prompt "Storage path (media + state + logs)" "${existing_storage:-/mnt/storage/radio}")
[[ -z "$STORAGE_PATH" ]] && STORAGE_PATH="${existing_storage:-/mnt/storage/radio}"
echo ""
echo "--- Icecast (source credentials) ---"
IC_HOST=$(prompt ic_host "Icecast host" "$existing_ic_host"); IC_HOST=${IC_HOST:-localhost}
IC_PORT=$(prompt ic_port "Icecast source port" "$existing_ic_port"); IC_PORT=${IC_PORT:-7777}
IC_MOUNT=$(prompt ic_mount "Mount point" "$existing_ic_mount"); IC_MOUNT=${IC_MOUNT:-/data}
IC_USER=$(prompt ic_user "Source username" "$existing_ic_user"); IC_USER=${IC_USER:-source}
IC_HOST=$(prompt "Icecast host" "$existing_ic_host"); IC_HOST=${IC_HOST:-localhost}
IC_PORT=$(prompt "Icecast source port" "$existing_ic_port"); IC_PORT=${IC_PORT:-7777}
IC_MOUNT=$(prompt "Mount point" "$existing_ic_mount"); IC_MOUNT=${IC_MOUNT:-/data}
IC_USER=$(prompt "Source username" "$existing_ic_user"); IC_USER=${IC_USER:-source}
read -rsp "Source password: " IC_PASS || true; echo; IC_PASS=${IC_PASS:-$existing_ic_pass}
echo ""
echo "--- gPodder sync (optional) ---"
GP_ENABLE=$(prompt gp_enable "Enable gPodder sync? (true/false)" "$existing_gp_enable"); GP_ENABLE=${GP_ENABLE:-false}
GP_HOST=$(prompt gp_host "gPodder host" "$existing_gp_host"); GP_HOST=${GP_HOST:-https://gpodder.net}
GP_USER=$(prompt gp_user "gPodder username" "$existing_gp_user")
GP_ENABLE=$(prompt "Enable gPodder sync? (true/false)" "$existing_gp_enable"); GP_ENABLE=${GP_ENABLE:-false}
GP_HOST=$(prompt "gPodder host" "$existing_gp_host"); GP_HOST=${GP_HOST:-https://gpodder.net}
GP_USER=$(prompt "gPodder username" "$existing_gp_user")
read -rsp "gPodder password: " GP_PASS || true; echo; GP_PASS=${GP_PASS:-$existing_gp_pass}
echo ""
@ -195,6 +195,10 @@ echo "==> Installing Python dependencies (feedparser, requests) ..."
"${VENV}/bin/pip" install --quiet --upgrade pip
"${VENV}/bin/pip" install --quiet feedparser requests
# Make sure the liquidsoap user can traverse the install dir and use the venv.
chmod o+x "$INSTALL_DIR"
chown -R "$LIQUIDSOAP_USER":"$LIQUIDSOAP_USER" "$VENV"
# ---------------------------------------------------------------------------
# 7. systemd unit (named after the directory)
# ---------------------------------------------------------------------------
@ -229,17 +233,24 @@ chown "$LIQUIDSOAP_USER":"$LIQUIDSOAP_USER" "${INSTALL_DIR}/station_runner.py"
systemctl daemon-reload
# ---------------------------------------------------------------------------
# 8. Cron jobs (deduplicated)
# 8. Cron jobs — installed into the liquidsoap user's crontab so all
# database/media writes happen under the same identity as the service.
# ---------------------------------------------------------------------------
echo "==> Setting up cron jobs ..."
echo "==> Setting up cron jobs under user '${LIQUIDSOAP_USER}' ..."
FETCH_CRON="0 * * * * cd ${INSTALL_DIR} && ./.venv/bin/python fetch_podcasts.py >> ${STORAGE_PATH}/logs/fetch.log 2>&1"
UPDATE_CRON="30 * * * * cd ${INSTALL_DIR} && ./.venv/bin/python update_playlists.py >> ${STORAGE_PATH}/logs/update.log 2>&1"
crontab -l 2>/dev/null | grep -vF "fetch_podcasts.py" | grep -vF "update_playlists.py" > /tmp/cron_radio.$$ || true
echo "$FETCH_CRON" >> /tmp/cron_radio.$$
echo "$UPDATE_CRON" >> /tmp/cron_radio.$$
crontab /tmp/cron_radio.$$
rm -f /tmp/cron_radio.$$
# Remove any stale entries from the liquidsoap user's crontab, then add ours.
sudo -u "$LIQUIDSOAP_USER" crontab -l 2>/dev/null | grep -vF "fetch_podcasts.py" | grep -vF "update_playlists.py" > /tmp/cron_ls_py.$$ || true
echo "$FETCH_CRON" >> /tmp/cron_ls_py.$$
echo "$UPDATE_CRON" >> /tmp/cron_ls_py.$$
sudo -u "$LIQUIDSOAP_USER" crontab /tmp/cron_ls_py.$$
rm -f /tmp/cron_ls_py.$$
# Also scrub these from root's crontab in case an earlier install put them there.
crontab -l 2>/dev/null | grep -vF "fetch_podcasts.py" | grep -vF "update_playlists.py" > /tmp/cron_root_py.$$ || true
crontab /tmp/cron_root_py.$$
rm -f /tmp/cron_root_py.$$
# ---------------------------------------------------------------------------
# 9. Enable services