#!/usr/bin/with-contenv bash

# Exit if gui
if [ "$YTDL_SUB_TYPE" == "gui" ] ; then
    exit 0
fi

echo "Checking ytdl-sub defaults..."

# copy config
[[ ! -e /config/config.yaml ]] && \
    cp /defaults/config.yaml /config/config.yaml
[[ ! -e /config/subscriptions.yaml ]] && \
    cp /defaults/subscriptions.yaml /config/subscriptions.yaml
[[ ! -d /config/examples ]] && \
    cp -R /defaults/examples /config/

# permissions
chown -R ${PUID:-abc}:${PGID:-abc} \
    /config