I wrote a little script to Start Stop Restart Cumulus on a Raspberry Pi or Linux SystemIt is often very useful to run Cumulus in a so called headless mode on console window without a attached keyboard etc. Since Cumulus can not be "deamonized" yet, one option is to run Cumulus in a so called: "Screen Session". This allows you to connect to the Linux Box via SSH, starting CumulusMX and close the SSH Session again.Once you logged out and logged in again, you are able to "find" your Cumulus again and Start/Restart or Quit it by using this small bash script

Description: This script can be called without so called "root rights" by using the command sudo and since Version 2.4.x also as normal user (usually user pi)Attention: Whenn the script is being started with root rights (sudo) some file in the CumulusMX folder might belong to the suer account root. In this case, it might happen, that other users are not allowed to write into the Files and CumulusMX will not start. So you should think about how you want to use the script. With sudo, or as normal user without sudo.The Script will find out, if it is previously being started as root (sudo) and in case, it will prompt with an error message to hange the owner of the files first.It is always possible to start the scrpt as user pi and call Script with options as user root (sudo).

Start this script with sudo ./cumulusmx.sh or sudo /home/pi//CumulusMX/cumulusmx.shAlternatively ./cumulusmx.sh or /home/pi//CumulusMX/cumulusmx.shBased on the location where you installed CumuluxMX

If CumulusMX (as Screen) is already running, the Script ask to Stop CumulusMX (y/n)If CumulusMX is not running it is starting CumulusMX as Screen.If you call the script with -r, it will immidiately restart CumulusMX (sudo ./cumulusmx.sh -r) -q, it will immidiately quit Cumulus, sending a CTR+C (sudo ./cumulusmx.sh -c) -s, it will display the status of CumulusMX - Also when not running (sudo ./cumulusmx.sh -s) -h, it will display a Help Screen with the list of available commands (sudo ./cumulusmx.sh -h) -p 1-65535, it will start on this TCP Port instead of default TCP Port 8998. (the Default Port can be modified within the the top of the script) -d, it will switch back to the "unscreened" Session. You can switch back to the Screen session by typing "CTRL-A" and "D" -b -t > will create a tar.gz Backup | -b -z > will create a zip Backup | -b -dd > will create a dd Backup of the SD Card | -b -c will create a Cloud Backup. Define the Backup folder in cumulusmxsh.conf -v Print current Version of this Script -u will Update the CumulusMX installation form an official ZIP File -l will show a small menu where Logfiles and other import CumulusMX relevant files can be listed -m will create a zip File which contain the latest MXdiag-log file in folder MXdiags. Can be used to easily upload to Cumulux Forum -c Application , System and Network Check - Will guide you through a System check: Network Settings/FTP Settings/CumulusMX Basic config check -n Cumulus Now will display the current CumulusMX weather values in the SSH Session - in a 5 Minutes loop -system [-s,-r] will display a menu to stop CumulusMX and reboot/shutdown system. Optional -system [-r, -s] will immidiately reboot/shutdown without menu. Good for use this in cron.

If you call without Paramaters it will find out, if Cumulus is running or not and will ask to start or in case it's running, ask to stop.

2. Download and copy the scriptAt the end of this post, you can find this script as a downloadable zip fileCopy the Script (cumulusmx.sh) and the config file (cumulusmxsh.conf) into the same folder as CumulusMX.exe

