MX on Linux: Difference between revisions

250 bytes added ,  09:06, 23 April 2021
m
no edit summary
m (change sequence)
mNo edit summary
Line 48: Line 48:
<pre>sudo apt-get update
<pre>sudo apt-get update
sudo apt-get upgrade</pre>
sudo apt-get upgrade</pre>
'''or''' to insert in single line type instead <tt>sudo apt-get update && sudo apt-get upgrade</tt>.
'''or''' to insert in single line type instead <code>sudo apt-get update && sudo apt-get upgrade</code>.


= Installing Mono =
= Installing Mono =
Line 78: Line 78:
== Installing Mono instruction ==
== Installing Mono instruction ==


With all the pre-requisites correct as in previous steps, you can install mono package by simply typing <tt>sudo apt-get install -y mono-complete</tt>.  
With all the pre-requisites correct as in previous steps, you can install mono package by simply typing <code>sudo apt-get install -y mono-complete</code>.  
*The "sudo" part of this gives us super-user rights when executing the instruction that follows
*The "sudo" part of this gives us super-user rights when executing the instruction that follows
*The "apt-get" is one of the ways to search the Raspberry repository for applications, it is more powerful than just "apt"
*The "apt-get" is one of the ways to search the Raspberry repository for applications, it is more powerful than just "apt"
Line 85: Line 85:
*The "mono-complete" is the package we want.
*The "mono-complete" is the package we want.


With latest installs of rPi, you can also use <tt>sudo apt install mono-complete -y</tt>
With latest installs of rPi, you can also use <code>sudo apt install mono-complete -y</code>


It is important to note that MX requires the ''complete'' edition of mono. (There is also a cut-down developer edition of Mono that can be downloaded/installed, and that is the default installation).
It is important to note that MX requires the ''complete'' edition of mono. (There is also a cut-down developer edition of Mono that can be downloaded/installed, and that is the default installation).
Line 91: Line 91:
==Tidying Mono  Installation==
==Tidying Mono  Installation==


Installing mono-complete has probably added some components not needed for your particular Linux distribution. To remove unneeded components type <tt>sudo autoremove</tt>.
Installing mono-complete has probably added some components not needed for your particular Linux distribution. To remove unneeded components type <code>sudo autoremove</code>.


Now you have what is needed to run any executable related to Cumulus, not just '''CumulusMX.exe'''.
Now you have what is needed to run any executable related to Cumulus, not just '''CumulusMX.exe'''.
Line 99: Line 99:
As the Pi does not know exactly which components are needed when multiple packages are installed with various dependencies, sometimes extra components are installed which in the end are not needed when you complete all your installations.  
As the Pi does not know exactly which components are needed when multiple packages are installed with various dependencies, sometimes extra components are installed which in the end are not needed when you complete all your installations.  


To clear up, delete any components that are not included in dependencies by typing <tt>sudo apt autoremove</tt>.
To clear up, delete any components that are not included in dependencies by typing <code>sudo apt autoremove</code>.


=Cumulus MX =
=Cumulus MX =
Line 121: Line 121:


The download and unzip procedure is exactly same on your Raspberry Pi, as it would be on a Windows PC:
The download and unzip procedure is exactly same on your Raspberry Pi, as it would be on a Windows PC:
# It is recommended, you type <tt>sudo mkdir EXISTING PATH/CumulusMX</tt> first, so you already have folder ready for MX, but the file can be created by unzipping the distribution into home directory ('''~''').
# It is recommended, you type <code>sudo mkdir EXISTING PATH/CumulusMX</code> first, so you already have folder ready for MX, but the file can be created by unzipping the distribution into home directory ('''~''').
#Run the browser you have available on your Raspberry Pi (the installed browser depends on what Operating System you installed)
#Run the browser you have available on your Raspberry Pi (the installed browser depends on what Operating System you installed)
#To find the link to latest release distribution zip in the Cumulus Wiki, open the [[Software#Current_Release|Software article in the Current_Release section]].
#To find the link to latest release distribution zip in the Cumulus Wiki, open the [[Software#Current_Release|Software article in the Current_Release section]].
Line 137: Line 137:
Follow above instructions, again.
Follow above instructions, again.


'''Either''' install new release on top of old release, '''or''' install in new place (follow all instructions as if new installation for adding existing log files) remembering that <tt>sudo mono CumulusMX.exe</tt> instruction has to be issued in new place.
'''Either''' install new release on top of old release, '''or''' install in new place (follow all instructions as if new installation for adding existing log files) remembering that <code>sudo mono CumulusMX.exe</code> instruction has to be issued in new place.


== MX Back-up issues ==
== MX Back-up issues ==
Line 179: Line 179:
**Your remote file names, if you have a local server as set up in the notes in the optional sections later, will look like ''/var/www/html/weather/trends.html'' or '''/var/www/html/weather/js/valuesRecentForTrends.js''', depending on your folder structure.   
**Your remote file names, if you have a local server as set up in the notes in the optional sections later, will look like ''/var/www/html/weather/trends.html'' or '''/var/www/html/weather/js/valuesRecentForTrends.js''', depending on your folder structure.   
**If you pay for a commercial web server, remote file names will be as specified by them and not dependent on what device MX is on.  
**If you pay for a commercial web server, remote file names will be as specified by them and not dependent on what device MX is on.  
**Remember ''if web site is on your Pi'', MX needs full '''rw''' permissions to the HTML folder on your web site,  so give permissions recursively using <tt>sudo chmod -R ugo+rw /var/www/html</tt> for Cumulus MX to successfully copy there.
**Remember ''if web site is on your Pi'', MX needs full '''rw''' permissions to the HTML folder on your web site,  so give permissions recursively using <code>sudo chmod -R ugo+rw /var/www/html</code> for Cumulus MX to successfully copy there.


