RaspberryPi: CumulusMX init.d System Startup Script
Posted: Thu 07 Jan 2016 3:27 pm
This tuorial affects all people having a Raspberry Pi running CumulusMX in conjunction with the CumulusMX Start|Stop Script
mentioned in post https://cumulus.hosiene.co.uk/viewtopic.php?f=27&t=13767
In Debian 7 (Debian Wheezy) it was not a problem at all to insert a line into the system Crontab to start a bash script at reboot using the @reboot option in a cronjob, for example:
sudo crontab -e
For any reason people reported that they are having problems using this method in Debian 8 (Debian Jessie)
I was able to insert such a command in the system crontab successfully, but others reported further problems
sudo nano /etc/crontab
This was the reason why I created a small system startup script which can be placed in /etc/init.d to start the CumulusMX Start|Stop Script at system boot without irritate with cron jobs probably not working anymore
Here is the instruction what you need to do.
1. Removing autostarts from cron
You can ignore this step, if you never had a cron based startup entry and proceed with Step 2
Please make sure, that all cron's are being checked not to start cumulusmx.sh anymore
Please use these commands and search for lines probably containing the start|stop script at reboot
crontab -e
sudo crontab -e
sudo nano /etc/crontab
If present, change them to
2. Download the /etc/init.d script
Copy the Script (using WINSCP) to your /tmp folder
Once the zip file is copied, login as pi or root using SSH (Putty) and insert these commands
unzip /tmp/cumulusmx.zip - will unzip the zip file
sudo cp /tmp/cumulusmx /etc/init.d/cumulusmx - will copy the startup script cumulusmx to /etc/init.d
sudo chmod +x /etc/init.d/cumulusmx - will make the scirpt executable
sudo update-rc.d cumulusmx defaults - will insert the Startup Script into the runlevels
(the command to remove it from the runlevels again is: sudo update-rc.d -f cumulusmx remove)
3. Changing some settings in this init script
sudo nano /etc/init.d/cumulusmx
Please only change one of these lines if necesarry (for most poeple nothing needs to be changed)
CumulusMX_HOME= the folder where the cumulusmx.sh Start|Stop Script is located. Normally it is in the same folder as CumulusMX.exe
CumulusMX_USER this is the user, who should start CumulusMX at system boot. It might user pi or root
Save changes by pressing CTRL-o and CTRL-x
sudo reboot - to reboot system
After the system has being rebooted check if CumulusMX is being started.
sudo grep -i cumulusmx /var/log/syslog
you should see a line like this:
Jan 7 13:31:11 raspberrypi systemd[1]: Started LSB: Start cumulusmx.sh (CumulusMX) at boot time
But now you have more options
type: /etc/init.d/cumulusmx
Usage: /etc/init.d/cumulusmx {start|stop|force-reload|status}
Possible commands should be
/etc/init.d/cumulusmx stop
/etc/init.d/cumulusmx start
/etc/init.d/cumulusmx force-reload
/etc/init.d/cumulusmx status
I think I don't need to explain these commands
So you are free to start stop CumulusMX by using the start Stop Script itself
1) /home/pi/CumulusMX/cumulusmx.sh -{options}
or using
2) /etc/init.d/cumulusmx {options}
however option 1) has more options than option 2)
for me it works so feel free to play around wit this init script.
I know, real linux admins maybe can do this much better then me, but this was my first attempt to write a init.d script.
EDIT: 11.10.2016
For all who have trouble strating CumulusMX with the init.d Startup Script at system boot, here is a command to check, if the init.d startup scirpt is correctly inserted into the runlevel of your system.
1) install a small program called: chkconfig
sudo apt-get install chkconfig
2) run the command to check if the startup script should be started at system boot
chkconfig |grep cumu
as a result you should see:
cumulusmx on
If you did not see this result, you missed to enter the following command to insert the startup script into the runlevels
sudo update-rc.d cumulusmx defaults
mentioned in post https://cumulus.hosiene.co.uk/viewtopic.php?f=27&t=13767
In Debian 7 (Debian Wheezy) it was not a problem at all to insert a line into the system Crontab to start a bash script at reboot using the @reboot option in a cronjob, for example:
sudo crontab -e
Code: Select all
@reboot sudo /home/pi/CumulusMX/cumulusmx.sh >> /dev/null 2>&1
I was able to insert such a command in the system crontab successfully, but others reported further problems
sudo nano /etc/crontab
Code: Select all
@reboot pi /home/pi/CumulusMX/cumulusmx.sh >> /dev/null 2>&1
Here is the instruction what you need to do.
1. Removing autostarts from cron
You can ignore this step, if you never had a cron based startup entry and proceed with Step 2
Please make sure, that all cron's are being checked not to start cumulusmx.sh anymore
Please use these commands and search for lines probably containing the start|stop script at reboot
crontab -e
sudo crontab -e
sudo nano /etc/crontab
Code: Select all
@reboot /home/pi/CumulusMX/cumulusmx.sh
Code: Select all
#@reboot /home/pi/CumulusMX/cumulusmx.sh
Once the zip file is copied, login as pi or root using SSH (Putty) and insert these commands
unzip /tmp/cumulusmx.zip - will unzip the zip file
sudo cp /tmp/cumulusmx /etc/init.d/cumulusmx - will copy the startup script cumulusmx to /etc/init.d
sudo chmod +x /etc/init.d/cumulusmx - will make the scirpt executable
sudo update-rc.d cumulusmx defaults - will insert the Startup Script into the runlevels
(the command to remove it from the runlevels again is: sudo update-rc.d -f cumulusmx remove)
3. Changing some settings in this init script
sudo nano /etc/init.d/cumulusmx
Please only change one of these lines if necesarry (for most poeple nothing needs to be changed)
Code: Select all
CumulusMX_HOME=/home/pi/CumulusMX
CumulusMX_USER=root
CumulusMX_USER this is the user, who should start CumulusMX at system boot. It might user pi or root
Save changes by pressing CTRL-o and CTRL-x
sudo reboot - to reboot system
After the system has being rebooted check if CumulusMX is being started.
sudo grep -i cumulusmx /var/log/syslog
you should see a line like this:
Jan 7 13:31:11 raspberrypi systemd[1]: Started LSB: Start cumulusmx.sh (CumulusMX) at boot time
But now you have more options
type: /etc/init.d/cumulusmx
Usage: /etc/init.d/cumulusmx {start|stop|force-reload|status}
Possible commands should be
/etc/init.d/cumulusmx stop
/etc/init.d/cumulusmx start
/etc/init.d/cumulusmx force-reload
/etc/init.d/cumulusmx status
I think I don't need to explain these commands
So you are free to start stop CumulusMX by using the start Stop Script itself
1) /home/pi/CumulusMX/cumulusmx.sh -{options}
or using
2) /etc/init.d/cumulusmx {options}
however option 1) has more options than option 2)
for me it works so feel free to play around wit this init script.
I know, real linux admins maybe can do this much better then me, but this was my first attempt to write a init.d script.
EDIT: 11.10.2016
For all who have trouble strating CumulusMX with the init.d Startup Script at system boot, here is a command to check, if the init.d startup scirpt is correctly inserted into the runlevel of your system.
1) install a small program called: chkconfig
sudo apt-get install chkconfig
2) run the command to check if the startup script should be started at system boot
chkconfig |grep cumu
as a result you should see:
cumulusmx on
If you did not see this result, you missed to enter the following command to insert the startup script into the runlevels
sudo update-rc.d cumulusmx defaults