-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
71 lines (68 loc) · 2.12 KB
/
docker-entrypoint.sh
File metadata and controls
71 lines (68 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh
set -e
CMD="${1:-start}"
reset_bt_adapter() {
if command -v btmgmt >/dev/null 2>&1; then
echo "Resetting Bluetooth adapter..."
if btmgmt --index 0 power off 2>/dev/null && btmgmt --index 0 power on 2>/dev/null; then
echo "Bluetooth adapter reset OK"
else
echo "Bluetooth adapter reset failed (will retry in-app)"
fi
sleep 2
fi
}
case "$CMD" in
start)
reset_bt_adapter
exec node dist/index.js
;;
setup)
exec node dist/wizard/index.js
;;
scan)
reset_bt_adapter
exec node dist/scan.js
;;
diagnose)
shift
reset_bt_adapter
exec node dist/diagnose.js "$@"
;;
validate)
exec node dist/config/validate-cli.js
;;
setup-garmin)
shift
if [ $# -eq 0 ]; then
exec python3 garmin-scripts/setup_garmin.py
elif [ "$1" = "--all-users" ]; then
exec python3 garmin-scripts/setup_garmin.py --from-config
elif [ "$1" = "--user" ] && [ -n "$2" ]; then
exec python3 garmin-scripts/setup_garmin.py --from-config --user "$2"
else
exec python3 garmin-scripts/setup_garmin.py "$@"
fi
;;
help|--help|-h)
echo "BLE Scale Sync - Docker Commands"
echo ""
echo "Usage: docker run [options] ghcr.io/kristianp26/ble-scale-sync [command]"
echo ""
echo "Commands:"
echo " start Run the main sync flow (default)"
echo " setup Interactive setup wizard"
echo " scan Discover nearby BLE devices"
echo " diagnose [MAC] BLE diagnostic tool (services, characteristics, flags)"
echo " validate Validate config.yaml"
echo " setup-garmin Garmin auth (env vars: GARMIN_EMAIL, GARMIN_PASSWORD)"
echo " setup-garmin --user <name> Garmin auth for a specific user from config.yaml"
echo " setup-garmin --all-users Garmin auth for all users from config.yaml"
echo " help Show this help message"
echo ""
echo "Any other command is executed directly (e.g. 'sh' for a debug shell)."
;;
*)
exec "$@"
;;
esac