== Keeping existing data and Reports files ==
== Keeping existing data and Reports files ==
Line 207: Line 207:
*The quickest way in WinSCP is to use its command line options.
*The quickest way in WinSCP is to use its command line options.
*The following apply to all clients using GUI.
*The following apply to all clients using GUI.
* Host - this is the IPv4 address of your Pi, I can't tell you what it is, but it is likely to be '''192.168.z.xy''' where the z is probably "1", but it could be another single figure like 0, and the xy is two (or perhaps three) figures you can find out by looking for "pi" (or whatever host username you have set on your Pi) in the admin interface for your hub or router. (It can also be found out by typing <tt>hostname -I</tt>). Most networks are setup in a way that the subnet range is from 192.168.1.0 to 192.168.1.255.
* Host - this is the IPv4 address of your Pi, I can't tell you what it is, but it is likely to be '''192.168.z.xy''' where the z is probably "1", but it could be another single figure like 0, and the xy is two (or perhaps three) figures you can find out by looking for "pi" (or whatever host username you have set on your Pi) in the admin interface for your hub or router. (It can also be found out by typing <code>hostname -I</code>). Most networks are setup in a way that the subnet range is from 192.168.1.0 to 192.168.1.255.
**If your Raspberry Pi has both Wireless and Ethernet connections, you will have two possible IPv4 addresses, choose either, the Ethernet one is likely to be quicker.
**If your Raspberry Pi has both Wireless and Ethernet connections, you will have two possible IPv4 addresses, choose either, the Ethernet one is likely to be quicker.
* Username - the default for this is '''raspberrypi''' (although on older Pi it might be '''Pi'''), but you can may have changed this (as described earlier). (It can be found by typing <tt>hostname</tt>) or by looking at the contents of the file '''/etc/hostname'''.
* Username - the default for this is '''raspberrypi''' (although on older Pi it might be '''Pi'''), but you can may have changed this (as described earlier). (It can be found by typing <code>hostname</code>) or by looking at the contents of the file '''/etc/hostname'''.
* Password - again the default for this is '''raspberry''' but we changed it as one of the mandatory configurations earlier.
* Password - again the default for this is '''raspberry''' but we changed it as one of the mandatory configurations earlier.
* Port - 22 is the default, (and I have not said how you can change this on a RPi!)
* Port - 22 is the default, (and I have not said how you can change this on a RPi!)
Line 225: Line 225:
=== Optional parameters to add to the instruction to run the MX engine ===
=== Optional parameters to add to the instruction to run the MX engine ===


Beta builds in MX version 3.0.0 had an optional parameter <tt>-wsport nnnn</tt> that determined which port (represented by a 4 digit number ''nnnn'') was used for '''WebSockets'''. That parameter is now deprecated as WebSockets in all builds since 3045 uses the same port as the rest of the [[MX_Administrative_Interface#The_API_interface|Admin Interface]]. The remaining parameters that are still available are described in subsequent sub-sections.
Beta builds in MX version 3.0.0 had an optional parameter <code>-wsport nnnn</code> that determined which port (represented by a 4 digit number ''nnnn'') was used for '''WebSockets'''. That parameter is now deprecated as WebSockets in all builds since 3045 uses the same port as the rest of the [[MX_Administrative_Interface#The_API_interface|Admin Interface]]. The remaining parameters that are still available are described in subsequent sub-sections.


==== Parameter for changing Port ====
==== Parameter for changing Port ====
Line 268: Line 268:
#Find the '''EXISTING PATH/CumulusMX/MXutils/linux/''' sub-folder, that might be in home directory and therefore found using "~/CumulusMX/MXutils/linux" as explained elsewhere on this page
#Find the '''EXISTING PATH/CumulusMX/MXutils/linux/''' sub-folder, that might be in home directory and therefore found using "~/CumulusMX/MXutils/linux" as explained elsewhere on this page
#* At time of typing this, the sub-folder only contains one file, the one we need to edit
#* At time of typing this, the sub-folder only contains one file, the one we need to edit
# As described later there is a choice of editors, but you can use <tt>sudo nano cumulusmx.service</tt> to edit the service configuration file
# As described later there is a choice of editors, but you can use <code>sudo nano cumulusmx.service</code> to edit the service configuration file
# Look for '''ExecStart=/usr/bin/mono-service -d:'''
# Look for '''ExecStart=/usr/bin/mono-service -d:'''
#* Replace the path that follows the above text with the path to your CumulusMX.exe, add the '''-service''' and optionally add any other parameter (e.g. '''-debug''', -locale, -port) as described in sub-sections above.
#* Replace the path that follows the above text with the path to your CumulusMX.exe, add the '''-service''' and optionally add any other parameter (e.g. '''-debug''', -locale, -port) as described in sub-sections above.
#save file
#save file
#now copy file  
#now copy file  
:<tt>sudo cp EXISTING_PATH/CumulusMX/MXutils/linux/cumulusmx.service /etc/systemd/system/</tt>
:<code>sudo cp EXISTING_PATH/CumulusMX/MXutils/linux/cumulusmx.service /etc/systemd/system/</code>


If you upgrade to a new release, the file in EXISTING PATH will be overwritten, but the critical file in "/etc/sytemd/system" will not be affected.
If you upgrade to a new release, the file in EXISTING PATH will be overwritten, but the critical file in "/etc/sytemd/system" will not be affected.
Line 279: Line 279:
===Running as a service===
===Running as a service===


If you want MX to automatically start when your Linux computer is booted, just type <tt>sudo systemctl enable cumulusmx</tt> once, and it will be activated on each reboot.
If you want MX to automatically start when your Linux computer is booted, just type <code>sudo systemctl enable cumulusmx</code> once, and it will be activated on each reboot.


To manually start MX as a service, (such as after any MX upgrade to a new release, or when you want to first run it), simply type <tt>sudo systemctl start cumulusmx</tt>
To manually start MX as a service, (such as after any MX upgrade to a new release, or when you want to first run it), simply type <code>sudo systemctl start cumulusmx</code>




Use <tt>systemctl status cumulusmx.service</tt> in a terminal session to see status of Cumulus service
Use <code>systemctl status cumulusmx.service</code> in a terminal session to see status of Cumulus service




Line 294: Line 294:
Whichever operating system you are using, to run MX requires an instruction that changes to the directory (EXISTING PATH) where it is installed (the instruction below is assuming it is in the standard Pi user home directory, the change directory command will be different if you have installed it elsewhere), and then starting the executable (using mono in the instruction below that applies to any non-Windows operating system). You may wish to add [[Cumulus_MX#Optional_parameters_to_add_to_the_instruction_to_run_the_MX_engine|Optional_parameters]].
Whichever operating system you are using, to run MX requires an instruction that changes to the directory (EXISTING PATH) where it is installed (the instruction below is assuming it is in the standard Pi user home directory, the change directory command will be different if you have installed it elsewhere), and then starting the executable (using mono in the instruction below that applies to any non-Windows operating system). You may wish to add [[Cumulus_MX#Optional_parameters_to_add_to_the_instruction_to_run_the_MX_engine|Optional_parameters]].


The simplest instruction to run Cumulus MX  is <tt>cd EXISTING PATH/CumulusMX && sudo mono CumulusMX.exe</tt>.  Just in case it is not obvious .... if you start MX using this command in a terminal window on your Pi, you must leave that session running, then MX will continue to run.  
The simplest instruction to run Cumulus MX  is <code>cd EXISTING PATH/CumulusMX && sudo mono CumulusMX.exe</code>.  Just in case it is not obvious .... if you start MX using this command in a terminal window on your Pi, you must leave that session running, then MX will continue to run.  


You can start it off directly on your Pi, and then
You can start it off directly on your Pi, and then
Line 301: Line 301:
*Just ensure you leave Pi on (with that window minimised) so that terminal session continues running.
*Just ensure you leave Pi on (with that window minimised) so that terminal session continues running.


Use <tt>'''ps -ef | grep -i cumulus | grep -v grep'''</tt> to see if Cumulus is running or not.
Use <code>'''ps -ef | grep -i cumulus | grep -v grep'''</code> to see if Cumulus is running or not.




Line 613: Line 613:
You need to use the raspbian configuration tool '''raspi-config''',
You need to use the raspbian configuration tool '''raspi-config''',
*this can be accessed on your Pi either in a Graphical User Interface (GUI) where fewer options are available,  
*this can be accessed on your Pi either in a Graphical User Interface (GUI) where fewer options are available,  
*or by running a command <tt>sudo raspi-config</tt> in Terminal where more options are available.
*or by running a command <code>sudo raspi-config</code> in Terminal where more options are available.


==== Mandatory configurations ====
==== Mandatory configurations ====
Line 623: Line 623:
Anyway, we need to replace the host name to personalise it to you, and make it harder for a hacker to know what device is represented by that network name.  
Anyway, we need to replace the host name to personalise it to you, and make it harder for a hacker to know what device is represented by that network name.  
*The name can most easily be changed within either Raspberian configuration utility, you will see a '''Network Options''' option, it is there that you change the network name.
*The name can most easily be changed within either Raspberian configuration utility, you will see a '''Network Options''' option, it is there that you change the network name.
*but it can also be edited by opening the file where it is stored using <tt>sudo nano /etc/hostname</tt>.   
*but it can also be edited by opening the file where it is stored using <code>sudo nano /etc/hostname</code>.   


Some network options can sometimes (depends on permissions) be configured by clicking an icon on the Pi (this icon might be two red crosses if network settings are missing, two parallel arrows if the network settings are not correctly set, or the wireless symbol if your wireless network is working).  
Some network options can sometimes (depends on permissions) be configured by clicking an icon on the Pi (this icon might be two red crosses if network settings are missing, two parallel arrows if the network settings are not correctly set, or the wireless symbol if your wireless network is working).  
Line 655: Line 655:
== su and sudo ==
== su and sudo ==


There is a command <tt>su</tt> that allows a terminal session to become a super user session with root privileges. If you use that command, without a '''sudo''' command in front, you need to type in the password (we changed earlier) when prompted.  if you type <tt>sudo su</tt>, then you get root privileges without being asked to quote password. All subsequent lines in this terminal session will have a prompt that reminds you that you have root access and do not need to prefix subsequent commands with "sudo".
There is a command <code>su</code> that allows a terminal session to become a super user session with root privileges. If you use that command, without a '''sudo''' command in front, you need to type in the password (we changed earlier) when prompted.  if you type <code>sudo su</code>, then you get root privileges without being asked to quote password. All subsequent lines in this terminal session will have a prompt that reminds you that you have root access and do not need to prefix subsequent commands with "sudo".


Normally, all terminal sessions will use the default "pi" user, and for individual commands, you will use a "sudo" prefix each time that command needs administrative rights, as this allows a standard Pi user to do tasks that otherwise only work for the root user.
Normally, all terminal sessions will use the default "pi" user, and for individual commands, you will use a "sudo" prefix each time that command needs administrative rights, as this allows a standard Pi user to do tasks that otherwise only work for the root user.
Line 674: Line 674:
If you are using the RPi OS GUI, it provides a file manager that displays folders and files, and if you have a mouse you can click on an object to see what actions are available.  The file manager has "Home" and "Root" as bookmarks by default, you can bookmark others.  Typically, any new partitions created can also be accessed from bookmarks.  Depending on options you select, there may be icons on the GUI desktop to link to particular folders and clicking on these offers various options including opening them in file manager.
If you are using the RPi OS GUI, it provides a file manager that displays folders and files, and if you have a mouse you can click on an object to see what actions are available.  The file manager has "Home" and "Root" as bookmarks by default, you can bookmark others.  Typically, any new partitions created can also be accessed from bookmarks.  Depending on options you select, there may be icons on the GUI desktop to link to particular folders and clicking on these offers various options including opening them in file manager.


In a terminal environment, to see what files and folders are in the current directory, type <tt>dir</tt> for just names or <tt>ls</tt> for details.
In a terminal environment, to see what files and folders are in the current directory, type <code>dir</code> for just names or <code>ls</code> for details.


== external storage ==
== external storage ==
Line 694: Line 694:
#if your drive has partitions, then you will see further entries like '''/dev/sda1''' and ''/dev/sda2''.
#if your drive has partitions, then you will see further entries like '''/dev/sda1''' and ''/dev/sda2''.
#type '''df''' to see whether your drive is currently mounted (being used by computer system)
#type '''df''' to see whether your drive is currently mounted (being used by computer system)
#if it is mounted, the command to use next is (type this accurately, there is a temptation to type an English word that adds an extra "n"!) <tt>umount /dev/sda</tt>, obviously replace the "a" by the appropriate letter seen in the earlier command
#if it is mounted, the command to use next is (type this accurately, there is a temptation to type an English word that adds an extra "n"!) <code>umount /dev/sda</code>, obviously replace the "a" by the appropriate letter seen in the earlier command
#if the drive does not have a partition, create one using <tt>fdisk /dev/sda</tt>, again changing the "a" into whatever letter was seen in response to the first "fdisk" command
#if the drive does not have a partition, create one using <code>fdisk /dev/sda</code>, again changing the "a" into whatever letter was seen in response to the first "fdisk" command
#*"fdisk" is a utility, it will wait for further instructions, follow each with pressing "Enter"
#*"fdisk" is a utility, it will wait for further instructions, follow each with pressing "Enter"
#*type '''n''' as instruction to create a new partition
#*type '''n''' as instruction to create a new partition
Line 708: Line 708:
#*type '''w''' to create the partition you have now specified for Linux.
#*type '''w''' to create the partition you have now specified for Linux.
#Now we have a partition table and a partition on our drive, we can repeat '''fdisk -l''' to see the entry now added, it might be '''/dev/sda1''', where again the "a" might be a different letter
#Now we have a partition table and a partition on our drive, we can repeat '''fdisk -l''' to see the entry now added, it might be '''/dev/sda1''', where again the "a" might be a different letter
#To format this partition for Linux, we specify "ext4" as the way to format it using <tt>mkfs.ext4 /dev/sda1</tt>, again replacing the "a" as required.
#To format this partition for Linux, we specify "ext4" as the way to format it using <code>mkfs.ext4 /dev/sda1</code>, again replacing the "a" as required.
#we need to create a folder within  
#we need to create a folder within  
#*"/media" for Linux in general
#*"/media" for Linux in general
#*"/media/pi" for Raspberry PI OS
#*"/media/pi" for Raspberry PI OS
# As we will learn later, the relevant command (in RPi OS) is '''mkdir /media/pi/my_short_name''', where "my_short_name" is selected by you
# As we will learn later, the relevant command (in RPi OS) is '''mkdir /media/pi/my_short_name''', where "my_short_name" is selected by you
#To mount our partition, we type <tt>mount /dev/sda1 /media/pi/my_short_name</tt>, where "sda1" is replaced by "sdb1" or whatever we saw in '''fdisk -l''', and "pi/my_short_name" is replaced by whatever we used in our make directory command.
#To mount our partition, we type <code>mount /dev/sda1 /media/pi/my_short_name</code>, where "sda1" is replaced by "sdb1" or whatever we saw in '''fdisk -l''', and "pi/my_short_name" is replaced by whatever we used in our make directory command.
#To (optionally) get our partition mounted at boot, we can use an editor (see later) to change the boot instructions, by typing <tt>nano /etx/fstab</tt>
#To (optionally) get our partition mounted at boot, we can use an editor (see later) to change the boot instructions, by typing <code>nano /etx/fstab</code>
#*In the editor, use the down arrow on your keyboard to move to last line, and then type '''/dev/sda1''' (change the "a" as necessary), then press "tab", then type '''/media/pi/my_short_name''' (change "pi/my_short_name" to whatever we used in our make directory command), then press "tab", then type '''ext4''' (again matching the format type we  selected earlier), then press "tab", then type '''defaults''', then press "tab", then type '''1''', then press "tab", then finally type '''2'''
#*In the editor, use the down arrow on your keyboard to move to last line, and then type '''/dev/sda1''' (change the "a" as necessary), then press "tab", then type '''/media/pi/my_short_name''' (change "pi/my_short_name" to whatever we used in our make directory command), then press "tab", then type '''ext4''' (again matching the format type we  selected earlier), then press "tab", then type '''defaults''', then press "tab", then type '''1''', then press "tab", then finally type '''2'''
#*save the file (as described later in nano sub-section), hold down control key and press '''o'' letter key. Press "enter" again to confirm same file name.
#*save the file (as described later in nano sub-section), hold down control key and press '''o'' letter key. Press "enter" again to confirm same file name.
Line 723: Line 723:
== folder commands ==
== folder commands ==


