Here's how my script look like.
#!/bin/sh
REDMINE_START=/home/tsiminiya/ redmine-3.3.0/run.sh
REDMINE_STOP=/home/tsiminiya/ redmine-3.3.0/stop.sh
REDMINE_USER=tsiminiya
REDMINE_COMMAND=
executeCommand() {
start-stop-daemon -S -u $REDMINE_USER -c $REDMINE_USER -o -x $REDMINE_COMMAND
}
case $1 in
start)
REDMINE_COMMAND=$REDMINE_START
executeCommand
;;
stop)
REDMINE_COMMAND=$REDMINE_STOP
executeCommand
;;
*)
echo "Usage: $(basename $0) (start | stop)"
;;
esac
You may modify the variables above to point to your start and stop scripts. I didn't put here the contents of my run.sh and stop.sh. What is important here is the start-stop-daemon line. And, also after constructing your start-up script:
1. Save the file at /etc/init.d/<filename-of-your-choice>.
2. sudo chmod +x /etc/init.d/<filename-of-your-choice>
3. sudo update-rc.d <filename-of-your-choice> defaults
Note: at #3, we don't specify the full path but just the script name.
Restart the server after Step 3 to test whether your start-up script is working.