I have what I consider to be a pretty simple script that I want to run on startup, however I'm pretty new to init.d scripts, and maybe there is a better way to do this in general.
Basically I want my script to run when the system starts, so I have a ruby script, which I've moved to /usr/bin, and named just consumer
For the sake of brevity say it looked like this, but actually did something:
#!/usr/bin/env ruby
# just example code
puts "do stuff"
Then I have my init.d script placed in /etc/init.d and named just consumer.
#!/bin/bash
### BEGIN INIT INFO
# Provides: consumer
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INF
# /etc/init.d/consumer
#
# Some things that run always
touch /var/lock/consumer
# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting Consumer"
consumer &
echo "Consumer started successfully."
;;
stop)
echo "Stopping Consumer"
echo "Nothing happened..."
;;
*)
echo "Usage: /etc/init.d/consumer {start|stop}"
exit 1
;;
esac
exit 0
Now if I save this file and I just run sudo /etc/init.d/consumer start, it works perfect! It starts and gives me the desired output. So then I run:
$ sudo update-rc.d consumer defaults
Adding system startup for /etc/init.d/consumer ...
/etc/rc0.d/K20consumer -> ../init.d/consumer
/etc/rc1.d/K20consumer -> ../init.d/consumer
/etc/rc6.d/K20consumer -> ../init.d/consumer
/etc/rc2.d/S20consumer -> ../init.d/consumer
/etc/rc3.d/S20consumer -> ../init.d/consumer
/etc/rc4.d/S20consumer -> ../init.d/consumer
/etc/rc5.d/S20consumer -> ../init.d/consumer
But when rebooting the system my script never gets started, any ideas? I'm not sure what action to take next. I've adjusted all the scripts permissions to 775, and made sure root owned them all as well.
Any help would be hugely helpful.