To make a new folder in the current directory, type <tt>sudo mkdir folder_name</tt>.
To make a new folder in the current directory, type <code>sudo mkdir folder_name</code>.


To remove a directory type in a particular path, type <tt>sudo rmdir /path/directory</tt>. Normally, you need to remove all contents before you can remove the directory. If you are sure it is safe to remove directory and contents in one go, type tt>sudo rmdir -r /path/directory</tt>, but remember the contents are gone for ever, so be absolutely sure you have specified the right folder!  
To remove a directory type in a particular path, type <code>sudo rmdir /path/directory</code>. Normally, you need to remove all contents before you can remove the directory. If you are sure it is safe to remove directory and contents in one go, type tt>sudo rmdir -r /path/directory</code>, but remember the contents are gone for ever, so be absolutely sure you have specified the right folder!  


To copy folders/files from one directory to another use <tt>cp -R --update --preserve /home/pi/CumulusMX/backup/daily /media/pi/data/CumulusMX/archive</tt>
To copy folders/files from one directory to another use <code>cp -R --update --preserve /home/pi/CumulusMX/backup/daily /media/pi/data/CumulusMX/archive</code>


To create a logical pointer to a folder or file elsewhere, within a folder that does not have that folder/file, <tt>ln -s /path/elsewhere path/pointer_location</tt>.  An example might be '''ln -s /usr/share/phpliteadmin/diary.db ~/CumulusMX/data/diary.db''' which would let MX see and update a database maintained by phpLiteAdmin.
To create a logical pointer to a folder or file elsewhere, within a folder that does not have that folder/file, <code>ln -s /path/elsewhere path/pointer_location</code>.  An example might be '''ln -s /usr/share/phpliteadmin/diary.db ~/CumulusMX/data/diary.db''' which would let MX see and update a database maintained by phpLiteAdmin.


