File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,11 +56,34 @@ SERVER_URL=$SERVER_URL
5656FLOOR_ID=$FLOOR_ID
5757EOF
5858
59- # ── 3. Copy scripts ──
59+ # ── 3. Copy or fetch helper scripts ──
6060echo " [3/5] Installing scripts..."
61- SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
62- cp " $SCRIPT_DIR /kiosk.sh" " $INSTALL_DIR /kiosk.sh"
63- cp " $SCRIPT_DIR /update.sh" " $INSTALL_DIR /update.sh"
61+
62+ # determine the directory containing this script. When the file is
63+ # executed via stdin (e.g. curl | bash) BASH_SOURCE may not be set, so
64+ # fall back to $0. Avoid unbound-variable errors by testing with -v.
65+ if [[ -v BASH_SOURCE ]]; then
66+ SCRIPT_PKG=" ${BASH_SOURCE[0]} "
67+ else
68+ SCRIPT_PKG=" $0 "
69+ fi
70+ SCRIPT_DIR=" $( cd " $( dirname " $SCRIPT_PKG " ) " && pwd) "
71+
72+ # helper to either copy from local tree or download a fresh copy
73+ fetch_or_copy () {
74+ local name=" $1 " url
75+ url=" https://raw.githubusercontent.com/IN4300-Embedded-Systems-Project/B22_Group06/main/pi-node/$name "
76+
77+ if [[ -f " $SCRIPT_DIR /$name " ]]; then
78+ cp " $SCRIPT_DIR /$name " " $INSTALL_DIR /$name "
79+ else
80+ echo " -> fetching $name from remote"
81+ curl -sSL " $url " -o " $INSTALL_DIR /$name "
82+ fi
83+ }
84+
85+ fetch_or_copy kiosk.sh
86+ fetch_or_copy update.sh
6487chmod +x " $INSTALL_DIR " /* .sh
6588
6689# ── 4. Install systemd services ──
Original file line number Diff line number Diff line change @@ -6,8 +6,12 @@ cd "$(dirname "${BASH_SOURCE[0]}")/.."
66
77echo " === Deploying Display System ==="
88
9- # Load .env if exists
10- [[ -f .env ]] && { set -a; source .env; set +a; }
9+ # Load .env if exists (strip any Windows CRs first so bash won't complain)
10+ if [[ -f .env ]]; then
11+ # remove stray carriage returns in case the file has CRLF line endings
12+ sed -i ' s/\r$//' .env || true
13+ set -a; source .env; set +a
14+ fi
1115
1216# Build and start
1317docker compose -f deploy/docker-compose.yml up -d --build
You can’t perform that action at this time.
0 commit comments