mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-11 10:21:02 +01:00
Update
This commit is contained in:
@@ -6,7 +6,7 @@ set -e
|
||||
for cmd in yq amixer; do
|
||||
command -v "$cmd" >/dev/null 2>&1 || { bashio::log.fatal "$cmd is required but not installed. Exiting."; exit 1; }
|
||||
done
|
||||
|
||||
|
||||
# Default Variables
|
||||
DEFAULT_BIRDSONGS_FOLDER="/data/clips/"
|
||||
CONFIG_LOCATIONS=("/config/config.yaml" "/internal/conf/config.yaml")
|
||||
@@ -44,6 +44,21 @@ if ! mkdir -p "$BIRDSONGS_FOLDER"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Migrate Files if Folder Changed
|
||||
if [[ "$CURRENT_BIRDSONGS_FOLDER" != "$BIRDSONGS_FOLDER" ]]; then
|
||||
bashio::log.warning "Birdsongs folder changed from $CURRENT_BIRDSONGS_FOLDER to $BIRDSONGS_FOLDER"
|
||||
if [[ -d "$CURRENT_BIRDSONGS_FOLDER" && "$(ls -A "$CURRENT_BIRDSONGS_FOLDER")" ]]; then
|
||||
bashio::log.warning "Migrating files from $CURRENT_BIRDSONGS_FOLDER to $BIRDSONGS_FOLDER"
|
||||
cp -rnf "$CURRENT_BIRDSONGS_FOLDER"/* "$BIRDSONGS_FOLDER"/
|
||||
mv "$CURRENT_BIRDSONGS_FOLDER" "${CURRENT_BIRDSONGS_FOLDER}_migrated"
|
||||
fi
|
||||
for configloc in "${CONFIG_LOCATIONS[@]}"; do
|
||||
if [ -f "$configloc" ]; then
|
||||
yq -i -y ".realtime.audio.export.path = \"$BIRDSONGS_FOLDER/\"" "$configloc"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Volume Adjustment
|
||||
current_volume="$(amixer sget Capture | grep -oP '\[\d+%\]' | tr -d '[]%' | head -1 2>/dev/null || echo "100")"
|
||||
if [[ "$current_volume" -eq 0 ]]; then
|
||||
|
||||
Reference in New Issue
Block a user