=== chmod ===
=== chmod ===


When you are attempting any of the actions listed in this article that involve reading, creating, editing, exeduting, or moving, files; you might see an error message generally because of a lack of write (or execute) permissions on an existing file or folder.  Whilst <tt>rm filename</tt> will remove a file even if it is write protected, for nano you need to change the file permissions with <tt>sudo chmod -R ugo+rw ~/CumulusMX</tt> for modify access to all files in your Cumulus installation (see the syntax below if you want to restrict access).
When you are attempting any of the actions listed in this article that involve reading, creating, editing, exeduting, or moving, files; you might see an error message generally because of a lack of write (or execute) permissions on an existing file or folder.  Whilst <code>rm filename</code> will remove a file even if it is write protected, for nano you need to change the file permissions with <code>sudo chmod -R ugo+rw ~/CumulusMX</code> for modify access to all files in your Cumulus installation (see the syntax below if you want to restrict access).




Line 767: Line 767:
====nano====
====nano====


The full syntax is <tt>sudo nano -B Path_file_name</tt> where the '''-B''' means it will create a backup of how the file was before (this can be enabled while in the editor by pressing the control key down and typing B). Alternatively use '''-C''' which stores each version in a back-up directory.  If you want to edit from a particular line and column you can use '''+line.column''', and also optionally use '''-l''' (lower-case "L") to display line numbers which might be useful when trying to correct a problem with a log file like [[dayfile.txt]].  If you don't specify a file name, then nano will create a new file and you will need to specify where to save it before exit.
The full syntax is <code>sudo nano -B Path_file_name</code> where the '''-B''' means it will create a backup of how the file was before (this can be enabled while in the editor by pressing the control key down and typing B). Alternatively use '''-C''' which stores each version in a back-up directory.  If you want to edit from a particular line and column you can use '''+line.column''', and also optionally use '''-l''' (lower-case "L") to display line numbers which might be useful when trying to correct a problem with a log file like [[dayfile.txt]].  If you don't specify a file name, then nano will create a new file and you will need to specify where to save it before exit.


