Skip to content

Instantly share code, notes, and snippets.

@swateek
Last active November 1, 2020 06:41
Show Gist options
  • Save swateek/0e677c3c10ed93bc1107551db24d8685 to your computer and use it in GitHub Desktop.
Save swateek/0e677c3c10ed93bc1107551db24d8685 to your computer and use it in GitHub Desktop.
A sample shell script with parameters
#!/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