Merge pull request #339 from alexbelgium/create-pull-request/patch-1653178319

Github bot : script beautyshied
This commit is contained in:
Alexandre
2022-05-22 07:00:48 +02:00
committed by GitHub

View File

@@ -13,9 +13,9 @@ PGID=$(bashio::config "PGID")
################### ###################
change_folders () { change_folders () {
CONFIGLOCATION=$1 CONFIGLOCATION=$1
ORIGINALLOCATION=$2 ORIGINALLOCATION=$2
TYPE=$3 TYPE=$3
# Inform # Inform
bashio::log.info "Setting $TYPE to $CONFIGLOCATION" bashio::log.info "Setting $TYPE to $CONFIGLOCATION"
@@ -28,20 +28,20 @@ change_folders () {
sed -i "s=$ORIGINALLOCATION=$CONFIGLOCATION=g" /defaults/* || true sed -i "s=$ORIGINALLOCATION=$CONFIGLOCATION=g" /defaults/* || true
# Adapt sync.conf # Adapt sync.conf
for FILE in "$ORIGINALLOCATION/sync.conf" "$CONFIGLOCATION/sync.conf" "/defaults/sync.conf"; do for FILE in "$ORIGINALLOCATION/sync.conf" "$CONFIGLOCATION/sync.conf" "/defaults/sync.conf"; do
if [ "$TYPE" = "config_location" ]; then if [ "$TYPE" = "config_location" ]; then
[ -f "$FILE" ] && jq --arg variable "$CONFIGLOCATION" '.storage_path = $variable' "$FILE" | sponge "$FILE" [ -f "$FILE" ] && jq --arg variable "$CONFIGLOCATION" '.storage_path = $variable' "$FILE" | sponge "$FILE"
fi fi
if [ "$TYPE" = "data_location" ]; then if [ "$TYPE" = "data_location" ]; then
[ -f "$FILE" ] && jq --arg variable "$CONFIGLOCATION" '.directory_root = $variable' "$FILE" | sponge "$FILE" [ -f "$FILE" ] && jq --arg variable "$CONFIGLOCATION" '.directory_root = $variable' "$FILE" | sponge "$FILE"
[ -f "$FILE" ] && jq --arg variable "$CONFIGLOCATION/downloads" '.files_default_path = $variable' "$FILE" | sponge "$FILE" [ -f "$FILE" ] && jq --arg variable "$CONFIGLOCATION/downloads" '.files_default_path = $variable' "$FILE" | sponge "$FILE"
fi fi
done done
# Create folders # Create folders
echo "Checking if folders exist" echo "Checking if folders exist"
for FOLDER in "$CONFIGLOCATION" "$CONFIGLOCATION"/folders "$CONFIGLOCATION"/mounted_folders "$CONFIGLOCATION"/downloads; do for FOLDER in "$CONFIGLOCATION" "$CONFIGLOCATION"/folders "$CONFIGLOCATION"/mounted_folders "$CONFIGLOCATION"/downloads; do
[ ! -d "$FOLDER" ] && echo "Creating $FOLDER" && mkdir -p "$FOLDER" [ ! -d "$FOLDER" ] && echo "Creating $FOLDER" && mkdir -p "$FOLDER"
done done
# Set permissions # Set permissions
@@ -50,9 +50,9 @@ change_folders () {
# Transfer files # Transfer files
if [ -d "$ORIGINALLOCATION" ] && [ "$(ls -A "$ORIGINALLOCATION" 2>/dev/null)" ]; then if [ -d "$ORIGINALLOCATION" ] && [ "$(ls -A "$ORIGINALLOCATION" 2>/dev/null)" ]; then
echo "Files were existing in $ORIGINALLOCATION, they will be moved to $CONFIGLOCATION" echo "Files were existing in $ORIGINALLOCATION, they will be moved to $CONFIGLOCATION"
mv "$ORIGINALLOCATION"/* "$CONFIGLOCATION"/ mv "$ORIGINALLOCATION"/* "$CONFIGLOCATION"/
rmdir "$ORIGINALLOCATION" rmdir "$ORIGINALLOCATION"
fi fi
} }