In the Cumulus Support forum, there are articles about a stop/start routine, a backup routine, and how to run MX as a service. I will let you hunt for and read the relevant topics, as you may find details in more than one place. This article will avoid these and try to keep it simple.
= oldAdding notesa web server =
== Ensuring up to date ==
These comprehensive notes describe how to install Cumulus MX on a Pi Zero, using a PC to do some of the work:
As before, we run <tt>sudo apt update && sudo apt upgrade -y</tt> to ensure all packages are up to date before we attempt to add another package.
== Install Apache 2 ==
'''
Download useful PC software and install on your PC'''
These instructions are for a Windows PC. Steps would be similar on a Mac, but programs and details would differ. Should also be possible with an Android tablet.
* SD Formatter (the Windows Format facility will NOT do)
**
* balenaEtcher (for unzipping and burning images to SD cards) [Previously named 'Etcher'] <tt>https://etcher.io/</tt>
* Win32DiskImager (for backup & restore of SD card images) <tt>https://sourceforge.net/projects/win32diskimager/</tt>
* PuTTY
* FileZilla (an FTP file transfer program for Windows) <tt>https://filezilla-project.org/download.php</tt>
Apache is not the only web server software, but it is probably the most comprehensive, so if you have enough space on your Pi, install it using <tt>sudo apt install apache2 -y</tt>.
'''Download Raspbian Pi Operating System'''
* Save it on your PC, from https://www.raspberrypi.org/downloads/raspbian/
* "RaspBIAN Buster Lite" is probably OK, but other than small file size it offers no advantage over installing the full version of RaspBIAN Buster. These instructions are being tested using "Raspbian Buster with desktop and recommended software", the largest of all, which could allow you to do other things more easily.
* Just click on “Download Zip” (torrent might be faster if you have the ability, but not worth installing just for this)
* Do not unzip it
* These instructions have been tested with kernel version 4.14, released 18 April 2018 and with kernel version 4.14, released 13 November 2018 [March 2019] and kernel version 4.19 released 10 July 2019
== Install PHP Hypertext Pre-processor ==
'''Install Pi Operating System onto Micro SD card'''
PHP is not the only script language available, but it is quite comprehensive being able to be used either in a fairly simple way or in an object-oriented way for those trying to achieve more complex scripts. The instruction to install it is <tt> sudo apt install php -y</tt>.
''Format the SD card''
* Put Micro SD card in PC (use adapter if needed)
** If re-using a previous Pi SD card, click ‘Cancel’ on the warning about needing to format the card
* Run SD Card Formatter (click Yes to ‘Allow to make changes to your device’).
** Need to use this program rather than the Format tool in File Explorer, because Pi SD cards end up with a very small ‘Windows accessible’ partition and a large partition containing Linux. SD Card Formatter allows reclaim of the large partition.
* Your SD card should automatically populate in the ‘Drive’ box. In case you have another SD card in your PC, ensure the correct card is selected!
* Click ‘Format’ and check and accept the Warning messages
You may wish to create a index.php web page at /var/www/html which is the web server root for browsing, or of course you may wish to copy or FTP here all your existing web pages.
'''Copy the Pi Raspbian Operating System onto the card'''
* Run '''balenaEtcher''' on your PC
* Click ‘Select Image’ and choose the ‘Raspbian Buster’ operating system zip file that was downloaded earlier
* SD card should be automatically populated. In case you have another SD card in your PC, ensure the correct card is selected!
* Click ‘Flash!’. The operating system will be copied to the card. This takes about 10 minutes, followed by another 8 minutes to ‘Verify’
* Cancel any messages about needing to Format the card - they are just indicating that Etcher has installed the partition that cannot be read by Windows
* On completion, the card is ‘ejected’ from the PC. Physically remove it and then straight away reinsert it so that the content can be viewed in File Explorer
* TWO drives will now be visible for the SD card. You will likely see a warning that one of the drives needs to be formatted before it can be used. ‘Cancel’ that warning and ignore that drive.
* View the other drive, which is named ‘boot’ in File Explorer
* On the View tab, ensure the ‘File Name extensions’ is ticked
* Right click and select ‘New’, ‘Text document’. Change its name to SSH (deleting the .txt extension; you need to make an empty file called SSH not SSH.txt). Click ‘Yes’ to ‘Are you sure you want to change the extension?’
* Right click and select ‘New’, ‘Text document’. Change its name to wpa_supplicant.conf (deleting the .txt extension; you need to make a file called wpa_supplicant.conf not wpa_supplicant.conf.txt). Click ‘Yes’ to ‘Are you sure you want to change the extension?’
* Right click on this new file and select ‘Open with Notepad’ or ‘Open with …’ then select Notepad. Enter the following content exactly as below (copy and paste) then edit your country code (if needed), WiFi network’s SSID and password: NOTE: Change GB as needed to be the code for your country. The quote marks should appear in the file, that is ssid="YourNetwork" not ssid=YourNetwork . Same for psk.
== Install Maria database ==
Since MySQL database is controlled by Oracle, Maria is an alternative that has largely similar command syntax so is likely to work with code (like MX) designed to work with MySQL. Since the MX developer (Mark Crossley) actually uses Maria DB we can have plenty of confidence it is suitable. To install it we type <tt>sudo apt install mariadb-server php-mysql -y</tt>.
* Not essential, but I like to keep copies of both those files for future use. They can be on the SD card with different names eg ‘SSH - Copy’ and ‘wpa_supplicant.conf - Copy’ as well as on your PC
* The function of these 2 files is to connect your Raspberry Pi to your network as soon as it boots, and allows you to connect to and control it from your PC by SSH using PuTTY. This avoids needing to connect a keyboard, mouse and monitor to the Raspberry Pi. It is particularly useful for Pi Zero W (or Pi Zero) which hasn’t got enough USB connections and no Ethernet (wired network) connection. This is called ‘Headless operation’.
* Right click on the ‘boot’ SD card in left pane of File Explorer and ‘Eject’ it safely.
== Restarting Apache ==
'''Setting up the Raspberry Pi'''
* With nothing plugged into the Raspberry Pi, take the Micro SD card from your PC and put it in the Pi.
* In a later step, you will need to find out the Raspberry Pi’s IP address by looking at your network router’s web interface. I can’t help you with doing that. If you don’t know how to, an alternative is to connect a keyboard, mouse and monitor to the Raspberry Pi at this stage
* Plug the power supply into the Raspberry Pi. It will boot up (note flashing red and/or green LEDs depending on model).
* On your PC, log into your network router’s web interface and identify the Pi’s IP address, which will be in the form xxx.xxx.xxx.xxx, for example 192.168.1.123
** NOTE: If you will be switching from a faster “build” Raspberry Pi to a “production” Raspberry Pi Zero W, the IP address will change, so you’ll need to repeat this step later
** While in your network router for the ‘production’ Pi you will be using, set up some port forwarding that will be needed later.
** Forward port 8998 to your Pi’s IP address for TCP protocol if you want to be able to access the Cumulus web interface from the external internet (this brings potential security risk though). [Forwarding port 8002 as well was previously needed].
* Start PuTTY on your PC. In the box for ‘Host Name or IP address’, enter the Pi’s IP address from above. In the adjacent ‘Port’ box, enter 22. Connection type should be SSH. Click ‘Open’.
* A window opens. The first time you do this you will probably see a long message asking to confirm it is OK to connect to a not-previously-known device. Click ‘Yes’.
* Login to the Pi. Username is pi [lower case] and password is raspberry [lower case]
* You will see a warning that SSH is enabled but the password has not been changed, which is a security risk. We will change the password in a moment
* Type
<pre>sudo raspi-config</pre>
After all these installs, we need to restart Apache (so it loads the PHP and MariaDB), by typing <tt>sudo service apache2 restart</tt>.
* Note, to copy from here (usually need to do 1 line at a time), select it then CTRL-C. To paste into the PuTTY window, right click.
== Making your database secure ==
We need to assign passwords to control access to the database by typing into terminal <tt>sudo mysql_secure_installation</tt>. That brings up a screen:
# where we are asked to type current password for the root (as no password has yet been set, simply press Enter),
# next type '''Y''' to signify we are going to set a new password for '''root''',
# next type in a new password that you will not forget,
# next as explained on the screen we are going to say whether users must select a user name as well as a password, type '''Y''' to ''Remove anonymous users''
# next we have to decide whether we will only be logging into the database on our Pi (using Localhost) or we might be logging in remotely; type Y or N respectively, but if you choose N remember someone other than you might guess there is a root user and might guess the password you set,
# next we have another option of whether to retain or delete a test database, answer N or Y respectively, I would keep the test database for now as you can play with it and then remove it later,
# finally you type in another Y as that will '''Reload the privilege tables''' and ensure all is set up for your access to the database later.
The message when the process sucessfully completes is "Thanks for using MariDB".
== Installing PHPMyAdmin ==
PHPMyAdmin is not the only tool that can be used to manipulate your MySQL like database (that is the significance of the "My" bit in the middle of the tools's name), and you may prefer to load a different tool, perhaps one that works using a drill down approach. However, let me assume that you are happy to use PHPMyAdmin and I will describe how to install that. Start the install with <tt>sudo apt install phpmyadmin -y</tt>.
The installer will ask some questions. Use your tab key to select <Yes> when it asks whether you want to configure with '''dbconfig-common'''. We need to add the mysqli module to our php install, to restart apache, and to move the phpadmin to the server web root so it can be seen in our browser:
<pre>sudo phpenmod mysqli
sudo service apache2 restart
sudo in -s /usr/share/phpmyadmin /var/www/html/phpmyadmin</pre>
You can view any index.php or PHPMyADmin web page in your browser by prefixing the address with your Pi URL e.g. '''http://192.168.1.xy/phpmyadmin''' where x and y are digits you look up as mentioned before where FTP of MX distribution was described. In this case you will see a PHP MyAdmin log on page where you type username and password (as you may not have added any other user yet, the user will be root).
In the steps below, you will need to press '''y''' to agree to proceed at various times
If you have been building the Micro SD card on a fast Pi, now is the time to switch to the 'production' Pi, for which a slower Pi Zero W is more than adequate.
Shut down the Raspberry Pi safely.
<pre>sudo halt</pre>
'''Move the micro SD card to the Pi Zero W'''.
Power on the Pi Zero W. Your SSH (PuTTY) session will close out and you'll need to reconnect after the Pi has rebooted. Use username pi and the new password you chose earlier.
'''Add the ‘Mono’ package'''
* Simplification: Mono is a package which allows programs to be written cross-platform so that they will run on Linux (including Raspberry Pi), Windows and Mac OS, similar to the Windows ‘.NET Framework’.
* The previous anomaly with the USB library not working with later versions of mono, affecting Fine Offset stations and the later Oregon Scientific stations (WMR88/100/200 etc) has been fixed (''in CumulusMX build 3044 onwards'') and these and other stations should now be fine with later/current versions of mono. I am currently using a Fine Offset with mono v5.18
* Process is to install a security certificate, add the mono server to the list of software sources [sources.list] that the Pi searches, then install the mono-complete package:
<pre>sudo apt-get update && sudo apt-get upgrade
sudo apt-get install -y mono-complete
sudo apt autoremove</pre>
At the time of writing (''18 Sep 2019''), this gets Mono v6.0.0.334, which works with Buster (RaspBIAN 10). However, there have been reports of incompatabilities which require use of an older version of Mono. These may have now been fixed, or alternatively may be related to use of locales other than en_GB.UTF-8 . Please see other threads in Support Forum for discussions.
NOTE: ''29 Feb 2020'': added '''-y''' into the line '''sudo apt-get install -y mono-complete''' . This makes the install bypass the usual 'Continue Y/n?' prompt¨which was causing strange problems for some, e.g. worked if just pressed 'Enter' to accept default 'Y', but aborted installation if pressed 'Y Enter'. Bizarre.
'''
Reboot your Raspberry Pi'''
This would be a reasonable time to reboot your Pi:
<pre>sudo reboot</pre>
Your SSH (PuTTY) session will close out and you'll need to reconnect after the Pi has rebooted. Use username pi and the new password you chose earlier.
'''
Install Cumulus MX on the Raspberry Pi'''
Download it [[Software|from here]] to your PC, unzip on your PC which makes a directory named CumulusMX. Remember where that directory is located then on PC run FileZilla
# In the ‘Host’ box, enter the Raspberry Pi’s IP address eg 192.168.1.123
# In Username, enter pi
# In Password enter your pi’s password
# In Port, enter 22
# Click ‘Quickconnect’. Raspberry Pi’s directory structure appears on the right and your PC’s directory structure is on the left.
# In the LEFT window, navigate to where you unzipped the download of Cumulus MX earlier. Ensure can see the folder name ‘CumulusMX’ in the lower left window
# In the RIGHT window, ensure that the folder /home/pi is shown (see top right window; contents in bottom right window include .cache, .config etc)
# Drag the folder ‘CumulusMX’ to an empty area in the lower right window (not onto one of the existing directories). Watch progress as this copies the whole CumulusMX folder and contents to directory ~/CumulusMX on the Pi
# Close FileZilla
'''On Raspberry Pi PuTTY window:'''
<pre>sudo halt</pre>
Plug your USB weather station into the Raspberry Pi – USB cable into the OTG connector (probably via an adaptor lead) if using Raspberry Pi Zero W.
If you have an ethernet or WiFi linked weather station then you won't need to do this - I don't have one so I don't know exact details. Steve below says you need to enter the IP address during Cumulus setup, but then also adjust a disconnect period if you are also using Weatherlink software.
'''Running Cumulus'''
On PC, run PuTTY again and log in to the Pi as before (note you can save the IP address between sessions)
<pre>cd ~/CumulusMX
sudo mono CumulusMX.exe</pre>
The next thing you will want to do is access Cumulus via its '''user interface''' from your PC, so that you can update the '''settings'''. Using the IP address for your Pi, in your internet browser, enter: 192.168.y.z:8998 (where y and z are numbers you will need to find from seeing how your router connects to your Pi. You’ll first see a dashboard page, then can access the Settings menu.
To make Cumulus run each time the Pi is rebooted (and force reboot in the early hours each day)
On the Pi, type:
<pre>sudo crontab -e</pre>
On first run select the text editor you prefer (defaults to #1, nano, the easiest)
Then add the following lines at the end of the file:
<pre># Start Cumulus as background task 30s after reboot (delay to allow WiFi to startup)
@reboot (sleep 30;cd /home/pi/CumulusMX;sudo mono CumulusMX.exe) &
# Reboot each day at 0253
53 02 * * * sudo reboot</pre>
'''To stop the Pi and restart it without CumulusMX running'''
(eg you need to do that if upgrading the CumulusMX version) type the following
<pre>sudo crontab -e</pre>
'''edit to put a # at the start of the line''' "@reboot..."
Ctrl-X to save the change to crontab and reboot using
<pre>sudo reboot</pre>
When your pi restarts, CumulusMX will no longer be running. You can then do your version upgrade or other task.
To revert to normal auto-running of CumulusMX, go through the same again, but this time edit crontab to remove the # from the start of the line "@reboot...". Save changes and reboot - CumulusMX will be running.
Updating a version of CumulusMX is easily done as follows using this:
1. Stop CumulusMX running (it locks files while it is running)
2. Install the updated CumulusMX version into a new directory - I call mine CumulusMX3xyz (where xyz are the last 3 digits of the build number) so that I can easily see which build it is
3. copy the following from the old CumulusMX directory to the new CumulusMX3xyz directory:
- your CumulusMX/Cumulus.ini file
- your CumulusMX/data directory
- your CumulusMX/twitter.txt file (if you have personalised it)
- your CumulusMX/web directory (if you have personalised any web files)
4. Change your startup instruction to use the version in the new directory eg cd /home/pi/CumulusMX3050;sudo mono CumulusMX.exe
With that method you can easily revert back to the old version if something has gone wrong. If all is well, you can delete the old directory after a few days/weeks/months/if you need the space.
'''Updating mono version'''
*First, stop CumulusMX as above by editing crontab.
*Then remove the present version of mono:
<pre>sudo apt-get purge libmono* cli-common mono-runtime
sudo apt-get autoremove</pre>
*Then install the new version
<pre>sudo apt-get install mono-complete</pre>
*Finally re-enable auto running by editing crontab to remove the # and finally
<pre>sudo reboot</pre>
Above Instructions: Last edited by ExperiMentor on Sun 01 Mar 2020 8:17 am,
|