summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon duSaint2023-07-04 17:41:43 -0700
committerJon duSaint2023-07-04 17:41:43 -0700
commit8cceff0179daffd6a5a7502b00d1176fb17a59e2 (patch)
tree6a8c548d39a400d611d9f23074b479a8d8c0a7ba
parente5b30233366fa793d138ff580c9037691c11f318 (diff)

weewx: setup scripts and patches

Make installation on OpenBSD easier.

-rw-r--r--weewx/README68
-rw-r--r--weewx/setup.cfg5
-rw-r--r--weewx/setup.cfg-Install-into-usr-local.patch30
-rw-r--r--weewx/setup.py-Add-config-name-option.patch80
-rw-r--r--weewx/weewx.rc18
5 files changed, 201 insertions, 0 deletions
diff --git a/weewx/README b/weewx/README
new file mode 100644
index 0000000..a677240
--- /dev/null
+++ b/weewx/README
@@ -0,0 +1,68 @@
+Instructions for installing WeeWX:
+
+https://www.weewx.com
+
+Reference guide at: https://www.weewx.com/docs/setup.htm
+
+ pkg_add py3-configobj py3-Pillow py3-serial py3-pyusb py3-cheetah
+
+Download and unpack (assuming latest version is 4.8.0):
+
+ curl -O https://weewx.com/downloads/weewx-4.8.0.tar.gz
+ tar zxvf weewx-4.8.0.tar.gz
+
+`cd` into the source directory and apply `setup.py-Add-config-name-option.patch`
+
+ patch -p1 < setup.py-Add-config-name-option.patch
+
+If you don't wish to let Google know every time you check the weather,
+apply the following patch:
+
+ patch -p1 < XXX-de-google-font-XXX.patch
+
+Copy the setup.cfg from this directory into the weewx source
+directory.
+
+Configure and install:
+
+ python3 setup.py build
+ doas python3 setup.py install --config-name /etc/weewx/weewx.conf
+
+Create a user for the daemon
+
+ # logname: weewx
+ # login class: daemon
+ # primary group: weewx
+ # supplementary groups: dialer, daemon
+ # no home
+ # login disallowed
+ useradd -c "WeeWX Daemon" -d /var/empty -G dialer,daemon -g =uid -L daemon -s /sbin/nologin weewx
+
+Fixup permissions:
+
+ doas chown -R weewx /var/www/weewx
+
+Install rc script and enable daemon:
+
+ doas install -m 0555 weewx.rc /etc/rc.d/weewx
+ doas rcctl enable weewx
+ doas rcctl start weewx
+
+Modify `httpd` configuration:
+
+ * Ensure that a line similar to this is in the `types` block (create
+ a `types` block if needed, see `httpd.conf(5)`):
+
+ text/html html htm
+
+ * Add these lines to the appropriate `server` block in `/etc/httpd.conf`:
+
+ location "/weewx/docs" {
+ request rewrite "/weewx/docs/usersguide.htm"
+ }
+
+
+ location "/weewx/*" {
+ root "/weewx/docs"
+ request strip 1
+ }
diff --git a/weewx/setup.cfg b/weewx/setup.cfg
new file mode 100644
index 0000000..2344cbe
--- /dev/null
+++ b/weewx/setup.cfg
@@ -0,0 +1,5 @@
+[install]
+prefix = /var/www
+install_scripts = /usr/local/bin
+install_lib = /usr/local/bin
+install_data = %(prefix)s/weewx
diff --git a/weewx/setup.cfg-Install-into-usr-local.patch b/weewx/setup.cfg-Install-into-usr-local.patch
new file mode 100644
index 0000000..8d26477
--- /dev/null
+++ b/weewx/setup.cfg-Install-into-usr-local.patch
@@ -0,0 +1,30 @@
+From c68f36936abc43c56e8a1a967821b6c00a3e3503 Mon Sep 17 00:00:00 2001
+From: Jon duSaint <jon@rockgeeks.net>
+Date: Mon, 1 Aug 2022 17:14:09 -0700
+Subject: [PATCH] setup.cfg: Install into /usr/local
+
+---
+ setup.cfg | 12 ++----------
+ 1 file changed, 2 insertions(+), 10 deletions(-)
+
+diff --git a/setup.cfg b/setup.cfg
+index 324d5d7..dcdb8c6 100644
+--- a/setup.cfg
++++ b/setup.cfg
+@@ -1,11 +1,3 @@
+ [install]
+-home = /home/weewx
+-prefix =
+-exec-prefix =
+-install_lib = %(home)s/bin
+-install_scripts = %(home)s/bin
+-
+-[egg_info]
+-tag_build =
+-tag_date = 0
+-
++prefix = /var/www
++install_data = %(prefix)s/weewx
+--
+2.35.1
+
diff --git a/weewx/setup.py-Add-config-name-option.patch b/weewx/setup.py-Add-config-name-option.patch
new file mode 100644
index 0000000..63eb64a
--- /dev/null
+++ b/weewx/setup.py-Add-config-name-option.patch
@@ -0,0 +1,80 @@
+From 7eda0d89745de97d0d0299e0d68e4fd839bd4145 Mon Sep 17 00:00:00 2001
+From: Jon duSaint <jon@rockgeeks.net>
+Date: Mon, 1 Aug 2022 17:15:28 -0700
+Subject: [PATCH] setup.py: Add --config-name option
+
+This is used to tell wee_config where to put the output weewx.conf file.
+---
+ setup.py | 23 +++++++++++++++--------
+ 1 file changed, 15 insertions(+), 8 deletions(-)
+
+diff --git a/setup.py b/setup.py
+index fecd57a..96fc309 100755
+--- a/setup.py
++++ b/setup.py
+@@ -48,15 +48,17 @@ this_dir = os.path.abspath(os.path.dirname(this_file))
+ # ==============================================================================
+
+ class weewx_install(install):
+- """Specialized version of install, which adds a '--no-prompt' option, and which runs a
+- wee_config post-install script"""
++ """Specialized version of install, which adds '--no-prompt' and '--config-name' options,
++ and which runs a wee_config post-install script"""
+
+- # Add an option for --no-prompt. This will be passed on to wee_config
+- user_options = install.user_options + [('no-prompt', None, 'Do not prompt for station info')]
++ # Add options for --no-prompt and --config-name to be passed on to wee_config
++ user_options = install.user_options + [('no-prompt', None, 'Do not prompt for station info'),
++ ('config-name=', None, 'Output config file')]
+
+ def initialize_options(self, *args, **kwargs):
+ install.initialize_options(self, *args, **kwargs)
+ self.no_prompt = None
++ self.config_name = 'weewx.conf'
+
+ def finalize_options(self):
+ # Call my superclass's version
+@@ -76,7 +78,7 @@ class weewx_install(install):
+
+ # Now the post-install
+ update_and_install_config(self.install_data, self.install_scripts, self.install_lib,
+- self.no_prompt)
++ self.no_prompt, self.config_name)
+
+ return rv
+
+@@ -250,7 +252,12 @@ def update_and_install_config(install_dir, install_scripts, install_lib, no_prom
+ """
+
+ # This is where the weewx.conf file will go
+- config_path = os.path.join(install_dir, config_name)
++ dist_config_path = os.path.join(install_dir, os.path.basename(config_name))
++
++ if os.path.isabs(config_name):
++ config_path = config_name
++ else:
++ config_path = dist_config_path
+
+ # Is there an existing file?
+ if os.path.isfile(config_path):
+@@ -259,7 +266,7 @@ def update_and_install_config(install_dir, install_scripts, install_lib, no_prom
+ os.path.join(install_scripts, 'wee_config'),
+ '--upgrade',
+ '--config=%s' % config_path,
+- '--dist-config=%s' % config_path + '.' + VERSION,
++ '--dist-config=%s' % dist_config_path + '.' + VERSION,
+ '--output=%s' % config_path,
+ ]
+ else:
+@@ -267,7 +274,7 @@ def update_and_install_config(install_dir, install_scripts, install_lib, no_prom
+ args = [sys.executable,
+ os.path.join(install_scripts, 'wee_config'),
+ '--install',
+- '--dist-config=%s' % config_path + '.' + VERSION,
++ '--dist-config=%s' % dist_config_path + '.' + VERSION,
+ '--output=%s' % config_path,
+ ]
+ # Add the --no-prompt flag if the user requested it.
+--
+2.35.1
+
diff --git a/weewx/weewx.rc b/weewx/weewx.rc
new file mode 100644
index 0000000..b6714bb
--- /dev/null
+++ b/weewx/weewx.rc
@@ -0,0 +1,18 @@
+#!/bin/ksh
+
+daemon="/usr/local/bin/weewxd"
+daemon_flags="--daemon --pidfile ''"
+daemon_user="weewx"
+
+. /etc/rc.d/rc.subr
+
+rc_check() {
+ pgrep -q -f "${daemon}"
+}
+
+# Override internal function rather than trying to get pexp right for all cases
+_rc_sendsig() {
+ pkill -${1:-TERM} -T "${daemon_rtable}" -f "${daemon}"
+}
+
+rc_cmd $1