-
Notifications
You must be signed in to change notification settings - Fork 1
Remote installation
weewx-wxobs requires access to the weewx database to generate the pages as it does.
If you move your web pages to another server by using weewx's built in transfer routines as found in weewx.conf...
[StdReport] [[FTP]] [...] [[RSYNC]] [...]then wxobs will also be transferred. However, it won't be able to access the database because that does not get transferred by those same weewx FTP or RSYNC routines.
sqlite is the default database type for a fresh install of weewx. If you've done nothing to change it, this is what you'll have.
An sqlite database can be simply copied to another destination (unlike a mysql setup) and should survive the disruption if there are no writes occuring while it's being done. If we do it during the report cycle, which is when we'll be doing the move, there will be no writes so all should be good and a current, or updated, database will be available on the remote machine.
This is an essential requirement for rsync to be used to access a remote server unattended - as we are doing with remote access. If you are using the RSYNC feature in weewx already then you've more than likely done it already, and can use the user name that you have configured there.
If you haven't done it yet there are a few tutorials out there. Have a read of them and and configure your user accordingly.
- SSH with authentication key instead of password
- How to set up ssh so you aren't asked for a password
READ WRITE : root@raspberrypi:~# ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: e6:54:4e:43:b1:72:fb:8d:5f:3f:8c:d6:b4:2a:8b:fa root@raspberrypi The key's randomart image is: +---[RSA 2048]----+ | o. | | . . | | . * | | * o | | S o | | + . o . | | . o * o| | .. + *.| | .oE .+.o o| +-----------------+ READ WRITE : root@raspberrypi:~# ssh-copy-id -i ~/.ssh/id_rsa.pub graybeard@192.168.0.100 /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys graybeard@192.168.0.100's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'graybeard@192.168.0.100'" and check to make sure that only the key(s) you wanted were added. READ WRITE : root@raspberrypi:~# ssh 'graybeard@192.168.0.100' The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. You have new mail. Last login: Tue Feb 14 08:56:07 2017 from 192.168.0.215 xterm graybeard@whitebeard:~ 09:31 AM $ logout Connection to 192.168.0.100 closed.
To set this up you need to edit the section in wxobs/skin.conf, which appears as follows (vers 0.6)
[[Remote]] # This section is used ONLY if you wish to use wxobs on a remote machine # where it cannot access the sqlite database. # It is for the sql database only, mysql should be accesable by replacing # hostname with the actual ip address (localhost) # To allow it to run, it requires a valid entry for both values eg: - #rsync_user = pi #rsync_machine = 192.168.1.62 rsync_user = rsync_machine =If either the rsync_user field OR the rsync_machine field is empty, no transfer can or will occur. If you are not using sqlite, it doesn't matter what you have here, it will be silently ignored.
If you satisfy the above criteria, and have public key (password less) access configured between your database machine and the remote machine then the logs will show some information.
The lofs will show more if you set wxobs_debug option in the skin.conf file, as follows
# debug output: # # wxobs_debug: Allow index.php to include debugging info if set to. # 1 and above is low level, variables, some logic. # 2 is for wxobs remote cmds etc. # 3 only for delta-T final values (low level - if enabled) # 4 only for delta-T unit conversion calcs (verbose) - if enabled # 5 only for ordinalCompass conversion calcs (N, NE...CALM) (verbose) # 6 is for database debugging wxobs_debug = 2
with wxobs debug set to 2, public key access configured and writable directories you should be greeted with something like...
[...]: wxobs: rsync cmd is ... ['rsync', '-ac', '--stats', '--compress', '/var/lib/weewx/sqlitedupe.sdb', 'pi@192.168.1.2:/var/lib/weewx'] [...]: wxobs: rsync'd 69,216 bytes bytes in 1 files (3,747,840 bytes) in 0.50 seconds [...]: wxobs: rsync cmd is ... ['rsync', '-ac', '--stats', '--compress', '/tmp/wxobs_sqlitedupe.inc', 'pi@192.168.1.2:/tmp'] [...]: wxobs: rsync'd 153 bytes bytes in 1 files (153 bytes) in 0.29 seconds
The last line, the include file transfer, will become 0 on subsequent transfers because it never (or rarely) changes...
[...] wxobs: rsync'd 0 bytes bytes in 0 files (153 bytes) in 0.29 seconds
You probably won't get the above success on your first run and instead will get an error of some sort, the following is one that you will probably see...
[...]: wxobs: rsync cmd is ... ['rsync', '-ac', '--stats', '--compress', '/etc/weewx/archive/sqlitedupe.sdb', 'pinochio@192.168.1.62:/etc/weewx/archive'] [...]: wxobs: ERR Permission error in rsync command, probably at remote end authentication ! FIX ME !· [...]: wxobs: code 12, rsync failed, executed in 5.98 seconds to pi@192.168.1.2:/etc/weewx/archive
With this one we have changed the database location in weewx.conf (which is okay) but we don't have the same directory on the remote sever. The fix is to log in to the remote sever, add the directory /etc/weewx/archive and make it writable by the user.
[...]: wxobs: rsync cmd is ... ['rsync', '-ac', '--stats', '--compress', '/usr/share/php/wxobs_sqlitedupe.inc', 'pi@192.168.1.2:/usr/share/php'] [...]: wxobs: ERR Permission error in rsync command, probably at remote end authentication ! FIX ME !· [...]: wxobs: code 12, rsync failed, executed in 0.28 seconds to pi@192.168.1.2:/usr/share/php
This states that a permission error has occured and this is more than likely to be because the user pi, doesn't have permission to write to the /usr/share/php directory to place the config file for wxobs.inc
This file contains passwords for mysql (if you were using that), paths to the database for sqlite and additions to php (such as the inclusion of a timezone setting.)
If this error is occuring with the sqlite database, then the files location is not as critical as the information that's within it doesn't expose passwords or the like. There is nothing in there that is not known, or easily found elsewhere.
For that reason it's location is less critical and it can be located somewhere else without ill effect - providing the web server can find it, and it's reasonably secure (notes above not withstanding). If it's all on a local LAN then there are fewer security implications if you can trust your intranet users.
wxobs/skin.conf offers an option to change it...
[wxobs] # This shouldn't need changing, but if it does then /tmp is a good # starting point. This will most likely be used with remote servers # using sqlite databases, see [Remote] below include_path = '/tmp'
You could use /tmp or any other location that the webserver can access. If you don't mind that it becomes available on your webserver then select a path to it within weewx or one level up. ie; /var/www/html/weewx or /var/www/html
By default this is set to True, ie:- always send it.
If the include file is really giving you grief, and you want to stop sending it then the undocumented switch for the skin.conf file is to set send_include = False and to stop sending it. It's placement and upkeep in its intended destination is then your responsibility.
You may want to do this if you want to keep it in the recommended location (by the PHP maintainers) which is as defined in the php.ini file, and where its data is most secure. If you're getting the permission errors on the rsync transfer and don't want to, or can't, change the permissions on the remote side then you can instead place the generated file into its location manually and then turn off the rsync transfer for that file.
If that file later disappears, or you change databases and need an updated include file then you'll have to replace it manually. But first you'll have to remember that you did it in the first place!
[[Remote]] # This section is used ONLY if you wish to use wxobs on a remote machine # where it cannot access the database. # It is for the sql database only, mysql should be accesable by replacing # hostname with the actual ip address (localhost) # to run it requires a valid entry for both values eg: - #rsync_user = pi #rsync_machine = 192.168.1.2 #rsync_user = #rsync_machine = rsync_user = pi rsync_machine = 192.168.1.2 send_include = False
If you save to a mysql database you may be able to access it from this remote machine by changing the weewx.conf section under
[DatabaseTypes] [[MySQL]] #host = localhost host = ip_address_or_DNS_name of your weewx machine.
This will work if the remote machine can access that IP address or resolve the DNS entry. If it's all on a local LAN it should be workable (untested). If it's truly remote (in the cloud) and can't get past your firewall then it won't work and you'll need to get imaginative.