-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
das-toolbox-125: Stop container after test is finished
- Loading branch information
1 parent
407b6b1
commit 5d12f56
Showing
2 changed files
with
46 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
function show_help { | ||
echo "Usage: ./stop_postgres.sh [options]" | ||
echo "" | ||
echo "Options:" | ||
echo " -n, --name Container name" | ||
echo " -h, --help Show this help message" | ||
exit 1 | ||
} | ||
|
||
function main() { | ||
while [[ "$#" -gt 0 ]]; do | ||
case $1 in | ||
-n|--name) POSTGRES_CONTAINER_NAME="$2"; shift ;; | ||
-h|--help) show_help ;; | ||
*) echo "Unknown option: $1"; show_help ;; | ||
esac | ||
shift | ||
done | ||
|
||
if [[ -z "$POSTGRES_CONTAINER_NAME" ]]; then | ||
echo "Error: All required parameters must be provided." | ||
show_help | ||
fi | ||
|
||
if [ "$(docker ps -q -f name=$POSTGRES_CONTAINER_NAME)" ]; then | ||
docker rm -f "$POSTGRES_CONTAINER_NAME" | ||
echo "Container $POSTGRES_CONTAINER_NAME stopped successfully!" | ||
else | ||
echo "Container $POSTGRES_CONTAINER_NAME is not running..." | ||
fi | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters