Page 1 of 2

CumulusMX Start|Stop - Management Script (CumulusMX 2.5.5.7)

Posted: Tue 24 Mar 2020 1:00 pm
by jank
CumulusMX Start|Stop - Management Script(s) for RaspberryPi/Linux Systems

Unfortunately the Admin removed this topic by mistake once he restructured the forum and asked me to re-create it again.

The CumulusMX Start|Stop - Management Script will help Linux users to handle CumulusMX on their systems.
With this Script you can run CumulusMX in the backgroud without the need to stay connected to the Linux system.
Since I have it running on a RaspberryPi with Raspbian OS (based debian) it might happen, that this script is not properly running on other Linux distro's

CumulusNow is another script I wrote which is a kind of measurement dashboard which visualize the values of your weatherstation in the linux console
CumulusMX init.d is a small startup Script to start cumulusmx.sh when systen starts for those who have problems to start it via crontab

Downloads:
CumulusMX_2.5.5.7.zip
+Added Debug Mode - CumulusMX can be started in debug mode now ( ./cumulusmx.sh -debug )
o Fixed Version check of CumulusMX since Forum structure has changed

Old version:
CumulusMX_2.5.5.4.zip

Instructions:
1. Download this Script and extract it to your RaspberryPi
2. Copy the files cumulusmx.sh and cumulusmxsh.conf to your CumulusMX installation folder
3. change the file permissions of the sh script: chmod +x /home/pi/CumulusMX/cumulusmx.sh
4. Use an editor (vi or nano) and modify
a) cumulusmx.sh
at the top you can find a line: INSTPATH="/home/pi/CumulusMX" # Example "/home/pi/CumulusMX" without ending /
change the path to your installation path of CumulusMX. Most users installed CumulusMX in the user pi's home directory.
Example: If you installed CumulusMX in the root, change the line to INSTPATH="CumulusMX"
b) cumulusmxsh.conf
you can modify further settings like TCP Port (where CumulusMX Webserver is listening and many other settings)
there are some locale settings, and some further Backup options for CumulusMX
5. Once you changed the settings to match your environment, you can start CumulusMX
a) /home/pi/CumulusMX/cumulusmx.sh or
b) cd /home/pi/CumulusMX
./cumulusms.sh

6. You will see a menue on the windows which gives you some information about the current status of CumulusMX Deamon.

7. the cumulusmx.sh script is having some options available which can be used when starting the script with
./cumulusmx.sh -h

-h HELP, This screen
-s CumulusMX Status
-r Restart CumulusMX
-q Quit CumulusMX
-p [1-65535] Start CumulusMX on TCP Port (Range: 1-65535) or edit the TCP PORT value in cumulusmxsh.conf
-d Resume Screened Session
-b [-z,-t,-d,-c] Backup CumulusMX with zip,tar.gz,dd or Cloud-WebDAV (sudo ./cumulusmx.sh -b [-t,-z,-d,-c] )
-n Cumulus Now - Current WeatherStation values
-l Logfile Viewer (Menu based)
-u Update Cumulus from an official CumulusMXDist3xxx.zip (You will be guided through this Process)
-m Create zip file with the latest MXdiags log
-c Will guide you through a System check: Network Settings/FTP Settings/CumulusMX Basic config check
-system [-r,-q] Option -system will open a reboot/shutdown menu. Additional Options [-r, -q] (./cumulusmx.sh -system -r, -q)
-w Watchdog Option - when script will be called by cron in a loop instead of init.d script
-v Print Version

HowTo:
[*] Howto Update CumulusMX using the CumulusMX Start|Stop - Management Script
[*] Automated Backups by using the CumulusMX Start|Stop - Management Script



Screenshots:
when you start this script it will start CumulusMX or in case it is alreay running, it can stop or restart CumulusMX
1_stats.jpg

when CumulusMX is running and you start the script with cumulusmx.sh -s it will show a status dashboard
2_status.jpg

when started with option ./cumulusmx -h it will show you an overview of all available options
3_help.jpg

