FreshRSS / start.sh
darkfire514's picture
Create start.sh
248f01f verified
Raw History Blame Contribute Delete
1.14 kB
#!/bin/bash
set -euo pipefail
cd /app
unset GITHUB_TOKEN
data_dir="${WERSS_DATA_DIR:-/data}"
case "$data_dir" in /*) ;; *) echo "WERSS_DATA_DIR must be an absolute path" >&2; exit 1;; esac
mkdir -p "$data_dir"
if [ ! -w "$data_dir" ]; then
echo "Data directory is not writable by UID 1000: $data_dir" >&2
exit 1
fi
# Do not remove an existing data directory with user files in it.
if [ "$(readlink -f /app/data)" != "$(readlink -f "$data_dir")" ]; then
if [ -L /app/data ]; then
rm /app/data
elif [ -d /app/data ]; then
rmdir /app/data || { echo "Refusing to replace non-empty /app/data" >&2; exit 1; }
fi
ln -s "$data_dir" /app/data
fi
if [ ! -f "$data_dir/config.yaml" ]; then
cp /app/config.template.yaml "$data_dir/config.yaml"
fi
if [ ! -e /app/config.yaml ] && [ ! -L /app/config.yaml ]; then
ln -s "$data_dir/config.yaml" /app/config.yaml
fi
# Template/environment values remain runtime settings; no secrets are baked
# into the image and existing persistent config is never overwritten.
printf 'WeRSS Docker startup: port=%s, data=%s\n' "${PORT:-7860}" "$data_dir"
exec /app/start.sh