Make some basic settings in the cumulusmxsh.conf file --> sudo nano cumulusmxsh.confRun the Script by using : sudo /path_of_script/cumulusmx.sh or sudo ./cumulusmx.shIf you encountering problems, please start CumulusMX first without using this Script and check for possible errors (http://sandaysoft.com/forum/viewtopic.php?f=27&t=12908)When you call this script the first time, you maybe see some errors likefind: `/tmp/CumulusMX.pid': No such file or directoryfind: `/home/pi/CumulusMX//MXdiags/*.txt': No such file or directory...which can be ignored.

4. Insert this Script into cron to be started at boot timeI used this method instead of /etc/init.d/ but maybe later I'll try this

sudo crontab -eScroll down to the bottom of the list and insert this line

CumulusNow is a script visualizing weatherstation values based on CumulusMX in a Putty Session-PLease see also CumulusNow: Forum Post

1_stats.jpg

2_status.jpg

3_help.jpg

4_list.jpg

5_check.jpg

6_detach.jpg

7_now.jpg

Version 1.1: Search the Server for install path of CumulusMX.exe, that the script can be placed anywhere on the System.Version 1.2: Preventing Script to Search Cumulus Install Path on Network sharesVersion 1.3: System Uptime included in output - Better formatting of Cumulus status outputVersion 1.4: Will check if Script is being called as root - otherwise will quit the scriptVersion 1.5: [11.05.2015] Some cosmetical improvments - adding CumulusMX uptime in the status messages - writing pid file in /run/Version 1.6: [14.05.2015] Fixed some obsolete CRLF in the script which caused errors in some casesVersion 1.7: [16.05.2015] Added possibillity to call the script with -r (restart) for immidiately restart of CumulusMx --> "sudo ./cumulusmx.sh -r"Version 1.8: [20.05.2015] Improved error Handling - Added possibillity to run with more parameters -s (Status), -q (Quit) , -h Help --> sudo ./cumulusmx [OPTION] [-h,-r,-q,-s]Version 1.9: [23.05.2015] TCP Port can be set in the Script - Added possibillity to call Script with a port Number: sudo ./cumulusmx -p 12345 to start Cumulus on Port 12345 - Detecting IP Address of ETH0 / Displaying the complete URL with PortVersion 2.0: [25.05.2015] Added new Parameter -d (will resume detached Screen session) - Can be screened again with CTR-A and D - Installation folder can be set within the head of the script by using editor (nano) - if folder name is other then CumulusMX - Fixed: Errorhandling in detecting installation path, if more than 1 CumulusMX folder is present (Backup on Network Strage for example)Version 2.0.2: [29.05.2015] Added new Parameter -b (Backup) in combination with -t (tar.gz) -z (zip) and -d for DD Backup of the SD Card.Version 2.0.6: [02.06.2015] Added new Parameter -u (Update) Script will ask you for the path of the CumulusMX ZIP File and will update the installation (It is possible to exclude a directory in the zip to be extracted for example: "web" folder , to not overwrite your own web template files)Version 2.0.7: [04.06.2015] Remove obsolete characters from the script which might causes errors on many Linux systems: (sudo: unable to execute ./cumulusmx.sh: No such file or directory)Version 2.1.0: [11.06.2015] Added new Parameter -l (list logfiles - Menu). This will give you the option to list some of the important logfiles or folder of CumulusMX installation - Added coloured run-status on Status Page - Detect CumulusMX Version and display with -s . Improved the error handlingVersion 2.1.1: [14.06.2015] Get Cumulus Version did not work because "xargs" missing in command - Error File not found -> was fixed in this version (Sorry for inconvenience)Version 2.1.3: [15.06.2015] Added new Parameter -m (create zip of latest MXdiags file into MXdiags folder) - Error: MXVersion finally fixed now - Script will check remaining diskspace. If threshold of 90% is reached, it will Alert in RED when using this Script (if 80% is reacxhed, a yellow warning will be displayed.Version 2.1.6: [19.06.2015] Added new Parameter -c (Application , System and Network Check - Will guide you through a System check: Network Settings/FTP Settings/CumulusMX Basic config check) - Abbillity to check the installed script version aginst the most current version (Will be displayed with -sVersion 2.1.7: [21.06.2015] Bugfix. removed hardcoded path from script.Version 2.2.0: [18.07.2015] Added "Cumulus Now" - will display current weather conditions within the SSH session in a 5 Minutes loopVersion 2.2.1: [29.07.2015] Option -n will show currentl Weatherstation values and will call an external script which can be downloaded here in this forum or directly within the script when option -n is called. (Will ask to download)Version 2.2.4: [01.09.2015] Removed some obsolete sudo's - fixed a bug when calling option -l -> "Show mmmyylog.txt log live-view" Added option -system [-r,-s]Version 2.2.5: [01.10.2015] Fixed month display in option -l - added Version Check Cumulusnow.sh - Check updated for Mono V4 - Check if /dev/ttyUSB0 is present and configuredVersion 2.2.7: [13.10.2015] Fixed: System menu (-system) is now able to reboot/restart, not a fake anymore - Check if RaspberryPi using Wireless Interface wlan0. If this is the case, the start of CumulusMX will be deferred because of WPA Handshake is slower than System start and IP might be not assigned. This prevent CumulusMX not to not start without a bound IP Address to an interface when used in cron while (re)boot - Fixed Status output/pages when using interfaces other than eth0.Version 2.3.0: [26.10.2015] Fixed: System Uptime will now be displayed properly - Abillity to display all used Variables when using option -l (Menu) - Added fancy progress bar when cumulusmx is being started to get more time before option -s is displaying an error - New look of Status information screen - checking for available Version of CumulusMX - when RaspberryPi using external USB Drive or DHCP, Script will wait until USB Drive is up or IP Address is assignedVersion 2.4.0: [22.12.2015] Script can now be started as non root user (sudo not requiered anymore) - list of all fixes and news on Page 13Version 2.5.0: [19.02.2016] + Added Logfile option. - list of all fixes and news on Page 17Version 2.5.1.0: [10.04.2016] + Added Cloud Backup function (WebDav)Version 2.5.2.0: [02.05.2016] + Added Cloud Backup check in the system check section (cumulusmx.sh -c)Version 2.5.2.2: [02.09.2016] - Fixed Version check for CumulusMX because changes on the Cumulus Webpages were made.Version 2.5.3.0: [27.09.2016] - Added Parameter -w (watchdog). In case CumulusMX can not be started with the init.d script, create a cron entry which is starting CumulusMX every 10 minutes. In case it is already running, nothing happens. If not running, it will be startetVersion 2.5.3.1: [21.01.2017] - fixed CumulusMX version check since Steve modified the Forum websiteVersion 2.5.4.0: [21.02.2017] - fixed a problem with the init.d script when CumulusMX is installed on a USB Drive. CumulusMX could not be started at system boot. This version fixed this problem. Please read Forum post for more information.Version 2.5.5.0: [11.09.2017] - fixed a problem with the status page when using Debian Stretch - Sorry for being so late with the fixPlease read Forum post for more information.

INIT.D Script: [08.01.2016] CumulusMX Init.d Script added as a replacement for a cron entry to start at boot

You do not have the required permissions to view the files attached to this post.

Last edited by slashmusic on Mon Sep 11, 2017 6:07 pm, edited 151 times in total.

you asked for feedback on your script - here are some first impressions from a Linux Newbe

First of all, I finally got them running and everything works fine - it's a great help, thank you!

But in the first try I got confused about the Linux topic "sudo or not" By simply clicking on the file "cumulusmx.sh" in the PCManFM "Dateimanager", which is, of course clearly a user (my) mistake I got in trouble

-> if I run the script by clicking on cumulusmx.sh in PCManFM "Dateimanager" and perform the action "im Terminal ausführen" the script gives the impression, that everything did work right, but in reality, the start of CumulusMX.exe failed ... (at least I couldn't access the GUI in Epiphany Webbrowser)

... don't know for sure, but switching off CumulusMX seems to work under these conditions, however.

--> would be good to give an error message, that the script has not been started with the correct environment (sudo ..) and do nothing, or, as an alternative, make the script operating without the "sudo" privileges at script start

As I said, I have only very basic knowledge of Linux and I'm still learning, so I don't create any theories why this happened (allthough I have some suspicions), just wanted to let you know.

yes, I asked for feedback and here I have my feedback.Thank you anyway<. I missed to think about people who are using the Raspberry Pi with graphical interface. Mine is directly starting without using the GUI.aynway, here is what I did:In the beginning of the Script I am checking if you are root or not.If you are not root, the script will give you a short hint to start as root and will quit.since this check is being done at the very beginning of this Script, I don#t need any further error Handling regarding user rights.Btw: Steve wrote somewhere in his Beta information, that Mono+Cumulus need to be started with Root rights and he is planning to change it sometime in the future.

I don't know, why it need to run as root, but maybe this is how Mono want to be started.

Btw and maybe this helps you. In my short mini instruction I explained how to add this Script into CRON . This willstart the script at reboot.By doing this, you never need to care about it, when you start your Raspberry Pi.

anyway, Version 1.4 is available above.PLease let me know, if you need anything elseJan

willyweather wrote:Just tested the new version - Everything works fine and as expected Thanks a lot, Jan.btw.: "System uptime" means "CumulusMX update" - right? i.e. we are talking here about the runtime of CumulusMX, not of the runtime of the RasPi Linux System, or ?

Thanks Wilfried for the positive feedback."System Uptime" means System Uptime not Cumulus Uptime. This is the time, when your RaspberryPi is being rebooted.There is a Webtag called: #ProgramUpTime but this can only be used from Cumulus itself but I have an idea for the next version to display the Cumulus Uptime also. Maybe one solution is: when CumulusMX is being started, I should create a "PID File" in /run/ folder and check the timestamp of this file, to get the runtime of CumulusMX Please wait for the next Verison 1.5

willyweather wrote:Next question from the Linux Newbe: How do I get access to the Messages from CumulusMX like i.e. "Connection to Station lost" ?

I think, this is nothing for the Cumulus Start/Stop Script. This is something Cumulus can handle internally with a WebTag.The Script is starting or stopping a Software. Things happend while the software is running is out of control of this script. In this case, you need a kind of Watchdog Program ........

willyweather wrote:Next question from the Linux Newbe: How do I get access to the Messages from CumulusMX like i.e. "Connection to Station lost" ?

I use Cumulus Toolbox to do this http://wiki.sandaysoft.com/a/Toolbox. It sends me an email when the connection is lost, and it uses the PHP webtags (cumuluswebtags.php) so all sorts of things can be checked every 15 minutes. However, it doesn't run on a RPi so you would have to use a windows machine to monitor the webtags. A Samba share to the RPi should allow that to work.

willyweather wrote:Next question from the Linux Newbe: How do I get access to the Messages from CumulusMX like i.e. "Connection to Station lost" ?

I use Cumulus Toolbox to do this http://wiki.sandaysoft.com/a/Toolbox. It sends me an email when the connection is lost, and it uses the PHP webtags (cumuluswebtags.php) so all sorts of things can be checked every 15 minutes. However, it doesn't run on a RPi so you would have to use a windows machine to monitor the webtags. A Samba share to the RPi should allow that to work.

In this case it should be possile to install php on Rasperry Pi and requesting the status of the weatherstation by using a small php script and checking the result code.

But I am sure, the toolbox can do much more than checking the status of the weatherstation

I'm intrigued to give your script a try, but do you know if the script should work "as-is" using other versions of Linux, or would this only work on the RPi?

I'm giving it a try on Ubuntu Server 14.04 but not having any luck. I have CumulusMX installed in /home/CumulusMX, and I put the cumulusmx.sh file in the same directory and made it executable. When I try to execute it using sudo ./cumulusmx.sh or sudo /home/CumulusMX/cumulusmx.sh I get the following:

sudo: unable to execute ./cumulusmx.sh: No such file or directoryorsudo: unable to execute /home/CumulusMX/cumulusmx.sh: No such file or directory

Do you know if I need to hard code the install path in the script, or if this just won't work on Ubuntu?

I do have screen installed and I've been using the following in my /etc/rc.local file without any issues, I just figured I would give your script a try.

Thanks, got it.....fixed itnormally, I created it completely in nano, but yes, I copied some lines for backup reason into my windows Textpad and moved it back to the nano editor.Maybe thats the reason why these obsolete characters sneaked into itthere is a fixed version above (1.6) available which should do it.

Downloaded new version of script and it is working on Ubuntu now. Thanks!

Ideally, I would love to be able to run MX without having to use screen. I've been having some issues where screen seems to stop randomly, not sure what's causing that. But I think screen is the only option to be able to run headless for now.