when started with option ./cumulusmx.sh -l it will show you a build in logfile viewer to see all relevant CumulusMX Logfiles
4_list.jpg

when started with option ./cumulusmx.sh -c it will open a check of your CumulusMX installation to detect possible config problems (Network etc)
5_check.jpg

when started with option ./cumulusmx.sh -c you can detach the background deamon CumulusMX and bring it into the forground again
6_detach.jpg

Re: CumulusMX Start|Stop - Management Script (CumulusMX 2.5.5.4)

Posted: Thu 09 Apr 2020 1:39 pm
by jank
Howto Update CumulusMX using the CumulusMX Start|Stop - Management Script above

cd /tmp
wget https://github.com/cumulusmx/CumulusMX/ ... st3070.zip

(replace the download link with the latest download provided here: https://cumuluswiki.org/a/Software)
once the wget download has finnished szart cumulusmx.sh with option -u
/home/pi/CumulusMX/cumulusmx.sh -u
When asked for the zip file, enter /tmp/CumulusMXDist and hit the TAB Button for File Completition. Choose the zip file with the CumulusMX update and hit return. Follow the oncreen instructions
Once you've been asked to insert one folder which should not be overwritten, enter the folder name or hit return
You've being asked if you are sure and then the update begins.
In the next dialog you will be asked to replace the first file.....you can choose: [y]es, [n]o, [A]ll, [N]one, [r]ename
I would reocmmend A to replace all files.
CumulusMX will be restarted after update and you can check if ther update was successful by using /home/pi/CumulusMX/cumulusmx.sh -s

Re: CumulusMX Start|Stop - Management Script (CumulusMX 2.5.5.4)

Posted: Fri 24 Apr 2020 8:38 am
by jank
CumulusMX - Automated Backups

In the Internet I accidentally found a very good howto make automated backups by using my Start|Stop Script by Wizza from Australia. I hope he is okay publishing this instruction here in this forum. --> h**s://www.meteocercal.info/forum/Thread-Cumul ... ed-Backups


Prerequisite for this task is that you already have CumulusMX installed and successfully running on your Raspberry Pi. In this case, I am running a Raspberry Pi 3 with Raspbian (Jessie) with Noobs v1.9.0 and I'm using the built-in wireless network interface on the Pi3. I'll give brief outlines below only, and presume that you have some basic understanding and knowledge of Linux and Windows.

Mountpoint to External Host

First step is to setup a mountpoint to an external host on your network. This can be a NAS device, a server or a workstation on your network. On the selected host, create a new user and password, something like 'Raspi' and p@ssw0rD for example. Then create a new share, something like "backup", and give the new user full RW access to the share. Then create a folder in the new share called Backup_CumulusMX, to hold your backups.

We'll go with the examples above, and presume the host is called "server" and its IP address is 192.168.1.1.

You'll need cifs on your Pi, and it seems to be there preinstalled on the later releases of Raspbian. Check if it is installed with:
dpkg -s cifs-util

If cifs is not installed, fetch it with:
sudo apt-get install cifs-utils

Now you need to create a new directory for the mountpoint on your Pi. Open a shell and do the following:
cd /mnt
sudo mkdir server
sudo mkdir /server/backup

Now you need to create the new mountpoint in the fstab file for cifs.
sudo nano /etc/fstab

Add the following line to the bottom of the file (note this is all one line):
//192.168.1.1/backup /mnt/server/backup username=raspi,password=p@ssw0rD,uid=1000,gid=1000,iocharset=utf8 0 0

Now mount the new drive share:
sudo mount –a

Give the mount a few seconds to complete, and if all was well you should be able to browse down your MNT path into the backup share that you created on your network host:
cd /mnt/server/backup/Backup_CumulusMX

At this point, if you copy a file to the share on that network host, from your Windows PC, you should see it on your Raspberry Pi now (ls -l).

To test permissions are correct on the share, on the Raspberri Pi create a test file:
cd /mnt/server/backup/Backup_CumulusMX
sudo nano test1.txt

Save and exit nono editor, and you should see the file in the share, on the host device. If you got this far, all is well with your mountpoint to the external host

Setup Backups in CumulusMX

Go back to your home drive on the Pi, with cd ~
Then CD into the CumulusMX directory. Edit the CumulusMX config file:
sudo nano cumulusmxsh.conf

Add the cifs share as the backup path:
BACKUPFOLDER= "/mnt/server/backup/Backup_CumulusMX/"

Now you can run quick manual (one off) test backup:
sudo ./cumulusmx.sh -b -t

If this worked ok you should have a TAR backup in your network share, and your good to setup the scheduled task next.

Schedule Automated Nightly Backups

To acheive the automated backups, you'll add a scheduled task to the CRONTAB to do the nightly backups:
sudo crontab –e

if asked, select 'nano' as your editor (easiest)

Insert a new line at the bottom of the crontab file:

00 01 * * * sudo /home/pi/CumulusMX/cumulusmx.sh –b –t >> /dev/null 2>&1

Alt-X, Y to save, Enter to select the filename

This example will backup every night at 1am. By default, the cumulusmx.sh script will keep the last five backups, in a rolling window, so your backup share should never fill over time. You can edit the number of kept backups in the cumulusmxsh.conf file.

Hope this info helps. If I've made any typos or something doesn't like or work right, post below and together we'll work it out.

Re: CumulusMX Start|Stop - Management Script (CumulusMX 2.5.5.4)

Posted: Sun 03 May 2020 3:18 pm
by HansR
Hi @jank: During the beta test of CMX 3.6.0 it appeared that the start/stop script does stop Cumulus by a signal that does not equal ctrl-C. So it may be useful if you communicate the signal sent with @mcrossley to get a correct ending of Cumulus. Apparently ctrl-C is not the same everywhere.

Re: CumulusMX Start|Stop - Management Script (CumulusMX 2.5.5.4)

Posted: Mon 04 May 2020 3:52 pm
by jank
HansR wrote: Sun 03 May 2020 3:18 pm Hi @jank: During the beta test of CMX 3.6.0 it appeared that the start/stop script does stop Cumulus by a signal that does not equal ctrl-C. So it may be useful if you communicate the signal sent with @mcrossley to get a correct ending of Cumulus. Apparently ctrl-C is not the same everywhere.
Thank you Hans....are you allowed to send me this beta ? I have a running RaspberryPi in spare where I can test witjhout loosing data......
I checked the script and am I right, it is always when your want to send a stop signal to the mono process in case of restarting or ending the mono session ?

How to you stop the mono session in this new bneta, when running mono (cumulusmx) interactive ?
Jan

Re: CumulusMX Start|Stop - Management Script (CumulusMX 2.5.5.4)

Posted: Mon 04 May 2020 5:33 pm
by HansR
The beta is actually finished, I think Mark will release tonight. If he doesn't i'll send you the 3.6.0 later this evening.
I think it is important it is done in communication with Mark. It is a part of code I don't really know, I just saw how you stop cumulus.
I can send you the beta in an hour or so.

And I don't stop cumulus interactive, I just use "cumulusmx.sh -q". It does stop of course, but not in the regular way. That's how we found out something was wrong. Apparently either cumulus does not receive a ctrl-C signal (or mono does not transfer the signal to Cumulus) or the signal is not the same as under windows.
Hans

Re: CumulusMX Start|Stop - Management Script (CumulusMX 2.5.5.4)

Posted: Mon 04 May 2020 8:08 pm
by jank
HansR wrote: Mon 04 May 2020 5:33 pm And I don't stop cumulus interactive, I just use "cumulusmx.sh -q". It does stop of course, but not in the regular way. That's how we found out something was wrong. Apparently either cumulus does not receive a ctrl-C signal (or mono does not transfer the signal to Cumulus) or the signal is not the same as under windows.
Hans
Hans, in my Code, I first send a ctrl+c and After a few seconds a kill -9 Pid
Thats the Reason why the Script does stop cumulus

Re: CumulusMX Start|Stop - Management Script (CumulusMX 2.5.5.7)

Posted: Fri 26 Jun 2020 10:18 am
by laulau
Hi,
simple basic question
How to update the script ?
Thanks

Re: CumulusMX Start|Stop - Management Script (CumulusMX 2.5.5.7)

Posted: Fri 26 Jun 2020 10:27 am
by ConligWX
laulau wrote: Fri 26 Jun 2020 10:18 am Hi,
simple basic question
How to update the script ?
Thanks
just install it as a new version as instructed on the original post.

Re: CumulusMX Start|Stop - Management Script (CumulusMX 2.5.5.7)

Posted: Tue 07 Jul 2020 12:07 pm
by jank
ConligWX wrote: Fri 26 Jun 2020 10:27 am
laulau wrote: Fri 26 Jun 2020 10:18 am Hi,
simple basic question
How to update the script ?
Thanks
just install it as a new version as instructed on the original post.
Sorry for answering late...I was on holiday-
Basically yes, true. replace the existing cumulusmx.sh file with the new one. More or less all code is in the main file cumulusmx.sh
There is a second file which is initially needed which is called cumulusmxsh.conf
(In case you are updating this script, you don't need to replace the cumulusmxsh.conf)
This file is a config/settings file where you can make you path settings etc......

Most code changes are in the main file cumulusmx.sh and in case there are new settings added in the cumulusmxsh.conf file, they will be added automatically by the main script.
So the only thing you need to do if you want to update the script is:
1. replace cumulusmx.sh with the new version
2. Set the file permissions by using this command: chmod +x cumulusmx.sh (will make the script executable)

-jan

Re: CumulusMX Start|Stop - Management Script (CumulusMX 2.5.5.7)

Posted: Wed 16 Sep 2020 5:49 pm
by Barpm
Hi,

is this script always valid running Cumulus MX as service using the newer systemd control?

Thanks

Re: CumulusMX Start|Stop - Management Script (CumulusMX 2.5.5.7)

Posted: Thu 17 Sep 2020 3:38 am
by HansR
If you use the systemd method of starting/stopping then basically there is no longer need for the start/stop script of @jank. Stronger, you can notuse them the same time. For the backup - if you used it - you would need to find / make another solution.

Re: CumulusMX Start|Stop - Management Script (CumulusMX 2.5.5.7)

Posted: Sun 20 Sep 2020 10:25 am
by billy
HansR wrote: Thu 17 Sep 2020 3:38 am For the backup - if you used it - you would need to find / make another solution.
Hans, I run MX as a service and use systemd - it really simplifies things - but I still use the start/stop script and crontab to create a daily zip backup. It seems to work OK. Should I be concerned? :?

Re: CumulusMX Start|Stop - Management Script (CumulusMX 2.5.5.7)

Posted: Sun 20 Sep 2020 10:40 am
by HansR
billy wrote: Sun 20 Sep 2020 10:25 am
HansR wrote: Thu 17 Sep 2020 3:38 am For the backup - if you used it - you would need to find / make another solution.
Hans, I run MX as a service and use systemd - it really simplifies things - but I still use the start/stop script and crontab to create a daily zip backup. It seems to work OK. Should I be concerned? :?
Try to restore it, than you'll know :lol:

Point is that the start/stop script (if I remember well) tries to stop Cumulus, make the backup and start it again. That start/stop does not work anymore. As a consequence, I assume CMX is still running while making the backup which means that it may try to get open files (those are not many I assume). Backing up open files is not a guaranteed success.

I think you are OK, but it's just something I don't do: backing up live systems. I shutdown running programs, backup and start the programs again.

Re: CumulusMX Start|Stop - Management Script (CumulusMX 2.5.5.7)

Posted: Sun 20 Sep 2020 10:57 am
by freddie
If the script uses init.d and doesn't try to do anything clever (like removing lock/pid files) then it should be okay, as under the covers calls to init.d are passed to systemd. I wouldn't want to assume anything, though, and would thoroughly test it first. It should be apparent from looking at MXdiags files whether or not clean stop/start is occurring.