27 lines
817 B
Bash
27 lines
817 B
Bash
#!/bin/sh
|
|
set -e
|
|
|
|
ZIP_URL="$(grep -o '"store_component_zip"[[:space:]]*:[[:space:]]*"[^"]*"' /data/options.json | sed 's/.*"store_component_zip"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/')"
|
|
TARGET="/config/custom_components/bahmcloud_store"
|
|
|
|
echo "Downloading: $ZIP_URL"
|
|
mkdir -p /tmp/storezip
|
|
curl -L --fail "$ZIP_URL" -o /tmp/storezip/store.zip
|
|
|
|
rm -rf /tmp/storezip/extract
|
|
mkdir -p /tmp/storezip/extract
|
|
unzip -q /tmp/storezip/store.zip -d /tmp/storezip/extract
|
|
|
|
SRC="$(find /tmp/storezip/extract -type d -path "*/custom_components/bahmcloud_store" | head -n 1)"
|
|
if [ -z "$SRC" ]; then
|
|
echo "ERROR: custom_components/bahmcloud_store not found in zip"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Installing to: $TARGET"
|
|
rm -rf "$TARGET"
|
|
mkdir -p "$(dirname "$TARGET")"
|
|
cp -a "$SRC" "$TARGET"
|
|
|
|
echo "Done. Please restart Home Assistant."
|