Update 00-folders.sh

This commit is contained in:
Alexandre
2022-05-18 13:51:33 +02:00
committed by GitHub
parent a35537a76d
commit 7640f00e87

View File

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