After typing the nano command you need to specify a filename (it might include a path, see earlier sub-section for use of '''/''' and '''~''') and there are examples later in this article, but if you decide to ''host a web site on your Pi'' then you might want to edit its home page with (.html or .php) name like <tt>sudo nano /var/www/html/index.php</tt>.   
After typing the nano command you need to specify a filename (it might include a path, see earlier sub-section for use of '''/''' and '''~''') and there are examples later in this article, but if you decide to ''host a web site on your Pi'' then you might want to edit its home page with (.html or .php) name like <code>sudo nano /var/www/html/index.php</code>.   


After you have made an alteration to the current contents of the file, various options are shown at the bottom. Here are two key ones:
After you have made an alteration to the current contents of the file, various options are shown at the bottom. Here are two key ones:
Line 776: Line 776:
*Another is '''^X''' which means if you press the control key down and type X you get the exit dialogue. If you have not made any edits, or have already saved the file, this just exits the editor. If you have not used control and O to save the file, it asks whether you want to save the edited file (type '''Y'''), typing just the Y key lets save continue (any other key stroke exits without saving), then it shows the current file name, if you press '''Enter''' then that file will be overwritten.
*Another is '''^X''' which means if you press the control key down and type X you get the exit dialogue. If you have not made any edits, or have already saved the file, this just exits the editor. If you have not used control and O to save the file, it asks whether you want to save the edited file (type '''Y'''), typing just the Y key lets save continue (any other key stroke exits without saving), then it shows the current file name, if you press '''Enter''' then that file will be overwritten.


You might find it useful to type <tt>sudo nano /etc/nanorc</tt> as this puts you into the configuration file for nano where you can set back-up, line-numbering, and other options.
You might find it useful to type <code>sudo nano /etc/nanorc</code> as this puts you into the configuration file for nano where you can set back-up, line-numbering, and other options.


====Geany====
====Geany====
Line 786: Line 786:
== removing an unwanted file ==
== removing an unwanted file ==


You can remove a file with various commands, including <tt>sudo rm filename</tt>.
You can remove a file with various commands, including <code>sudo rm filename</code>.


== install ==
== install ==
Line 820: Line 820:
== Standard action before adding any extra packages ==
== Standard action before adding any extra packages ==


