mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-09 09:05:55 +02:00
fix: auto-fix linting issues
This commit is contained in:
committed by
github-actions[bot]
parent
3539f328fb
commit
f5428e0950
@@ -8,12 +8,12 @@ config_location="$(bashio::config 'config_location')"
|
||||
config_location="${config_location/\/config/\/homeassistant}"
|
||||
|
||||
if [ -f "$config_location/config.yaml" ] && [ ! -f "$config_location/migrated" ]; then
|
||||
bashio::log.warning "Migrating config.yaml"
|
||||
cp -rf "/homeassistant/addons_config/$slug"/* /config/ || true
|
||||
echo "Migrated to internal config folder accessible at /addon_configs/xxx-$slug" >"/homeassistant/addons_config/$slug/migrated"
|
||||
bashio::log.warning "Migrating config.yaml"
|
||||
cp -rf "/homeassistant/addons_config/$slug"/* /config/ || true
|
||||
echo "Migrated to internal config folder accessible at /addon_configs/xxx-$slug" > "/homeassistant/addons_config/$slug/migrated"
|
||||
fi
|
||||
|
||||
if [ -f "/homeassistant/addons_autoscripts/$slug.sh" ]; then
|
||||
bashio::log.warning "Migrating autoscript"
|
||||
mv /homeassistant/addons_autoscripts/$slug.sh /config/ || true
|
||||
bashio::log.warning "Migrating autoscript"
|
||||
mv /homeassistant/addons_autoscripts/$slug.sh /config/ || true
|
||||
fi
|
||||
|
||||
@@ -14,48 +14,48 @@ PGID=$(bashio::config "PGID")
|
||||
###################
|
||||
|
||||
change_folders() {
|
||||
CONFIGLOCATION=$1
|
||||
ORIGINALLOCATION=$2
|
||||
TYPE=$3
|
||||
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" = "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" = "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"
|
||||
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ change_folders "$(bashio::config 'downloads_location')" "/share/resiliosync_down
|
||||
|
||||
# Ensure configuration is in /config
|
||||
if [[ ! -e /config/sync.conf ]]; then
|
||||
cp /defaults/sync.conf /config/sync.conf
|
||||
cp /defaults/sync.conf /config/sync.conf
|
||||
fi
|
||||
jq '.storage_path = "/config"' /config/sync.conf | sponge /config/sync.conf
|
||||
chown -R "$PUID":"$PGID" /config
|
||||
@@ -79,8 +79,8 @@ chmod -R 777 /config
|
||||
DIRS_TO_ADD=("/backup" "/media" "/share" "/addons")
|
||||
echo "Checking dir_whitelist in /config/sync.json"
|
||||
for DIR in "${DIRS_TO_ADD[@]}"; do
|
||||
if ! jq -e ".webui.dir_whitelist | index(\"$DIR\")" /config/sync.json >/dev/null; then
|
||||
echo "Adding $DIR to dir_whitelist"
|
||||
jq ".webui.dir_whitelist += [\"$DIR\"]" /config/sync.json | sponge /config/sync.json
|
||||
fi
|
||||
if ! jq -e ".webui.dir_whitelist | index(\"$DIR\")" /config/sync.json > /dev/null; then
|
||||
echo "Adding $DIR to dir_whitelist"
|
||||
jq ".webui.dir_whitelist += [\"$DIR\"]" /config/sync.json | sponge /config/sync.json
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user