Last active
November 1, 2020 06:41
-
-
Save swateek/0e677c3c10ed93bc1107551db24d8685 to your computer and use it in GitHub Desktop.
A sample shell script with parameters
This file contains hidden or 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
#!/bin/bash | |
help() | |
{ | |
echo "Invalid Arguments Supplied.." | |
echo "############## Use one from below ##############" | |
echo "'./run_db.sh --start' for starting MongoDB server" | |
echo "'./run_db.sh --stop' for stopping MongoDB server" | |
echo "'./run_db.sh --clean' for clean restart of MongoDB server" | |
} | |
stop() | |
{ | |
echo "Stopping MongoDB.." | |
docker-compose down | |
} | |
start() | |
{ | |
echo "Starting MongoDB.." | |
docker-compose up -d | |
} | |
clean() | |
{ | |
echo "Cleaning MongoDB data directory" | |
rm -rf data/* | |
} | |
if [ "$1" == "--start" ] | |
then | |
start | |
elif [ "$1" == "--stop" ] | |
then | |
stop | |
elif [ "$1" == "--clean" ] | |
then | |
stop | |
clean | |
start | |
else | |
help | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment