-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop
More file actions
executable file
·87 lines (78 loc) · 2.3 KB
/
Copy pathstop
File metadata and controls
executable file
·87 lines (78 loc) · 2.3 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
# SCRIPT: stop
# DESCRIPTION: Stop the Nomisma coin analysis application and optionally remove volumes
# USAGE: ./stop [-v] [-h]
# PARAMETERS:
# -v Remove volumes (WARNING: deletes all data including database and images)
# -h Display this help message
# EXAMPLE: ./stop
# Source script-helpers
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Check if script-helpers is installed
if [ ! -f "${SCRIPT_DIR}/.script-helpers/helpers.sh" ]; then
echo "⚠️ Warning: script-helpers not found"
echo "This script requires the script-helpers library."
echo ""
echo "To install it, run:"
echo " ./update"
echo ""
read -p "Would you like to run ./update now? (y/n): " response
if [[ "$response" =~ ^[Yy]$ ]]; then
"${SCRIPT_DIR}/update"
echo ""
echo "Please run ./stop again"
exit 0
else
echo "Exiting. Please run ./update before using this script."
exit 1
fi
fi
source "${SCRIPT_DIR}/.script-helpers/helpers.sh"
shlib_import logging help
# Parse command line arguments
REMOVE_VOLUMES=false
while getopts "hv" opt; do
case $opt in
h)
display_help "$0"
exit 0
;;
v)
REMOVE_VOLUMES=true
;;
\?)
echo "Invalid option: -$OPTARG" >&2
echo "Use -h for help"
exit 1
;;
esac
done
log_info "Stopping Nomisma - Coin Analysis System"
# Check if Docker Compose is available
if command -v docker-compose &> /dev/null; then
COMPOSE_CMD="docker-compose"
elif docker compose version &> /dev/null; then
COMPOSE_CMD="docker compose"
else
log_error "Docker Compose not found"
exit 1
fi
# Stop containers
if [ "$REMOVE_VOLUMES" = true ]; then
log_warn "Stopping containers and removing volumes..."
log_warn "This will DELETE all data including the database and images!"
read -p "Are you sure? (yes/no): " confirm
if [ "$confirm" = "yes" ]; then
$COMPOSE_CMD down -v
log_info "Containers stopped and volumes removed"
else
log_info "Operation cancelled"
exit 0
fi
else
log_info "Stopping containers..."
$COMPOSE_CMD down
log_info "Containers stopped (data preserved)"
fi
echo ""
log_info "To start the application again, run: ./start"