Files
hassio-addons/tdarr/rootfs/etc/cont-init.d/00-configuration.sh
2022-03-25 15:09:37 +01:00

45 lines
1.1 KiB
Bash

#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
#################
# Set PUID PGID #
#################
# Get from options
PGID=$(bashio::config 'PGID')
PUID=$(bashio::config 'PUID')
# If blank, set 0
[[ "$PUID" = "null" ]] && PUID=0
[[ "$PGID" = "null" ]] && PGID=0
# Write in permission file
sed -i "1a PGID=$PGID" /etc/cont-init.d/01-setup-perms
sed -i "1a PUID=$PUID" /etc/cont-init.d/01-setup-perms
# Information
bashio::log.info "Setting PUID=$PUID, PGID=$PGID"
#####################
# Set Configuration #
#####################
# Config location
CONFIGLOCATION="$(bashio::config 'CONFIG_LOCATION')"
# Create folder
mkdir -p "$CONFIGLOCATION"
# Rename base folder
mv /app /tdarr
sed -i "s|/app|/tdarr|g" /etc/cont-init.d/*
sed -i "s|/app|/tdarr|g" /etc/services.d/*/run
# Symlink configs
[ -d /tdarr/configs ] && rm -r /tdarr/configs
ln -snf "$CONFIGLOCATION" /tdarr/configs
# Symlink server data
[ -d /tdarr/server/Tdarr ] && rm -r /tdarr/server/Tdarr
ln -snf "$CONFIGLOCATION/server" /tdarr/server/Tdarr
# Text
bashio::log.info "Setting config location to $CONFIGLOCATION"