Problem Executing Code at Startup
Posted: Fri May 22, 2015 4:36 pm
Hi.
This is staring to do my head in!
Up until recently I have had some script entries in rc.local which worked fine, they no longer seem to be working now - I had an old raspbmc from June last year that I upgraded late April this year, which I think caused the rc.local to no longer be executed
Now, at boot none of the entries are written to /var/log/messages and none of the actions expected have happened - no minidlna, no /dev/inotify and the shutdown scrip doesn't run.
After boot, and using ssh to obtain a terminal it is possible to start rc.local correctly using
I read somewhere that upstart may be causing the rc.local to start too early so I decided to move to an upstart script (I have little experience with upstart but found a recipe elsewhere, commented out all the lines in rc.local and created /etc/init/my-jobs.conf:
Starting manual using:
works fine, with all the expected results.
It does not however appear to start after a reboot
I put in the sleep 10 to make sure the logging service was running, but I am currently stumped how to get either rc.local or the uspstart script to work at boot.
Any suggestions gratefully received.
Regards,
Steve
This is staring to do my head in!
Code: Select all
uname -a:
Linux raspbmc 3.10.36 #4 PREEMPT Sun Apr 13 21:25:32 UTC 2014 armv6l GNU/LinuxCode: Select all
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Log start of script
logger -s "`date` Starting rc.local"
#Monitor the UPiS for running on battery and shutdown as required
logger -s "`date` Start Monitoring UPiS"
/home/pi/bin/shutdown-after-power-loss.sh &
#Monitor the shutdown button on the UPiS
#sudo python /home/pi/bin/fwshut.py.
#Use UPiS to set clock - FIXME
#logger -s "`date` Setting Clock"
#echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device.
#hwclock -s
# This may be needed by minidlna to get inotify to work properly
logger -s "`date` Setup inotify node"
mknod /dev/inotify c 10 63
#Not sure if minidlna starts correctly uncomment below to force
logger -s "`date` delay 60s start minidlna"
sleep 60 && sudo service minidlna start
logger -s "`date` Ending rc.local"
exit 0
After boot, and using ssh to obtain a terminal it is possible to start rc.local correctly using
Code: Select all
sudo service rc.local startCode: Select all
#
#/etc/init/my-jobs.conf
#
description "Replacement Slot for rc.local"
start on local-filesystems
script
#Just wait a little while to be sure
sleep 10
# Log start of script
logger -s "`date` Starting my-job"
#Monitor the UPiS for running on battery and shutdown as required
logger -s "`date` Start Monitoring UPiS"
/home/pi/bin/shutdown-after-power-loss.sh &
#Monitor the shutdown button on the UPiS
#sudo python /home/pi/bin/fwshut.py.
#Use UPiS to set clock - FIXME
#logger -s "`date` Setting Clock"
#echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device.
#hwclock -s
# This may be needed by minidlna to get inotify to work properly
logger -s "`date` Setup inotify node"
mknod /dev/inotify c 10 63
#Not sure if minidlna starts correctly uncomment below to force
logger -s "`date` delay 60s start minidlna"
sleep 60 && sudo service minidlna start
logger -s "`date` Ending my-job"
end script
Code: Select all
start my-jobsIt does not however appear to start after a reboot
I put in the sleep 10 to make sure the logging service was running, but I am currently stumped how to get either rc.local or the uspstart script to work at boot.
Any suggestions gratefully received.
Regards,
Steve