Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

First create script

No Format
sudo nano /etc/init.d/[script] && sudo chmod +x /etc/init.d/[script] && sudo update-rc.d /etc/init.d/[script] defaults 99 01
 /etc/init.d/[script]
No Format
#! /bin/sh
# This is a generic Init Script
# This is a comment/note

#Edit these variables!
#variable1=


case "$1" in
  start)
    echo "Description of code for script starting"
    [command1]
    [command2]
    ;;
  stop)
    echo "Description of code run when stopping/shutting down script"
    [command1]
    [command2]
    ;;
  *)
    echo "Usage: /etc/init.d/[script] {start|stop}"
    exit 1
    ;;
esac

exit 0

The last code works so that if you typeInstall and {start|stop}

No Format
chmod +x /etc/init.d/[script]

It says

No Format
Usage: 
update-rc.d /etc/init.d/[script] defaults
/etc/init.d/[script] {start|stop} 

...