diff --git a/resiliosync/rootfs/etc/cont-init.d/00-folders.sh b/resiliosync/rootfs/etc/cont-init.d/00-folders.sh index a9333f67d..c6ffef075 100644 --- a/resiliosync/rootfs/etc/cont-init.d/00-folders.sh +++ b/resiliosync/rootfs/etc/cont-init.d/00-folders.sh @@ -1,10 +1,6 @@ #!/usr/bin/with-contenv bashio # shellcheck shell=bash -#Disable script -echo "script is not enabled yet" -exit 0 - ############### # Define user # ############### @@ -12,60 +8,41 @@ exit 0 PUID=$(bashio::config "PUID") PGID=$(bashio::config "PGID") -####################### -# Adapt data location # -####################### +################### +# Create function # +################### -CONFIGLOCATION=$(bashio::config 'data_location') -ORIGINALLOCATION="/share/resiliosync" +change_folders (change_fold) { + CONFIGLOCATION=$1 + ORIGINALLOCATION=$2 + TYPE=$3 + + if [ ! -d "$CONFIGLOCATION" ]; then -if [ ! -d "$CONFIGLOCATION" ]; then + # Inform + bashio::log.info "Setting $TYPE location to $CONFIGLOCATION" - # 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 - # 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" - # Create folders - [ ! -d "$CONFIGLOCATION" ] && echo "Creating $CONFIGLOCATION" && mkdir -p "$CONFIGLOCATION" + # Transfer files + [ -d "$,ORIGINALLOCATION" ] && echo "Moving files to $CONFIGLOCATION" && mv "$ORIGINALLOCATION"/* "$CONFIGLOCATION"/ && rmdir "$ORIGINALLOCATION" - # 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" - # Set permissions - echo "Setting ownership to $PUID:$PGID" && chown -R "$PUID":"$PGID" "$CONFIGLOCATION" + else + bashio::log.nok "Your $TYPE $CONFIGLOCATION doesn't exists" + exit 1 + fi +} -else - bashio::log.nok "Your data_location $CONFIGLOCATION doesn't exists" - exit 1 -fi +######################## +# Change data location # +######################## -######################### -# 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 +change_folders "$(bashio::config 'data_location')" "/share/resiliosync" "data_location" +change_folders "$(bashio::config 'config_location')" "/share/resiliosync_config" "config_location"