*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.  
*We run <code>sudo apt update && sudo apt upgrade -y</code> to ensure all packages are up to date before we attempt to add another package.  
*I remind you here that this does not update everything on your computer to the latest versions available for a Pi, that requires a different (more risky) command not taught here.   
*I remind you here that this does not update everything on your computer to the latest versions available for a Pi, that requires a different (more risky) command not taught here.   
*Instead, the instruction quoted above just updates your Pi to a consistent state; based on what is in the repository you are already using.
*Instead, the instruction quoted above just updates your Pi to a consistent state; based on what is in the repository you are already using.
Line 840: Line 840:
You can install phpLiteAdmin (the significant part of that name is in the middle) to read (you can display the whole table very easily) and edit (via a friendly GUI) either, or both, of those SQLite databases.  
You can install phpLiteAdmin (the significant part of that name is in the middle) to read (you can display the whole table very easily) and edit (via a friendly GUI) either, or both, of those SQLite databases.  


Install it using <tt>sudo apt install phpliteadmin</tt>. You will need to follow the instructions in '''/usr/share/phpliteadmin/phpliteadmin.php''' to change the password, and to define the path to the database you want to read, as both databases have the wrong extension to be found automatically. You may need to change file permissions, and you may decide to use the symbolic link example given earlier so MX accesses the diary at a location that suits ppLiteAdmin.
Install it using <code>sudo apt install phpliteadmin</code>. You will need to follow the instructions in '''/usr/share/phpliteadmin/phpliteadmin.php''' to change the password, and to define the path to the database you want to read, as both databases have the wrong extension to be found automatically. You may need to change file permissions, and you may decide to use the symbolic link example given earlier so MX accesses the diary at a location that suits ppLiteAdmin.


I find the admin interface is not always reliable for updating the weather diary, MX uses a very simple way to access hardware;  
I find the admin interface is not always reliable for updating the weather diary, MX uses a very simple way to access hardware;  
Line 867: Line 867:


I will mention 3 possible web servers:
I will mention 3 possible web servers:
#You might choose '''Apache 2''' as 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>.   
#You might choose '''Apache 2''' as it is probably the most comprehensive, so if you have enough space on your Pi, install it using <code>sudo apt install apache2 -y</code>.   
#*You might want to add Fast CGI (if you don't know what that is, skip this) and therefore add <tt>sudo apt-get install libapache2-mod-fcgid</tt>.
#*You might want to add Fast CGI (if you don't know what that is, skip this) and therefore add <code>sudo apt-get install libapache2-mod-fcgid</code>.
#You might choose '''nginx''', as it is quite popular for small computers like the Pi, install that web server with <tt>sudo apt-get install nginx -y</tt>.
#You might choose '''nginx''', as it is quite popular for small computers like the Pi, install that web server with <code>sudo apt-get install nginx -y</code>.
#You might choose '''lighttpd''', as it is designed to use as little space on your Pi as possible, install it with <tt>sudo apt-get install lighttpd -y</tt>.
#You might choose '''lighttpd''', as it is designed to use as little space on your Pi as possible, install it with <code>sudo apt-get install lighttpd -y</code>.


=== Install PHP Hypertext Pre-processor ===
=== Install PHP Hypertext Pre-processor ===
Line 877: Line 877:
**being able to be used either in a fairly simple way by non-technical people  
**being able to be used either in a fairly simple way by non-technical people  
**or in an object-oriented way for those more technical to achieve success with more complex scripts.   
**or in an object-oriented way for those more technical to achieve success with more complex scripts.   
*The simplest instruction to install it is <tt>sudo apt install php -y</tt>, which version you get depends on your Pi and its operating system.  
*The simplest instruction to install it is <code>sudo apt install php -y</code>, which version you get depends on your Pi and its operating system.  
*To check which PHP modules have been installed by the above command, type <tt>php -m</tt>.  
*To check which PHP modules have been installed by the above command, type <code>php -m</code>.  
*If you later want to use a database (and a tool like PhpMyAdmin), then your php modules loaded must include at least '''mysqli''' and '''mbstring'''.  
*If you later want to use a database (and a tool like PhpMyAdmin), then your php modules loaded must include at least '''mysqli''' and '''mbstring'''.  
*I will explain how to find the .ini files later, but unwanted modules can be commented out in your .ini file.  
*I will explain how to find the .ini files later, but unwanted modules can be commented out in your .ini file.  


'''Alternatively''', you can install particular php modules, or a particular PHP version, by selecting components from a list. To do this type something like <tt>sudo apt install php7-fpm php7-cgi php7-cli php7-common php7.3-mbstring php7.3-mysql php7.3-curl php7.3-gd php7.3-zip -y</tt>. Only use this approach to force a particular version (but you may find that is not available), or if you are short of space, and you are only going to use a minority of the php features available in the full set of modules.  
'''Alternatively''', you can install particular php modules, or a particular PHP version, by selecting components from a list. To do this type something like <code>sudo apt install php7-fpm php7-cgi php7-cli php7-common php7.3-mbstring php7.3-mysql php7.3-curl php7.3-gd php7.3-zip -y</code>. Only use this approach to force a particular version (but you may find that is not available), or if you are short of space, and you are only going to use a minority of the php features available in the full set of modules.  




To test that php is installed, type <tt>php -v</tt> into terminal, and you will see the exact version that has been installed, a confirmation that it offers command line interface (cli), and a copyright notice.
To test that php is installed, type <code>php -v</code> into terminal, and you will see the exact version that has been installed, a confirmation that it offers command line interface (cli), and a copyright notice.


