I have created a script to start a server (my first question). Now I want it to run on the system boot and start the defined server. What should I do to get this done?
My findings tell me put this file in the /etc/init.d
location, and it will execute when the system will boot. But I am not able to understand how the first argument on the startup will be start
? Is this predefined somewhere to use start
as $1
? If I want to have a case startall
that will start all the servers in the script, then what are the options I can manage?
My script is like this:
#!/bin/bash
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
$0 stop
$0 start
;;
*)
echo "usage: $0 (start|stop|restart)"
;;
esac