#!/bin/sh
set -eu

SRC="/volume2/docker/mh-map-gateway/html"

docker exec homeassistant sh -lc 'mkdir -p /config/www/tesvor-map/archive'

docker cp "$SRC/map.html" homeassistant:/config/www/tesvor-map/map.html
docker cp "$SRC/current.json" homeassistant:/config/www/tesvor-map/current.json
docker cp "$SRC/archive_index.json" homeassistant:/config/www/tesvor-map/archive_index.json
docker cp "$SRC/archive/." homeassistant:/config/www/tesvor-map/archive/

docker exec homeassistant sh -lc '
find /config/www/tesvor-map -type d -exec chmod 755 {} \;
find /config/www/tesvor-map -type f -exec chmod 644 {} \;
'