===Creating a Home web page on your web server===
===Creating a Home web page on your web server===
Line 899: Line 899:
You may need to edit this file for example to specify where your include files are stored (if not in same folder as script with require/include). Replace "apache2" by "cli" in the path for the ''batch'' '''php.ini''' file that you may also need to edit.
You may need to edit this file for example to specify where your include files are stored (if not in same folder as script with require/include). Replace "apache2" by "cli" in the path for the ''batch'' '''php.ini''' file that you may also need to edit.


To run a php script in batch, type <tt>php - f <file_name></tt>. You can redirect the output by adding a greater than symbol and the destination file (i.e. > log_file) on the same terminal line.   
To run a php script in batch, type <code>php - f <file_name></code>. You can redirect the output by adding a greater than symbol and the destination file (i.e. > log_file) on the same terminal line.   


If you want the MX external commands to run a PHP script for you, use something like "sh" as the program to run (i.e. run shell script); and in the parameters something like
If you want the MX external commands to run a PHP script for you, use something like "sh" as the program to run (i.e. run shell script); and in the parameters something like
Line 917: Line 917:
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.  
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 this database server, we type <tt>sudo apt install mariadb-server php-mysql -y</tt>.
To install this database server, we type <code>sudo apt install mariadb-server php-mysql -y</code>.


Our database files will be stored at '''/var/lib/mysql''' by default. Our MariaDB configuration is stored at '''/etc/mysql/mariadb.conf.d/50-server.cnf''', and it is the ''datadir='' entry that controls where the database files are stored.
Our database files will be stored at '''/var/lib/mysql''' by default. Our MariaDB configuration is stored at '''/etc/mysql/mariadb.conf.d/50-server.cnf''', and it is the ''datadir='' entry that controls where the database files are stored.
Line 923: Line 923:
=== Making your database secure ===
=== 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:
We need to assign passwords to control access to the database by typing into terminal <code>sudo mysql_secure_installation</code>.  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),
# 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 '''Y''' to signify we are going to set a new password for '''root''',
Line 947: Line 947:
* a selection approach (you select a database, then select a table, then select an action)
* a selection approach (you select a database, then select a table, then select an action)


#Start the install with <tt>sudo apt install phpmyadmin -y</tt>.   
#Start the install with <code>sudo apt install phpmyadmin -y</code>.   
#The PhpMyAdmin installer will ask some questions.  
#The PhpMyAdmin installer will ask some questions.  
#Use your tab key to select <Yes> when it asks whether you want to configure with '''dbconfig-common'''.  
#Use your tab key to select <Yes> when it asks whether you want to configure with '''dbconfig-common'''.  
Line 956: Line 956:
You may prefer to install a different tool, perhaps '''adminer''' that works using a drill down approach. A drill down approach is when you select the database, then select the table, then select the row, then select the column, then select the action.  This logical step by step approach is a popular approach, but does not suit everyone.  
You may prefer to install a different tool, perhaps '''adminer''' that works using a drill down approach. A drill down approach is when you select the database, then select the table, then select the row, then select the column, then select the action.  This logical step by step approach is a popular approach, but does not suit everyone.  


Install this drill down package with <tt>sudo apt install adminer</tt> (I leave you to work out the commands needed after that).
Install this drill down package with <code>sudo apt install adminer</code> (I leave you to work out the commands needed after that).


===Getting web and database servers ready for use===
===Getting web and database servers ready for use===
Line 1,009: Line 1,009:
You might have started using MX before you set up your database.  There is a option in that part of the admin interface to create database tables (as required) for each of the 3 updating intervals.  For example, the default name for the table updated at the standard interval is "monthly", but you could give it a name of "standard" or whatever you like.
You might have started using MX before you set up your database.  There is a option in that part of the admin interface to create database tables (as required) for each of the 3 updating intervals.  For example, the default name for the table updated at the standard interval is "monthly", but you could give it a name of "standard" or whatever you like.


The MX release distribution includes another executable.  Type <tt>cd CumulusMX && sudo mono ExportMySQL.exe monthly</tt> to run the executable. The first parameter is "monthly" even if the table has a different name.  
The MX release distribution includes another executable.  Type <code>cd CumulusMX && sudo mono ExportMySQL.exe monthly</code> to run the executable. The first parameter is "monthly" even if the table has a different name.  
#if the table name is defined in the admin interface, and the table already exists in the database with the correct columns defined, then the executable will use that table.
#if the table name is defined in the admin interface, and the table already exists in the database with the correct columns defined, then the executable will use that table.
#There is an optional second parameter that specifies the log file name to read.
#There is an optional second parameter that specifies the log file name to read.
Line 1,016: Line 1,016:
#*the SQL syntax used is "insert ignore", so if the row for that log file line already exists in the table, it will skip onto next line of log file.
#*the SQL syntax used is "insert ignore", so if the row for that log file line already exists in the table, it will skip onto next line of log file.


Similar instructions apply for the end of day table, although as there is only one daily summary log file, there is no optional second parameter, just type <tt>cd CumulusMX && sudo mono ExportMySQL.exe dayfile</tt>.
Similar instructions apply for the end of day table, although as there is only one daily summary log file, there is no optional second parameter, just type <code>cd CumulusMX && sudo mono ExportMySQL.exe dayfile</code>.


There is no way to use this executable for insert of past rows into the real-time table.
There is no way to use this executable for insert of past rows into the real-time table.
Line 1,032: Line 1,032:
=== Restarting Web Server ===
=== Restarting Web Server ===


After all these installs, we need to restart Apache (so it loads the PHP and MariaDB), by typing <tt>sudo service apache2 restart</tt> or  (if we just want the Apache configuration reloaded) by typing <tt>sudo systemctl reload apache2</tt>.  Similar commands apply for other web servers.
After all these installs, we need to restart Apache (so it loads the PHP and MariaDB), by typing <code>sudo service apache2 restart</code> or  (if we just want the Apache configuration reloaded) by typing <code>sudo systemctl reload apache2</code>.  Similar commands apply for other web servers.


