mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-20 22:39:14 +02:00
Update 00-folders.sh
This commit is contained in:
@@ -22,6 +22,8 @@ change_folders () {
|
|||||||
# Inform
|
# Inform
|
||||||
bashio::log.info "Setting $TYPE to $CONFIGLOCATION"
|
bashio::log.info "Setting $TYPE to $CONFIGLOCATION"
|
||||||
|
|
||||||
|
if [ "$CONFIGLOCATION" != "$ORIGINALLOCATION" ]; then
|
||||||
|
|
||||||
# Modify files
|
# Modify files
|
||||||
echo "Adapting files"
|
echo "Adapting files"
|
||||||
grep -rl "$ORIGINALLOCATION" /etc/cont-init.d | xargs sed -i "s|$ORIGINALLOCATION|$CONFIGLOCATION|g" || true
|
grep -rl "$ORIGINALLOCATION" /etc/cont-init.d | xargs sed -i "s|$ORIGINALLOCATION|$CONFIGLOCATION|g" || true
|
||||||
@@ -42,6 +44,14 @@ change_folders () {
|
|||||||
fi
|
fi
|
||||||
done
|
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
|
||||||
|
|
||||||
# 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
|
||||||
@@ -53,12 +63,6 @@ change_folders () {
|
|||||||
chown -R "$PUID":"$PGID" "$CONFIGLOCATION"
|
chown -R "$PUID":"$PGID" "$CONFIGLOCATION"
|
||||||
chmod -R 777 "$CONFIGLOCATION"
|
chmod -R 777 "$CONFIGLOCATION"
|
||||||
|
|
||||||
# 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
########################
|
########################
|
||||||
|
|||||||
Reference in New Issue
Block a user