Added --down option to db.sh to stop database containers without deleting volumes.
This commit is contained in:
parent
8794a8a193
commit
9dca1e8abb
1 changed files with 27 additions and 9 deletions
20
db.sh
20
db.sh
|
|
@ -7,12 +7,13 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|||
cd "$SCRIPT_DIR"
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 <mysql|mssql> [--clean] [--users]"
|
||||
echo "Usage: $0 <mysql|mssql> [--clean] [--users] [--down]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " mysql|mssql Which database to start"
|
||||
echo " --clean Delete volumes and start fresh"
|
||||
echo " --users Only import test users (database must be running)"
|
||||
echo " --down Stop the database container"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
|
@ -20,6 +21,7 @@ usage() {
|
|||
DB=""
|
||||
CLEAN=false
|
||||
USERS_ONLY=false
|
||||
DOWN_ONLY=false
|
||||
|
||||
for arg in "$@"; do
|
||||
case $arg in
|
||||
|
|
@ -32,6 +34,9 @@ for arg in "$@"; do
|
|||
--users)
|
||||
USERS_ONLY=true
|
||||
;;
|
||||
--down)
|
||||
DOWN_ONLY=true
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
|
|
@ -40,6 +45,19 @@ done
|
|||
|
||||
[ -z "$DB" ] && usage
|
||||
|
||||
# Stop container only
|
||||
if [ "$DOWN_ONLY" = true ]; then
|
||||
if [ "$DB" = "mysql" ]; then
|
||||
echo "==> Stopping MySQL..."
|
||||
podman-compose down 2>/dev/null || true
|
||||
elif [ "$DB" = "mssql" ]; then
|
||||
echo "==> Stopping MSSQL..."
|
||||
podman-compose --profile mssql down 2>/dev/null || true
|
||||
fi
|
||||
echo "==> Done!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Import users only
|
||||
if [ "$USERS_ONLY" = true ]; then
|
||||
if [ "$DB" = "mysql" ]; then
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue