-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop.sh
More file actions
executable file
·62 lines (53 loc) · 1.6 KB
/
stop.sh
File metadata and controls
executable file
·62 lines (53 loc) · 1.6 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
#!/bin/bash
# ==========================
# rscp2mqtt Compose Stopper
# ==========================
# Default values
USE_BROKER=false
USE_DASHBOARD=false
COMPOSE_FILE="docker-compose.yml"
DO_ALL=false
# Help message
print_help() {
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --with-broker Stop internal MQTT broker"
echo " --with-dashboard Stop rscp2mqtt-dashboard"
echo " --all Stop all services (default)"
echo " --help Show this help message"
echo ""
echo "Examples:"
echo " $0 # stop all services"
echo " $0 --with-dashboard # stop dashboard only"
echo " $0 --with-broker # stop broker only"
echo " $0 --with-dashboard --with-broker # stop both optional services"
}
# Parse arguments
if [[ $# -eq 0 ]]; then
DO_ALL=true
fi
while [[ "$#" -gt 0 ]]; do
case "$1" in
--with-broker) USE_BROKER=true ;;
--with-dashboard) USE_DASHBOARD=true ;;
--all) DO_ALL=true ;;
--help) print_help; exit 0 ;;
*) echo "Unknown option: $1"; print_help; exit 1 ;;
esac
shift
done
# Build service list
SERVICES=()
$DO_ALL && SERVICES=("rscp2mqtt" "rscp2mqtt-dashboard" "mqtt-broker")
$USE_BROKER && SERVICES+=("mqtt-broker")
$USE_DASHBOARD && SERVICES+=("rscp2mqtt-dashboard")
# Run docker compose stop and remove
if [[ ${#SERVICES[@]} -eq 0 ]]; then
echo "❌ No services selected to stop."
print_help
exit 1
fi
echo "🛑 Stopping and removing services: ${SERVICES[*]}"
docker compose -f "$COMPOSE_FILE" stop "${SERVICES[@]}"
docker compose -f "$COMPOSE_FILE" rm -f "${SERVICES[@]}"