mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-11 02:11:01 +01:00
fix: auto-fix linting issues
This commit is contained in:
committed by
github-actions[bot]
parent
e5adbd266f
commit
f728166b14
@@ -13,52 +13,52 @@ PGID=$(bashio::config "PGID")
|
||||
# Create function #
|
||||
###################
|
||||
|
||||
change_folders () {
|
||||
CONFIGLOCATION=$1
|
||||
ORIGINALLOCATION=$2
|
||||
TYPE=$3
|
||||
change_folders() {
|
||||
CONFIGLOCATION=$1
|
||||
ORIGINALLOCATION=$2
|
||||
TYPE=$3
|
||||
|
||||
# Inform
|
||||
bashio::log.info "Setting $TYPE to $CONFIGLOCATION"
|
||||
# Inform
|
||||
bashio::log.info "Setting $TYPE to $CONFIGLOCATION"
|
||||
|
||||
if [ "$CONFIGLOCATION" != "$ORIGINALLOCATION" ]; then
|
||||
if [ "$CONFIGLOCATION" != "$ORIGINALLOCATION" ]; then
|
||||
|
||||
# Modify files
|
||||
echo "Adapting files"
|
||||
# shellcheck disable=SC2013,SC2086
|
||||
for file in $(grep -ril "$ORIGINALLOCATION" /etc /defaults); do sed -i "s=$ORIGINALLOCATION=$CONFIGLOCATION=g" $file; done
|
||||
# Modify files
|
||||
echo "Adapting files"
|
||||
# shellcheck disable=SC2013,SC2086
|
||||
for file in $(grep -ril "$ORIGINALLOCATION" /etc /defaults); do sed -i "s=$ORIGINALLOCATION=$CONFIGLOCATION=g" $file; done
|
||||
|
||||
# Adapt sync.conf
|
||||
for FILE in "$ORIGINALLOCATION/sync.conf" "$CONFIGLOCATION/sync.conf" "/defaults/sync.conf"; do
|
||||
if [ "$TYPE" = "config_location" ]; then
|
||||
[ -f "$FILE" ] && jq --arg variable "$CONFIGLOCATION" '.storage_path = $variable' "$FILE" | sponge "$FILE"
|
||||
fi
|
||||
if [ "$TYPE" = "data_location" ]; then
|
||||
[ -f "$FILE" ] && jq --arg variable "$CONFIGLOCATION" '.directory_root = $variable' "$FILE" | sponge "$FILE"
|
||||
fi
|
||||
if [ "$TYPE" = "downloads_location" ]; then
|
||||
[ -f "$FILE" ] && jq --arg variable "$CONFIGLOCATION" '.files_default_path = $variable' "$FILE" | sponge "$FILE"
|
||||
fi
|
||||
done
|
||||
# Adapt sync.conf
|
||||
for FILE in "$ORIGINALLOCATION/sync.conf" "$CONFIGLOCATION/sync.conf" "/defaults/sync.conf"; do
|
||||
if [ "$TYPE" = "config_location" ]; then
|
||||
[ -f "$FILE" ] && jq --arg variable "$CONFIGLOCATION" '.storage_path = $variable' "$FILE" | sponge "$FILE"
|
||||
fi
|
||||
if [ "$TYPE" = "data_location" ]; then
|
||||
[ -f "$FILE" ] && jq --arg variable "$CONFIGLOCATION" '.directory_root = $variable' "$FILE" | sponge "$FILE"
|
||||
fi
|
||||
if [ "$TYPE" = "downloads_location" ]; then
|
||||
[ -f "$FILE" ] && jq --arg variable "$CONFIGLOCATION" '.files_default_path = $variable' "$FILE" | sponge "$FILE"
|
||||
fi
|
||||
done
|
||||
|
||||
# Transfer files
|
||||
if [ -d "$ORIGINALLOCATION" ] && [ "$(ls -A "$ORIGINALLOCATION" 2>/dev/null)" ]; then
|
||||
echo "Files were existing in $ORIGINALLOCATION, they will be moved to $CONFIGLOCATION"
|
||||
mv "$ORIGINALLOCATION"/* "$CONFIGLOCATION"/
|
||||
rmdir "$ORIGINALLOCATION"
|
||||
fi 2>/dev/null || true
|
||||
fi
|
||||
# Transfer files
|
||||
if [ -d "$ORIGINALLOCATION" ] && [ "$(ls -A "$ORIGINALLOCATION" 2>/dev/null)" ]; then
|
||||
echo "Files were existing in $ORIGINALLOCATION, they will be moved to $CONFIGLOCATION"
|
||||
mv "$ORIGINALLOCATION"/* "$CONFIGLOCATION"/
|
||||
rmdir "$ORIGINALLOCATION"
|
||||
fi 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Create folders
|
||||
echo "Checking if folders exist"
|
||||
for FOLDER in "$CONFIGLOCATION" "$CONFIGLOCATION"/folders "$CONFIGLOCATION"/mounted_folders "$CONFIGLOCATION"/downloads; do
|
||||
[ ! -d "$FOLDER" ] && echo "Creating $FOLDER" && mkdir -p "$FOLDER"
|
||||
done
|
||||
# Create folders
|
||||
echo "Checking if folders exist"
|
||||
for FOLDER in "$CONFIGLOCATION" "$CONFIGLOCATION"/folders "$CONFIGLOCATION"/mounted_folders "$CONFIGLOCATION"/downloads; do
|
||||
[ ! -d "$FOLDER" ] && echo "Creating $FOLDER" && mkdir -p "$FOLDER"
|
||||
done
|
||||
|
||||
# Set permissions
|
||||
echo "Setting ownership to $PUID:$PGID"
|
||||
chown -R "$PUID":"$PGID" "$CONFIGLOCATION"
|
||||
chmod -R 777 "$CONFIGLOCATION"
|
||||
# Set permissions
|
||||
echo "Setting ownership to $PUID:$PGID"
|
||||
chown -R "$PUID":"$PGID" "$CONFIGLOCATION"
|
||||
chmod -R 777 "$CONFIGLOCATION"
|
||||
|
||||
}
|
||||
|
||||
@@ -72,5 +72,5 @@ change_folders "$(bashio::config 'data_location')" "/share/resiliosync" "data_lo
|
||||
change_folders "$(bashio::config 'downloads_location')" "/share/resiliosync_downloads" "downloads_location"
|
||||
|
||||
if [[ ! -e "$(bashio::config 'config_location')"/sync.conf ]]; then
|
||||
cp /defaults/sync.conf "$(bashio::config 'config_location')"/sync.conf
|
||||
cp /defaults/sync.conf "$(bashio::config 'config_location')"/sync.conf
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user