0

I'd like to create my own init script to make my program start at boot and be controlled via "service" utility in most popular Linux distributions.

Requirements:

  • it should be portable across different distros(it should support at least Debian/Ubuntu and RedHat/Centos)
  • it shouldn't depend on any additionally installed packages
  • it should control if my program started succesfully or encountered some kind of errors
  • it should reliably stop my program when requested (sometimes init script say "stopping... OK" but it's still running)

For example, I can do it this way:

case "$1" in
start)
    ./start-jira.sh
    ;;
stop)
    ./stop-jira.sh
    ;;
*)
    echo "Usage: $0 {start|stop}"
    exit 1
    ;;
esac

But in this case it's required to check if program has been properly started with 'ps' and properly killed on shutdown.

Looking for the right way to do it. Is there any standard to satisfy all those systemd, upstart,etc. ?

Thanks

guZ
  • 1
  • 1

1 Answers1

0

There's no drop-in script that will work with all init systems. While you can write one that launches your daemon (similar to bin/startup.sh for tomcat), you need some config files or scripts for the actual init system in use by the target distro.

fuero
  • 9,413
  • 1
  • 35
  • 40