mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-07-21 05:20:31 +02:00
Update 01-structure.sh
This commit is contained in:
@@ -62,12 +62,16 @@ if [[ "${CURRENT_BIRDSONGS_FOLDER%/}" != "${$BIRDSONGS_FOLDER%/}" ]]; then
|
|||||||
cp -rnf "$CURRENT_BIRDSONGS_FOLDER"/* "$BIRDSONGS_FOLDER"/
|
cp -rnf "$CURRENT_BIRDSONGS_FOLDER"/* "$BIRDSONGS_FOLDER"/
|
||||||
mv "${CURRENT_BIRDSONGS_FOLDER%/}" "${CURRENT_BIRDSONGS_FOLDER%/}_migrated"
|
mv "${CURRENT_BIRDSONGS_FOLDER%/}" "${CURRENT_BIRDSONGS_FOLDER%/}_migrated"
|
||||||
fi
|
fi
|
||||||
# Define the SQLite database file
|
# Adapt the database
|
||||||
DB_FILE="your_database.db"
|
if [ -f /config/birdnet.db ]; then
|
||||||
# SQL query to update the paths
|
# SQL query to update the paths
|
||||||
SQL_QUERY="UPDATE notes SET clip_name = REPLACE(clip_name, 'clips/', '/zlkrj/zer');"
|
bashio::log.warning "Modifying database paths from $CURRENT_BIRDSONGS_FOLDER to $BIRDSONGS_FOLDER. A backup will be created before"
|
||||||
|
cp /config/birdnet.db /config/birdnet.db_$(date +%Y%m%d_%H%M%S)
|
||||||
|
SQL_QUERY="UPDATE notes SET clip_name = REPLACE(clip_name, '^${CURRENT_BIRDSONGS_FOLDER}/', '${BIRDSONGS_FOLDER%/}/');"
|
||||||
|
|
||||||
# Execute the query using sqlite3
|
# Execute the query using sqlite3
|
||||||
sqlite3 "$DB_FILE" "$SQL_QUERY"
|
sqlite3 /config/birdnet.db "$SQL_QUERY"
|
||||||
|
|
||||||
# Check if the operation was successful
|
# Check if the operation was successful
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "Paths have been successfully updated."
|
echo "Paths have been successfully updated."
|
||||||
@@ -75,6 +79,7 @@ if [[ "${CURRENT_BIRDSONGS_FOLDER%/}" != "${$BIRDSONGS_FOLDER%/}" ]]; then
|
|||||||
bashio::log.warning "An error occurred while updating the paths."
|
bashio::log.warning "An error occurred while updating the paths."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# Correct Defaults
|
# Correct Defaults
|
||||||
|
|||||||
Reference in New Issue
Block a user