mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-01 05:14:04 +02:00
Update 00-folders.sh
This commit is contained in:
@@ -5,37 +5,67 @@
|
|||||||
echo "script is not enabled yet"
|
echo "script is not enabled yet"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
# Define user
|
###############
|
||||||
|
# Define user #
|
||||||
|
###############
|
||||||
|
|
||||||
PUID=$(bashio::config "PUID")
|
PUID=$(bashio::config "PUID")
|
||||||
PGID=$(bashio::config "PGID")
|
PGID=$(bashio::config "PGID")
|
||||||
|
|
||||||
# Check data location
|
#######################
|
||||||
DATALOCATION=$(bashio::config 'data_location')
|
# Adapt data location #
|
||||||
if [[ "$DATALOCATION" = "null" || -z "$DATALOCATION" ]]; then DATALOCATION=/config/addons_config/${HOSTNAME#*-}; fi
|
#######################
|
||||||
|
|
||||||
# Check config location
|
CONFIGLOCATION=$(bashio::config 'data_location')
|
||||||
LOCATION=$(bashio::config 'config_location')
|
ORIGINALLOCATION="/share/resiliosync"
|
||||||
if [[ "$CONFIGLOCATION" = "null" || -z "$CONFIGLOCATION" ]]; then CONFIGLOCATION=/config/addons_config/${HOSTNAME#*-}_config; fi
|
|
||||||
|
|
||||||
|
if [ ! -d "$CONFIGLOCATION" ]; then
|
||||||
|
|
||||||
# Set data location
|
# Inform
|
||||||
bashio::log.info "Setting data location to $LOCATION"
|
bashio::log.info "Setting config location to $CONFIGLOCATION"
|
||||||
sed -i "s|/config|$LOCATION|g" /etc/services.d/jellyfin/run
|
|
||||||
sed -i "s|/config|$LOCATION|g" /etc/cont-init.d/10-adduser
|
|
||||||
sed -i "s|/config|$LOCATION|g" /etc/cont-init.d/30-config
|
|
||||||
|
|
||||||
echo "Creating $LOCATION"
|
# Modify files
|
||||||
mkdir -p "$LOCATION"
|
sed -i "s/$ORIGINALLOCATION/$CONFIGLOCATION|| true/g" /etc/cont-init.d/10-adduser || true
|
||||||
|
|
||||||
bashio::log.info "Setting ownership to $PUID:$PGID"
|
# Create folders
|
||||||
chown "$PUID":"$PGID" "$LOCATION"
|
[ ! -d "$CONFIGLOCATION" ] && echo "Creating $CONFIGLOCATION" && mkdir -p "$CONFIGLOCATION"
|
||||||
|
|
||||||
|
# Transfer files
|
||||||
|
[ -d "$,ORIGINALLOCATION" ] && echo "Moving synced files to $CONFIGLOCATION" && mv "$ORIGINALLOCATION"/* "$CONFIGLOCATION"/ && rmdir "$ORIGINALLOCATION"
|
||||||
|
|
||||||
echo "Checking folders"
|
# Set permissions
|
||||||
LOCATION="/share/resiliosync"
|
echo "Setting ownership to $PUID:$PGID" && chown -R "$PUID":"$PGID" "$CONFIGLOCATION"
|
||||||
mkdir -p "$LOCATION"/folders
|
|
||||||
mkdir -p "$LOCATION"/mounted_folders
|
|
||||||
mkdir -p /share/resiliosync_config
|
|
||||||
|
|
||||||
echo "Checking permissions"
|
else
|
||||||
chown -R "$(id -u):$(id -g)" "$LOCATION"
|
bashio::log.nok "Your data_location $CONFIGLOCATION doesn't exists"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# Adapt config location #
|
||||||
|
#########################
|
||||||
|
|
||||||
|
CONFIGLOCATION=$(bashio::config 'config_location')
|
||||||
|
ORIGINALLOCATION="/share/resiliosync_config"
|
||||||
|
|
||||||
|
if [ ! -d "$CONFIGLOCATION" ]; then
|
||||||
|
|
||||||
|
# Inform
|
||||||
|
bashio::log.info "Setting config location to $CONFIGLOCATION"
|
||||||
|
|
||||||
|
# Modify files
|
||||||
|
sed -i "s/$ORIGINALLOCATION/$CONFIGLOCATION|| true/g" /etc/cont-init.d/10-adduser || true
|
||||||
|
|
||||||
|
# Create folders
|
||||||
|
[ ! -d "$CONFIGLOCATION" ] && echo "Creating $CONFIGLOCATION" && mkdir -p "$CONFIGLOCATION"
|
||||||
|
|
||||||
|
# Transfer files
|
||||||
|
[ -d "$,ORIGINALLOCATION" ] && echo "Moving synced files to $CONFIGLOCATION" && mv "$ORIGINALLOCATION"/* "$CONFIGLOCATION"/ && rmdir "$ORIGINALLOCATION"
|
||||||
|
|
||||||
|
# Set permissions
|
||||||
|
echo "Setting ownership to $PUID:$PGID" && chown -R "$PUID":"$PGID" "$CONFIGLOCATION"
|
||||||
|
|
||||||
|
else
|
||||||
|
bashio::log.nok "Your config_location $CONFIGLOCATION doesn't exists"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user