We will need to restart Apache (or whichever web server we installed) any time we change our php.ini files, database passwords, and anything else that is checked when the web server starts.
We will need to restart Apache (or whichever web server we installed) any time we change our php.ini files, database passwords, and anything else that is checked when the web server starts.
Line 1,087: Line 1,087:
*On a Windows PC, if you right click (while viewing the boot directory on the card) there is an option called '''New'''  and if you select ''a text file'' it will create an empty file with the extension '''.txt'''. (In windows there is an option to hide extensions which is on by default, so you may need to deselect this option ['''New''' menu -> ''Options''] to see this extension).  On Windows you can open the file using Notepad to verify it is empty, if you gave accidentally created a file of another type like word processing it will be full of characters some of which do not display. Anyway, you must remove any extension from the file name so it is really just '''SSH'''.   
*On a Windows PC, if you right click (while viewing the boot directory on the card) there is an option called '''New'''  and if you select ''a text file'' it will create an empty file with the extension '''.txt'''. (In windows there is an option to hide extensions which is on by default, so you may need to deselect this option ['''New''' menu -> ''Options''] to see this extension).  On Windows you can open the file using Notepad to verify it is empty, if you gave accidentally created a file of another type like word processing it will be full of characters some of which do not display. Anyway, you must remove any extension from the file name so it is really just '''SSH'''.   


Type into the file <tt>touch ssh</tt>, but nothing else, no empty lines, no end of line characters.
Type into the file <code>touch ssh</code>, but nothing else, no empty lines, no end of line characters.


When the card is inserted into your Pi, on boot this file will be removed and the SSH option will be enabled. The default password is '''raspberry''', once you have successfully got SSH working. You should then use '''sudo raspi-config''' (choose option 1 = ''Change User Password'', and set the new password you will use for your SSH session next time).
When the card is inserted into your Pi, on boot this file will be removed and the SSH option will be enabled. The default password is '''raspberry''', once you have successfully got SSH working. You should then use '''sudo raspi-config''' (choose option 1 = ''Change User Password'', and set the new password you will use for your SSH session next time).
Line 1,098: Line 1,098:
If you have a Linux or Mac device, open '''Terminal'''.  
If you have a Linux or Mac device, open '''Terminal'''.  


Next, (assuming your Pi is running, and that your other device is on the same local network), type <tt>ssh pi@raspberrypi</tt> to get access to default user in your Pi.   
Next, (assuming your Pi is running, and that your other device is on the same local network), type <code>ssh pi@raspberrypi</code> to get access to default user in your Pi.   


(As an alternative for Windows operating system, you can install PuTTY, this has the advantage that you can enter the connection settings into it, and configure various other options, and these are remembered, so might make it easier to use. As mentioned earlier, PuTTY and winSCP work well togther because they share settings.  '''PuTTY''' software (an SSH client for Windows) can be downloaded from <tt>https://www.putty.org/</tt>).  
(As an alternative for Windows operating system, you can install PuTTY, this has the advantage that you can enter the connection settings into it, and configure various other options, and these are remembered, so might make it easier to use. As mentioned earlier, PuTTY and winSCP work well togther because they share settings.  '''PuTTY''' software (an SSH client for Windows) can be downloaded from <code>https://www.putty.org/</code>).  


When you are using a terminal, it is a sequential device, each line is either a string of characters that you type in (these might include a backspace character) or something sent back in response. The action that result from any key combinations depend on your terminal application, not just whatever you are running on your Pi.  Your mouse can't affect cursor location, but the mouse might be needed to select text, the left click might copy what is selected, and the right click might paste (what is in your PC's clipboard) at current cursor position.
When you are using a terminal, it is a sequential device, each line is either a string of characters that you type in (these might include a backspace character) or something sent back in response. The action that result from any key combinations depend on your terminal application, not just whatever you are running on your Pi.  Your mouse can't affect cursor location, but the mouse might be needed to select text, the left click might copy what is selected, and the right click might paste (what is in your PC's clipboard) at current cursor position.
Line 1,110: Line 1,110:
== Running MX from your PC ==
== Running MX from your PC ==


If you choose to use the simple <tt>sudo mono CumulusMX.exe</tt> command in a terminal (or command window or Powershell) session on your PC, remember MX will detect if that session is ended and will shut down MX. This means if you want to keep MX running you need to keep your session on your PC running and you loose the advantage of saving electricity by running MX on a PI because your PC remains on.   
If you choose to use the simple <code>sudo mono CumulusMX.exe</code> command in a terminal (or command window or Powershell) session on your PC, remember MX will detect if that session is ended and will shut down MX. This means if you want to keep MX running you need to keep your session on your PC running and you loose the advantage of saving electricity by running MX on a PI because your PC remains on.   


As I type this a new release 3.8.0 is to allow MX to run as a service, and a future release is planned to change the associated script, so anything I write here might become obsolete, and the next sub-section gives you some links to the support forum about alternatives to the new feature.  Hopefully, someone will edit this article, when instructions have settled down and won't change on next release.  Basically, the ability to run MX as a service,  means that MX actually runs independent of the session that starts or stops the service; and therefore implies you can shut down your PC without stopping MX.   
As I type this a new release 3.8.0 is to allow MX to run as a service, and a future release is planned to change the associated script, so anything I write here might become obsolete, and the next sub-section gives you some links to the support forum about alternatives to the new feature.  Hopefully, someone will edit this article, when instructions have settled down and won't change on next release.  Basically, the ability to run MX as a service,  means that MX actually runs independent of the session that starts or stops the service; and therefore implies you can shut down your PC without stopping MX.   
5,838

edits