27 lines
745 B
Bash
27 lines
745 B
Bash
#!/bin/sh
|
|
set -e
|
|
|
|
ZIP_URL="$(cat /data/options.json | sed -n 's/.*"store_component_zip"[ ]*:[ ]*"\([^"]*\)".*/\1/p')"
|
|
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."
|