refactor: use config.json with MVC architecture
This commit is contained in:
@@ -9,12 +9,28 @@ KIOSK_REMOTE="jgitta@100.64.0.1"
|
||||
REPO_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
HOME_SRC="$REPO_DIR/home-screen-index.html"
|
||||
HOME_DST="/home/jgitta/kiosk-home/index.html"
|
||||
CONFIG_SRC="$REPO_DIR/config.json"
|
||||
COMMIT_MSG="${1:-deploy: update from kiosk-dev $(date +%Y-%m-%d)}"
|
||||
|
||||
inject_config() {
|
||||
local src="$1"
|
||||
local dst="$2"
|
||||
local config="$3"
|
||||
|
||||
if [ -f "$config" ]; then
|
||||
local config_json=$(cat "$config" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g' | tr '\n' ' ')
|
||||
sed "s|const config = {.*};|const config = $config_json;|" "$src" > "$dst"
|
||||
echo " Injected config.json into home screen"
|
||||
else
|
||||
cp "$src" "$dst"
|
||||
echo " WARNING: config.json missing — deploying without config injection"
|
||||
fi
|
||||
}
|
||||
|
||||
echo "==> Syncing home screen to $HOME_DST..."
|
||||
if [ -f "$HOME_SRC" ]; then
|
||||
mkdir -p "$(dirname "$HOME_DST")"
|
||||
cp "$HOME_SRC" "$HOME_DST"
|
||||
inject_config "$HOME_SRC" "$HOME_DST" "$CONFIG_SRC"
|
||||
chown jgitta:jgitta "$HOME_DST" 2>/dev/null || true
|
||||
else
|
||||
echo " WARNING: $HOME_SRC missing — home screen not updated"
|
||||
@@ -44,7 +60,9 @@ if [ -n "$KIOSK" ]; then
|
||||
ssh "$KIOSK" "
|
||||
cd /home/jgitta/kiosk-browser
|
||||
git pull
|
||||
cp home-screen-index.html /home/jgitta/kiosk-home/index.html
|
||||
# Inject config at deploy time
|
||||
config_json=\$(cat config.json | sed 's/\\\\/\\\\\\\\/g' | sed 's/\"/\\\\\"/g' | tr '\n' ' ')
|
||||
sed \"s|const config = {.*};|const config = \$config_json;|\" home-screen-index.html > /home/jgitta/kiosk-home/index.html
|
||||
/usr/local/bin/kiosk-restart
|
||||
"
|
||||
echo " Production updated."
|
||||
|
||||
Reference in New Issue
Block a user