Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deploy/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0
0.2.0
16 changes: 16 additions & 0 deletions deploy/scripts/rerun-gsm-fastapi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -euo pipefail

SELF=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
source "$SELF/lib/deploy-common.sh"

current=$(readlink -f "$SAPOT_ROOT/releases/current" 2>/dev/null || true)
if [ -z "$current" ]; then
log_error "No current release found at $SAPOT_ROOT/releases/current"
exit 1
fi

log_info "Applying compose configuration for gsm-fastapi..."
compose "$current" up -d gsm-fastapi

log_info "gsm-fastapi container has been restarted."
67 changes: 67 additions & 0 deletions deploy/scripts/update-arduino-port.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
set -euo pipefail

SELF=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
source "$SELF/lib/deploy-common.sh"

shopt -s nullglob
detected_ports=(/dev/ttyACM* /dev/ttyUSB*)
shopt -u nullglob

hardware=false
selected_port=""

if [ ${#detected_ports[@]} -eq 0 ]; then
read -r -p "No GSM Arduino detected. Enter port path manually or leave empty to skip: " answer
if [ -n "$answer" ]; then
selected_port="$answer"
hardware=true
fi
elif [ ${#detected_ports[@]} -eq 1 ]; then
read -r -p "Found GSM Arduino at ${detected_ports[0]}. Use this? [Y/n/custom] " answer
if [[ "$answer" =~ ^[Yy]$ ]] || [ -z "$answer" ]; then
selected_port="${detected_ports[0]}"
hardware=true
elif [[ "$answer" =~ ^[Cc]ustom$ ]]; then
read -r -p "Enter custom port path: " selected_port
if [ -n "$selected_port" ]; then hardware=true; fi
fi
else
echo "Multiple GSM Arduino devices found:"
for i in "${!detected_ports[@]}"; do
echo " $((i+1))) ${detected_ports[$i]}"
done
read -r -p "Select a number, type a custom path, or leave empty to skip: " answer
if [[ "$answer" =~ ^[0-9]+$ ]] && [ "$answer" -ge 1 ] && [ "$answer" -le "${#detected_ports[@]}" ]; then
selected_port="${detected_ports[$((answer-1))]}"
hardware=true
elif [ -n "$answer" ]; then
selected_port="$answer"
hardware=true
fi
fi

if [ "$hardware" = true ] && [ -n "$selected_port" ]; then
sed -i "s|^GSM_ARDUINO_PORT=.*|GSM_ARDUINO_PORT=$selected_port|" "$SAPOT_ROOT/shared/gsm-arduino.env"
sed -i "s|^SERIAL_PORT=.*|SERIAL_PORT=$selected_port|" "$SAPOT_ROOT/shared/gsm-fastapi.env"
log_info "Updated port configuration to $selected_port"
else
log_info "No hardware port selected. GSM hardware will be disabled."
fi

# Update state.json
python3 - "$SAPOT_ROOT/shared/state.json" "$hardware" <<'PY'
import json, sys, os
path = sys.argv[1]
if not os.path.exists(path):
sys.exit(0)
with open(path, 'r') as f:
state = json.load(f)
state["gsmHardwarePresent"] = sys.argv[2] == "true"
tmp = path + ".tmp"
with open(tmp, 'w') as f:
json.dump(state, f, indent=2)
os.replace(tmp, path)
PY

log_info "State updated successfully. You can now rerun the gsm-fastapi container."
Loading