Freitag, 19 Januar 201819:03:08

CumulusMX Start|Stop Script

 

CumulusMX is a, free software for your personal weather station. Please visit: http://sandaysoft.com/ for more information

 

Hi Raspberry Pi /Linux User

I wrote a little script to Start Stop Restart Cumulus on a Raspberry Pi or Linux System

It 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:
Start this script with sudo ./cumulusmx.sh or sudo home/pi//CumulusMX/cumulusmx.sh
Based 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 CumulusMX folder. Define the Backup folder in head of the Script. Default: /Backup_CumulusMX
-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.


1. Install screen and Mono(*) on your Raspberry Pi
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install screen
sudo apt-get install mono

* Regarding correct version of mono for your RapsberryPi, please refer to these Forum posts
http://sandaysoft.com/forum/viewtopic.php?f=27&t=13587 http://sandaysoft.com/forum/viewtopic.php?f=27&t=14222 and

2. Download and copy the script
At the end of this post, you can find this script as a downloadable zip file
Copy the Script wherever you want (It will find the Installpath of CumulusMX.exe automatically)
Recommendation of course in the CumulusMX folder which is mostly located in /home/pi/CumulusMX/)
Copy ZIP File into this folder

3. Unzip Script and make the script executable

sudo unzip /path_to_script/cumulusmx_2.x.x.zip
sudo chmod +x /path_to_script/cumulusmx.sh

Run the Script by using : sudo /path_of_script/cumulusmx.sh or sudo ./cumulusmx.sh

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

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

Code:
# If you like CumulusMX to be started when starting the Raspberry Pi
@reboot  sudo /CumulusMX/cumulusmx.sh >> /dev/null 2>&1

#if you like a daily restart at 5 am
0 5 * * * sudo /CumulusMX/cumulusmx.sh -r >> /dev/null 2>&1

# In case you want to make a frequent backup of the CumulusMX folder every day around midnight
59 23 * * * sudo /CumulusMX/cumulusmx.sh -b -z >> /dev/null 2>&1

# In case you want to make a backup of the Raspberrypi once per week on Sunday Morning
00 06 * * 7 sudo /CumulusMX/cumulusmx.sh -b -d >> /dev/null 2>&1

# In case you want to reboot your RaspberryPi each sunday morning at 6:15 am
15 6 0 0 7 /usr/bin/sudo /home/pi/cumulusmx.sh -system -r >> /dev/null 2>&1


(replace * with the time you want cumulus to be restarted)

 

 
File comment: Status without Parameters


 

Attachment:
File comment: Option -s - Status


 

Attachment:
File comment: Option -h - Help
3_help.jpg

 

Attachment:
File comment: Option -l - List Logfiles
4_list.jpg

 

Attachment:
File comment: option -c - Check Settings


 

Attachment:
File comment: Option -d - Bring Screened CumulusMX into foreground


 

Attachment:
File comment: Option -n - Additional Script: CumulusNow
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 shares
Version 1.3: System Uptime included in output - Better formatting of Cumulus status output
Version 1.4: Will check if Script is being called as root - otherwise will quit the script
Version 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 cases
Version 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 Port
Version 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 handling
Version 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 -s
Version 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 loop
Version 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 configured
Version 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 assigned

 

Dateien:
cumulusmx_2.3.0.1.zip 2.3.0.1 Beliebt
(0 Stimmen)

CumulusMX is a, free software for your personal weather station. Please visit: http://sandaysoft.com/ for more information. Cumulusmx.sh is a script to easily start/stop cumulusmx on a RaspberryPi

Lizenz CharitywareTooltip Datum 2015-11-09 Sprache  Englisch Dateigröße 13.4 KB Download 206 Download