Check if configuration file exists

This commit is contained in:
Sumit Khanna 2021-04-29 11:51:31 -04:00
parent 3ad17d54f3
commit f9891dbeef
2 changed files with 23 additions and 18 deletions

View File

@ -20,8 +20,7 @@ RUN addgroup -g 1000 -S invidious && \
adduser -u 1000 -S invidious -G invidious
COPY ./assets/ ./assets/
COPY --chown=invidious ./config/config.* ./config/
RUN mv -n config/config.example.yml config/config.yml
RUN sed -i 's/host: \(127.0.0.1\|localhost\)/host: postgres/' config/config.yml
COPY ./config/sql/ ./config/sql/
COPY ./locales/ ./locales/
COPY --from=builder /invidious/invidious .

View File

@ -1,23 +1,29 @@
#!/bin/sh
echo "Configuring Invidious"
CONF_FILE="/invidious/config/config.yml"
cat <<EOF > /invidious/config/config.yml
channel_threads: $INVIDIOUS_CHANNEL_THREADS
check_tables: $INVIDIOUS_CHECK_TABLES
feed_threads: $INVIDIOUS_FEED_THREADS
db:
user: $POSTGRES_USER
password: $POSTGRES_PASS
host: $POSTGRES_HOST
port: $POSTGRES_PORT
dbname: $POSTGRES_DB
full_refresh: $INVIDIOUS_FULL_REFRESH
https_only: $INVIDIOUS_HTTPS_ONLY
domain: $INVIDIOUS_DOMAIN
registration_enabled: $INVIDIOUS_REGISTRATION_ENABLED
disable_proxy: $INVIDIOUS_DISABLE_PROXY
if [ -f "$CONF_FILE" ]; then
echo "Existing configuration found. Skipping environment variable based conifg..."
else
echo "Configuring Invidious"
cat <<EOF > /invidious/config/config.yml
channel_threads: $INVIDIOUS_CHANNEL_THREADS
check_tables: $INVIDIOUS_CHECK_TABLES
feed_threads: $INVIDIOUS_FEED_THREADS
db:
user: $POSTGRES_USER
password: $POSTGRES_PASS
host: $POSTGRES_HOST
port: $POSTGRES_PORT
dbname: $POSTGRES_DB
full_refresh: $INVIDIOUS_FULL_REFRESH
https_only: $INVIDIOUS_HTTPS_ONLY
domain: $INVIDIOUS_DOMAIN
registration_enabled: $INVIDIOUS_REGISTRATION_ENABLED
disable_proxy: $INVIDIOUS_DISABLE_PROXY
EOF
fi
# kemal is the hardcoded postgres username
for i in /invidious/config/sql/*.sql; do sed -i s/kemal/$POSTGRES_USER/g $i; done