Here is an example of how I have done something like that in the past:
Code:
#!/bin/bash
case "$1" in
start)
echo "Starting"
;;
stop)
echo "Stoping"
;;
restart)
echo "Restarting"
$0 stop
$0 start
;;
reload)
echo "Reloading"
$0 start
;;
*)
echo "Unknown command" 1>&2
;;
esac
This will just run the script with the stop command, and then the start command when you tell it to restart, and it will run the start command when you tell it to reload (you may have to edit the actions to what you want).
$0 stands for the name of the command, so it is just a quick way of calling itself. In this script, if you put it in a file and make it executable, when you run it with:
Then it will print out Restarting, then Stoping, then Starting. "reload" will just print out Reloading and then starting.