diff --git a/src/weecfg/station_config.py b/src/weecfg/station_config.py
index d622732a..5d2f4162 100644
--- a/src/weecfg/station_config.py
+++ b/src/weecfg/station_config.py
@@ -569,59 +569,73 @@ def copy_user(config_dict, user_root=None, dry_run=False):
def copy_util(config_path, config_dict, dry_run=False, force=False):
import weewxd
weewxd_path = weewxd.__file__
+ cfg_dir = os.path.dirname(config_path)
username = getpass.getuser()
groupname = grp.getgrgid(os.getgid()).gr_name
weewx_root = config_dict['WEEWX_ROOT']
- # This is the set of substitutions to be performed. The key is a regular expression. If a
- # match is found, the value will be substituted for the matched expression.
- re_dict = {
- # For systemd
- r"^#User=.*": rf"User={username}",
- # For systemd
- r"^#Group=.*": rf"Group={groupname}",
- # For systemd
- r"^ExecStart=.*": rf"ExecStart={sys.executable} {weewxd_path} {config_path}",
- # For init.d, redhat, bsd, suse
- r"^WEEWX_BIN=.*": rf"WEEWX_BIN={sys.executable} {weewxd_path}",
- # For init.d, redhat, bsd, suse
- r"^WEEWX_CFG=.*": rf"WEEWX_CFG={config_path}",
- # For init.d
- r"^WEEWX_USER=.*": rf"WEEWX_USER={groupname}",
- # For multi
- r"^WEEWX_BINDIR=.*": rf"WEEWX_BINDIR={os.path.dirname(weewxd_path)}",
- # For multi
- r"^WEEWX_CFGDIR=.*": rf"WEEWX_CFGDIR={os.path.dirname(config_path)}",
- # for macOS:
- r"/usr/bin/python3": rf"{sys.executable}/string>",
- # For macOS:
- r"/Users/Shared/weewx/src/weewxd.py": rf"{weewxd_path}",
- # For macOS:
- r"/Users/Shared/weewx/weewx.conf": rf"{config_path}",
- # For Apache
- r"/home/weewx/public_html": rf"{os.path.join(weewx_root, 'public_html')}",
- # For scripts
- r"^UTIL_ROOT=.*": rf"UTIL_ROOT={os.path.join(weewx_root, 'util')}",
+ html_dir = os.path.join(weewx_root, 'public_html') # FIXME: get from conf
+ util_dir = os.path.join(weewx_root, 'util')
+ bin_dir = os.path.dirname(weewxd_path)
+
+ # This is the set of substitutions to be performed, with a different set
+ # for each type of files. The key is a regular expression. If a match is
+ # found, the value will be substituted for the matched expression. Beware
+ # that the labels for user, group, config directory, and other parameters
+ # are consistent throughout the utility files. Be sure to test the
+ # patterns by using them to grep all of the files in the util directory to
+ # see what actually matches.
+
+ re_patterns = {
+ 'scripts': { # daemon install scripts
+ r"^UTIL_ROOT=.*": rf"UTIL_ROOT={util_dir}",
+ },
+ 'systemd': { # systemd unit files
+ r"User=WEEWX_USER": rf"User={username}",
+ r"Group=WEEWX_GROUP": rf"Group={groupname}",
+ r"ExecStart=WEEWX_PYTHON WEEWXD": rf"ExecStart={sys.executable} {weewxd_path}",
+ r" WEEWX_CFGDIR/": rf" {cfg_dir}/",
+ },
+ 'launchd': { # macos launchd files
+ r"/usr/bin/python3": rf"{sys.executable}/string>",
+ r"/Users/Shared/weewx/src/weewxd.py": rf"{weewxd_path}",
+ r"/Users/Shared/weewx/weewx.conf": rf"{config_path}",
+ },
+ 'default': { # defaults file used by SysV init scripts
+ r"^WEEWX_PYTHON=.*": rf"WEEWX_PYTHON={sys.executable}",
+ r"^WEEWX_BINDIR=.*": rf"WEEWX_BINDIR={bin_dir}",
+ r"^WEEWX_CFGDIR=.*": rf"WEEWX_CFGDIR={cfg_dir}",
+ r"^WEEWX_USER=.*": rf"WEEWX_USER={username}",
+ r"^WEEWX_GROUP=.*": rf"WEEWX_GROUP={groupname}",
+ },
}
- # Convert to a list of two-way tuples.
- re_list = [(re.compile(key), re_dict[key]) for key in re_dict]
+
+ # Convert the patterns to a list of two-way tuples
+ for k in re_patterns:
+ re_patterns[k] = [(re.compile(key), re_patterns[k][key]) for key in re_patterns[k]],
def _patch_file(srcpath, dstpath):
- """Copy an individual file from srcpath to dstpath, while making substitutions
- using the list of regular expressions re_list"""
- with open(srcpath, 'r') as rd, open(dstpath, 'w') as wd:
- for line in rd:
- # Lines starting with "#&" are comment lines. Ignore them.
- if line.startswith("#&"):
- continue
- # Go through all the regular expressions, substituting the value for the key
- for key, value in re_list:
- line = key.sub(value, line)
- wd.write(line)
+ srcdir = os.path.dirname(srcpath)
+ if srcdir in re_patterns:
+ # Copy an individual file from srcpath to dstpath, while making
+ # substitutions using the list of regular expressions re_list
+ re_list = re_patterns[srcdir]
+ with open(srcpath, 'r') as rd, open(dstpath, 'w') as wd:
+ for line in rd:
+ # Lines starting with "#&" are comment lines. Ignore them.
+ if line.startswith("#&"):
+ continue
+ # Go through all the regular expressions, substituting the
+ # value for the key
+ for key, value in re_list:
+ line = key.sub(value, line)
+ wd.write(line)
+ else:
+ # Just copy the file
+ shutil.copyfile(srcpath, dstpath)
# Create a callable using the shutil.ignore_patterns factory function.
- _ignore_function = shutil.ignore_patterns('*.pyc', '__pycache__', 'apache', 'default', 'i18n',
- 'init.d', 'logwatch', 'newsyslog.d',
- 'solaris', 'tmpfiles.d')
+ # The files/directories that match items in this list will *not* be copied.
+ _ignore_function = shutil.ignore_patterns('*.pyc', '__pycache__')
util_dir = os.path.join(weewx_root, 'util')
if os.path.isdir(util_dir):
@@ -636,18 +650,18 @@ def copy_util(config_path, config_dict, dry_run=False, force=False):
with weeutil.weeutil.get_resource_path('weewx_data', 'util') as util_resources:
print(f"Copying utility files into {util_dir}")
if not dry_run:
- # Copy the tree rooted in 'util_resources' to 'dstdir', while ignoring files given
- # by _ignore_function. While copying, use the function _patch_file() to massage
- # the files.
+ # Copy the tree rooted in 'util_resources' to 'dstdir', while
+ # ignoring files given by _ignore_function. While copying, use the
+ # function _patch_file() to massage the files.
shutil.copytree(util_resources, util_dir,
- ignore=_ignore_function,
- copy_function=_patch_file)
+ ignore=_ignore_function, copy_function=_patch_file)
scripts_dir = os.path.join(weewx_root, 'scripts')
- # The 'scripts' subdirectory is a little different. We don't delete it first, because it's a
- # comman name and a user might have put things there. Instead, just copy our files into it.
- # First, make sure the subdirectory exists:
+ # The 'scripts' subdirectory is a little different. We do not delete it
+ # first, because it's a comman name and a user might have put things there.
+ # Instead, just copy our files into it. First, make sure the subdirectory
+ # exists:
os.makedirs(scripts_dir, exist_ok=True)
# Then do the copying.
with weeutil.weeutil.get_resource_path('weewx_data', 'scripts') as scripts_resources:
@@ -658,8 +672,9 @@ def copy_util(config_path, config_dict, dry_run=False, force=False):
abs_dst = os.path.join(scripts_dir, file)
_patch_file(abs_src, abs_dst)
status = os.stat(abs_dst)
- # Because these files have been tailored to a particular user, they hould only
- # be executable by that user. So, use S_IXUSR (instead of S_IXOTH):
+ # Because these files have been tailored to a particular user,
+ # they hould only be executable by that user. So, use S_IXUSR
+ # (instead of S_IXOTH):
os.chmod(abs_dst, status.st_mode | stat.S_IXUSR)
return util_dir
diff --git a/src/weewx_data/scripts/setup-daemon.macos b/src/weewx_data/scripts/setup-daemon.macos
index b0a54635..f2d00b4f 100755
--- a/src/weewx_data/scripts/setup-daemon.macos
+++ b/src/weewx_data/scripts/setup-daemon.macos
@@ -1,7 +1,6 @@
#!/bin/sh
#
-# Copy configurations that integrate WeeWX into a macOS system.
-#
+# Install files that integrate WeeWX into a macOS system.
# This script must be run as a privileged user.
#
set -e
@@ -13,9 +12,31 @@ if [ "$(id -u)" != "0" ]; then
exit 1
fi
+if [ ! -d /Library/LaunchDaemons ]; then
+ echo "Apparently this system does not use launchd"
+ exit 1
+fi
+
+ts=`date +"%Y%m%d%H%M%S"`
+
+copy_file() {
+ src=$1
+ dst=$2
+ if [ -f "$dst" ]; then
+ mv ${dst} ${dst}.${ts}
+ fi
+ cp $src $dst
+}
+
+remove_file() {
+ dst=$1
+ if [ -f "$dst" ]; then
+ rm $dst
+ fi
+}
+
do_install() {
- echo "This script sets up the files necessary to run WeeWX at system startup."
- echo "On some systems, it can be slow to run. Please be patient."
+ echo "Set up the files necessary to run WeeWX at system startup."
if [ ! -d $UTIL_ROOT ]; then
echo "Cannot find utility files at location '$UTIL_ROOT'"
@@ -24,7 +45,7 @@ do_install() {
echo "Copying files from $UTIL_ROOT..."
echo " plist"
- cp $UTIL_ROOT/launchd/com.weewx.weewxd.plist /Library/LaunchDaemons
+ copy_file $UTIL_ROOT/launchd/com.weewx.weewxd.plist /Library/LaunchDaemons
echo "You can now start weewx with the following command:"
echo " '\033[1msudo launchctl load /Library/LaunchDaemons/com.weewx.weewxd.plist\033[0m'"
@@ -35,9 +56,7 @@ do_uninstall() {
launchctl unload /Library/LaunchDaemons/com.weewx.weewxd.plist
echo "Removing files..."
echo " plist"
- if [ -f /Library/LaunchDaemons/com.weewx.weewxd.plist ]; then
- rm /Library/LaunchDaemons/com.weewx.weewxd.plist
- fi
+ remove_file /Library/LaunchDaemons/com.weewx.weewxd.plist
}
diff --git a/src/weewx_data/scripts/setup-daemon.systemd b/src/weewx_data/scripts/setup-daemon.systemd
index b5c201be..e9c5b2a0 100755
--- a/src/weewx_data/scripts/setup-daemon.systemd
+++ b/src/weewx_data/scripts/setup-daemon.systemd
@@ -1,9 +1,6 @@
#!/bin/sh
#
-# Copy configuration files that integrate WeeWX into a Linux system that uses
-# systemd. These include udev rules for known devices, and the service unit
-# files to facilitate starting/stopping WeeWX.
-#
+# Install files that integrate WeeWX into a Linux system that uses systemd.
# This script must be run using sudo, or as root.
#
set -e
@@ -15,9 +12,32 @@ if [ "$(id -u)" != "0" ]; then
exit 1
fi
+if [ ! -d /etc/systemd/system ]; then
+ echo "Apparently this system does not use systemd"
+ exit 1
+fi
+
+ts=`date +"%Y%m%d%H%M%S"`
+
+copy_file() {
+ src=$1
+ dst=$2
+ if [ -f "$dst" ]; then
+ mv ${dst} ${dst}.${ts}
+ fi
+ cp $src $dst
+}
+
+remove_file() {
+ dst=$1
+ if [ -f "$dst" ]; then
+ rm $dst
+ fi
+}
+
do_install() {
- echo "This script sets up the files necessary to run WeeWX at system startup."
- echo "On some systems, it can be slow to run. Please be patient."
+ echo "Set up the files necessary to run WeeWX at system startup."
+ echo "On some systems, this may take awhile. Please be patient."
if [ ! -d $UTIL_ROOT ]; then
echo "Cannot find utility files at location '$UTIL_ROOT'"
@@ -27,23 +47,20 @@ do_install() {
echo "Copying files from $UTIL_ROOT..."
if [ -d /etc/udev/rules.d ]; then
echo " udev rules"
- cp $UTIL_ROOT/udev/rules.d/weewx.rules /etc/udev/rules.d/60-weewx.rules
- fi
- if [ -d /etc/systemd/system ]; then
- echo " systemd unit"
- cp $UTIL_ROOT/systemd/weewx.service /etc/systemd/system
- cp $UTIL_ROOT/systemd/weewx@.service /etc/systemd/system
+ copy_file $UTIL_ROOT/udev/rules.d/weewx.rules /etc/udev/rules.d/60-weewx.rules
+ echo " If you are using a device that is connected to the computer by USB or"
+ echo " serial port, unplug the device then plug it back in again to ensure that"
+ echo " permissions are applied correctly."
fi
+ echo " systemd unit"
+ copy_file $UTIL_ROOT/systemd/weewx.service /etc/systemd/system/weewx.service
+ copy_file $UTIL_ROOT/systemd/weewx@.service /etc/systemd/system/weewx@.service
+
echo "Reloading systemd..."
systemctl daemon-reload
echo "Enabling weewx..."
systemctl enable weewx
-
- echo "If you are using a device that is connected to the computer by USB or"
- echo "serial port, unplug the device then plug it back in again to ensure that"
- echo "permissions are applied correctly."
- echo ""
echo "You can start weewx with the following command:"
echo " '\033[1msudo systemctl start weewx\033[0m'"
}
@@ -54,18 +71,12 @@ do_uninstall() {
echo "Disabling weewx..."
systemctl disable weewx
echo "Removing files..."
- if [ -f /etc/systemd/system/weewx.service ]; then
- echo " systemd unit"
- rm /etc/systemd/system/weewx.service
- fi
- if [ -f /etc/systemd/system/weewx@.service ]; then
- echo " systemd unit template"
- rm /etc/systemd/system/weewx@.service
- fi
- if [ -f /etc/udev/rules.d/60-weewx.rules ]; then
- echo " udev rules"
- rm /etc/udev/rules.d/60-weewx.rules
- fi
+ echo " systemd unit"
+ remove_file /etc/systemd/system/weewx.service
+ echo " systemd unit template"
+ remove_file /etc/systemd/system/weewx@.service
+ echo " udev rules"
+ remove_file /etc/udev/rules.d/60-weewx.rules
}
ACTION=$1
diff --git a/src/weewx_data/scripts/setup-daemon.sysv b/src/weewx_data/scripts/setup-daemon.sysv
old mode 100644
new mode 100755
index f96dbe83..8c4ce09e
--- a/src/weewx_data/scripts/setup-daemon.sysv
+++ b/src/weewx_data/scripts/setup-daemon.sysv
@@ -1,9 +1,6 @@
#!/bin/sh
#
-# Copy configuration files that integrate WeeWX into a Linux system that uses
-# sysV init. These udev rules for known devices, and the init script to
-# facilitate starting/stopping WeeWX.
-#
+# Install files that integrate WeeWX into a Linux system that uses sysV init.
# This script must be run using sudo, or as root.
#
set -e
@@ -15,9 +12,31 @@ if [ "$(id -u)" != "0" ]; then
exit 1
fi
+if [ ! -d /etc/init.d ]; then
+ echo "Apparently this system does not use SysV init"
+ exit 1
+fi
+
+ts=`date +"%Y%m%d%H%M%S"`
+
+copy_file() {
+ src=$1
+ dst=$2
+ if [ -f "$dst" ]; then
+ mv ${dst} ${dst}.${ts}
+ fi
+ cp $src $dst
+}
+
+remove_file() {
+ dst=$1
+ if [ -f "$dst" ]; then
+ rm $dst
+ fi
+}
+
do_install() {
- echo "This script sets up the files necessary to run WeeWX at system startup."
- echo "On some systems, it can be slow to run. Please be patient."
+ echo "Set up the files necessary to run WeeWX at system startup."
if [ ! -d $UTIL_ROOT ]; then
echo "Cannot find utility files at location '$UTIL_ROOT'"
@@ -27,21 +46,22 @@ do_install() {
echo "Copying files from $UTIL_ROOT..."
if [ -d /etc/udev/rules.d ]; then
echo " udev rules"
- cp $UTIL_ROOT/udev/rules.d/weewx.rules /etc/udev/rules.d/60-weewx.rules
- fi
- if [ -d /etc/init.d ]; then
- echo " init script"
- cp $UTIL_ROOT/init.d/weewx-multi /etc/init.d/weewx
- chmod 755 /etc/init.d/weewx
+ copy_file $UTIL_ROOT/udev/rules.d/weewx.rules /etc/udev/rules.d/60-weewx.rules
+ echo " If you are using a device that is connected to the computer by USB or"
+ echo " serial port, unplug the device then plug it back in again to ensure that"
+ echo " permissions are applied correctly."
fi
+ echo " defaults"
+ copy_file $UTIL_ROOT/default/weewx /etc/default/weewx
+
+ echo " init script"
+ copy_file $UTIL_ROOT/init.d/weewx-multi /etc/init.d/weewx
+ chmod 755 /etc/init.d/weewx
+
echo "Enabling weewx..."
update-rc.d weewx defaults
- echo "If you are using a device that is connected to the computer by USB or"
- echo "serial port, unplug the device then plug it back in again to ensure that"
- echo "permissions are applied correctly."
- echo ""
echo "You can start weewx with the following command:"
echo " '\033[1msudo /etc/init.d/weewx start\033[0m'"
}
@@ -52,14 +72,12 @@ do_uninstall() {
echo "Disabling weewx..."
update-rc.d weewx remove
echo "Removing files..."
- if [ -f /etc/init.d/weewx ]; then
- echo " init script"
- rm /etc/init.d/weewx
- fi
- if [ -f /etc/udev/rules.d/60-weewx.rules ]; then
- echo " udev rules"
- rm /etc/udev/rules.d/60-weewx.rules
- fi
+ echo " init script"
+ remove_file /etc/init.d/weewx
+ echo " defaults"
+ remove_file /etc/default/weewx
+ echo " udev rules"
+ remove_file /etc/udev/rules.d/60-weewx.rules
}
ACTION=$1
diff --git a/src/weewx_data/util/default/weewx b/src/weewx_data/util/default/weewx
index f03ede80..09a537c7 100644
--- a/src/weewx_data/util/default/weewx
+++ b/src/weewx_data/util/default/weewx
@@ -1,4 +1,10 @@
+# WeeWX parameters that are used in startup and init scripts
WEEWX_PYTHON=python3
WEEWX_PYTHON_ARGS=
WEEWX_BINDIR=/usr/share/weewx
-WEEWX_CFG=/etc/weewx/weewx.conf
+WEEWX_CFGDIR=/etc/weewx
+WEEWX_RUNDIR=/var/run/weewx
+WEEWX_USER=weewx
+WEEWX_GROUP=weewx
+WEEWX_INSTANCES="weewx"
+WEEWX_CFG=weewx.conf
diff --git a/src/weewx_data/util/init.d/weewx.bsd b/src/weewx_data/util/init.d/weewx
similarity index 51%
rename from src/weewx_data/util/init.d/weewx.bsd
rename to src/weewx_data/util/init.d/weewx
index 239123a6..12719b5e 100755
--- a/src/weewx_data/util/init.d/weewx.bsd
+++ b/src/weewx_data/util/init.d/weewx
@@ -1,19 +1,26 @@
#!/bin/sh
-# Start script for FreeBSD, contributed by user Fabian Abplanalp
-# Put this script in /usr/local/etc/rc.d then adjust WEEWX_BIN and
-# WEEWX_CFG values in /etc/defaults/weewx
+#
+# Generic SysV startup script. Put this file in the system's init script
+# directory, then create appropriate symlinks for your system runlevels.
+# To modify the behavior of this script, adjust the values in the file
+# /etc/defaults/weewx or /etc/default/weewx, as appropriate.
-WEEWX_BIN="/opt/weewx/bin/weewxd"
-WEEWX_CFG="/opt/weewx/weewx.conf"
-WEEWX_PID="/var/run/weewx.pid"
+WEEWX_PYTHON=python3
+WEEWX_BINDIR=/usr/share/weewx
+WEEWX_CFGDIR=/etc/weewx
+WEEWX_RUNDIR=/var/run
+WEEWX_CFG=weewx.conf
# Read configuration variable file if it is present
[ -r /etc/defaults/weewx ] && . /etc/defaults/weewx
+WEEWXD=$WEEWX_BINDIR/weewxd.py
+WEEWX_PID=$WEEWX_RUNDIR/weewx.pid"
+
case "$1" in
"start")
echo "Starting weewx..."
- ${WEEWX_BIN} ${WEEWX_CFG} --daemon &
+ ${WEEWX_PYTHON} ${WEEWXD} ${WEEWX_CFGDIR}/${WEEWX_CFG} &
echo $! > ${WEEWX_PID}
echo "done"
;;
diff --git a/src/weewx_data/util/init.d/weewx-multi b/src/weewx_data/util/init.d/weewx-multi
index 2bedd859..f53a9c37 100755
--- a/src/weewx_data/util/init.d/weewx-multi
+++ b/src/weewx_data/util/init.d/weewx-multi
@@ -1,28 +1,21 @@
#! /bin/sh
-# Copyright 2016-2022 Matthew Wall, all rights reserved
+# Copyright 2016-2023 Matthew Wall, all rights reserved
# init script to run multiple instances of weewx
#
# each weewx instance is identified by name. that name is used to identify the
-# configuration and pid files.
+# configuration and pid files. if no list of instances is specified, then run
+# a single instance of weewxd using the configuration file weewx.conf.
#
-# this init script expects the following configuration:
-# /etc/weewx/a.conf
-# /etc/weewx/b.conf
-# /var/run/weewx/weewxd-a.pid
-# /var/run/weewx/weewxd-b.pid
-#
-# with the appropriate rsyslog and logrotate configurations:
-# /var/log/weewx/weewxd-a.log
-# /var/log/weewx/weewxd-b.log
-#
-# to configure the script, override variables in /etc/default/weewx-multi
+# to configure the script, override variables in /etc/default/weewx
# for example:
#
# WEEWX_INSTANCES="vantage acurite"
-# WEEWX_BINDIR=/opt/weewx/bin
+# WEEWX_PYTHON=python3
+# WEEWX_BINDIR=/opt/weewx
# WEEWX_CFGDIR=/etc/weewx
# WEEWX_RUNDIR=/var/run/weewx
# WEEWX_USER=weewx
+# WEEWX_GROUP=weewx
### BEGIN INIT INFO
# Provides: weewx-multi
@@ -34,29 +27,33 @@
# Description: Manages multiple instances of weewx
### END INIT INFO
+# Try to keep systemd from screwing everything up
+export SYSTEMCTL_SKIP_REDIRECT=1
+
PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC=weewx
WEEWX_INSTANCES="weewx"
-WEEWX_BINDIR=/opt/weewx/bin
+WEEWX_PYTHON=python3
+WEEWX_BINDIR=/opt/weewx
WEEWX_CFGDIR=/etc/weewx
WEEWX_RUNDIR=/var/run/weewx
WEEWX_USER=root
-
-# Try to keep systemd from screwing everything up
-export SYSTEMCTL_SKIP_REDIRECT=1
+WEEWX_GROUP=root
# Read configuration variable file if it is present
[ -r /etc/default/weewx ] && . /etc/default/weewx
-DESC=weewx
-DAEMON=$WEEWX_BINDIR/weewxd
+WEEWXD=$WEEWX_BINDIR/weewxd.py
# Exit if the package is not installed
-if [ ! -x "$DAEMON" ]; then
- echo "The $DESC daemon is not installed at $DAEMON"
+if [ ! -x "$WEEWXD" ]; then
+ echo "The $DESC daemon is not installed at $WEEWXD"
exit 0
fi
+DAEMON=$WEEWX_PYTHON $WEEWXD
+
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
@@ -68,6 +65,7 @@ fi
if [ ! -d $WEEWX_RUNDIR ]; then
mkdir -p $WEEWX_RUNDIR
chown $WEEWX_USER $WEEWX_RUNDIR
+ chgrp $WEEWX_GROUP $WEEWX_RUNDIR
fi
# start the daemon
diff --git a/src/weewx_data/util/init.d/weewx.debian b/src/weewx_data/util/init.d/weewx.debian
deleted file mode 100755
index b0a5fc60..00000000
--- a/src/weewx_data/util/init.d/weewx.debian
+++ /dev/null
@@ -1,181 +0,0 @@
-#! /bin/sh
-# Author: Tom Keffer
-# Startup script for Debian derivatives
-#
-# the skeleton script in debian 6 does not work properly in package scripts.
-# the return/exit codes cause {pre|post}{inst|rm} to fail regardless of the
-# script completion status. this script exits explicitly.
-#
-# the skeleton script also does not work properly with python applications,
-# as the lsb tools cannot distinguish between the python interpreter and
-# the python code that was invoked. this script uses ps and grep to look
-# for the application signature instead of using the lsb tools to determine
-# whether the app is running.
-#
-### BEGIN INIT INFO
-# Provides: weewx
-# Required-Start: $local_fs $remote_fs $syslog $time
-# Required-Stop: $local_fs $remote_fs $syslog
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: weewx weather system
-# Description: Manages the weewx weather system
-### END INIT INFO
-
-# Do NOT "set -e"
-
-# PATH should only include /usr/* if it runs after the mountnfs.sh script
-PATH=/sbin:/usr/sbin:/bin:/usr/bin
-
-DESC="weewx weather system"
-NAME=weewx
-
-# these can be overridden in the default file
-WEEWX_BIN=/home/weewx/bin/weewxd
-WEEWX_CFG=/home/weewx/weewx.conf
-WEEWX_PID=/var/run/$NAME.pid
-WEEWX_USER=root
-
-# Read configuration variable file if it is present
-[ -r /etc/default/$NAME ] && . /etc/default/$NAME
-
-# Exit if the package is not installed
-[ -x "$WEEWX_BIN" ] || exit 0
-
-DAEMON=$WEEWX_BIN
-DAEMON_ARGS="--daemon --pidfile=$WEEWX_PID $WEEWX_CFG"
-
-# Load the VERBOSE setting and other rcS variables
-. /lib/init/vars.sh
-
-# Define LSB log_* functions.
-# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
-. /lib/lsb/init-functions
-
-# start the daemon/service
-# 0 if daemon has been started
-# 1 if daemon was already running
-# 2 if daemon could not be started
-# check using ps not the pid file. pid file could be leftover.
-do_start() {
- NPROC=$(count_procs)
- if [ $NPROC != 0 ]; then
- return 1
- fi
- start-stop-daemon --start --chuid $WEEWX_USER --pidfile $WEEWX_PID --exec $DAEMON -- $DAEMON_ARGS || return 2
- return 0
-}
-
-# stop the daemon/service
-# 0 if daemon has been stopped
-# 1 if daemon was already stopped
-# 2 if daemon could not be stopped
-# other if a failure occurred
-do_stop() {
- # bail out if the app is not running
- NPROC=$(count_procs)
- if [ $NPROC = 0 ]; then
- return 1
- fi
- # bail out if there is no pid file
- if [ ! -f $WEEWX_PID ]; then
- return 1
- fi
- start-stop-daemon --stop --user $WEEWX_USER --pidfile $WEEWX_PID
- # we cannot trust the return value from start-stop-daemon
- RETVAL=2
- c=0
- while [ $c -lt 24 -a "$RETVAL" = "2" ]; do
- c=`expr $c + 1`
- # process may not really have completed, so check it
- NPROC=$(count_procs)
- if [ $NPROC = 0 ]; then
- RETVAL=0
- else
- echo -n "."
- sleep 5
- fi
- done
- if [ "$RETVAL" = "0" -o "$RETVAL" = "1" ]; then
- # delete the pid file just in case
- rm -f $WEEWX_PID
- fi
- return "$RETVAL"
-}
-
-# send a SIGHUP to the daemon/service
-do_reload() {
- start-stop-daemon --stop --signal 1 --quiet --user $WEEWX_USER --pidfile $WEEWX_PID
- return 0
-}
-
-count_procs() {
- NPROC=`ps ax | grep weewxd | grep $NAME.pid | wc -l`
- echo $NPROC
-}
-
-RETVAL=0
-case "$1" in
- start)
- log_daemon_msg "Starting $DESC" "$NAME"
- do_start
- case "$?" in
- 0) log_end_msg 0; RETVAL=0 ;;
- 1) log_action_cont_msg " already running" && log_end_msg 0; RETVAL=0 ;;
- 2) log_end_msg 1; RETVAL=1 ;;
- esac
- ;;
- stop)
- log_daemon_msg "Stopping $DESC" "$NAME"
- do_stop
- case "$?" in
- 0) log_end_msg 0; RETVAL=0 ;;
- 1) log_action_cont_msg " not running" && log_end_msg 0; RETVAL=0 ;;
- 2) log_end_msg 1; RETVAL=1 ;;
- esac
- ;;
- status)
- NPROC=$(count_procs)
- if [ $NPROC -gt 1 ]; then
- MSG="running multiple times"
- elif [ $NPROC = 1 ]; then
- MSG="running"
- else
- MSG="not running"
- fi
- log_daemon_msg "Status of $DESC" "$MSG"
- log_end_msg 0
- RETVAL=0
- ;;
- reload|force-reload)
- log_daemon_msg "Reloading $DESC" "$NAME"
- do_reload
- RETVAL=$?
- log_end_msg $RETVAL
- ;;
- restart)
- log_daemon_msg "Restarting $DESC" "$NAME"
- do_stop
- case "$?" in
- 0|1)
- do_start
- case "$?" in
- 0) log_end_msg 0; RETVAL=0 ;;
- 1) log_end_msg 1; RETVAL=1 ;; # Old process still running
- *) log_end_msg 1; RETVAL=1 ;; # Failed to start
- esac
- ;;
- *)
- # Failed to stop
- log_end_msg 1
- RETVAL=1
- ;;
- esac
- ;;
- *)
- echo "Usage: $0 {start|stop|status|restart|reload}"
- exit 3
- ;;
-esac
-
-exit $RETVAL
diff --git a/src/weewx_data/util/init.d/weewx.freebsd b/src/weewx_data/util/init.d/weewx.freebsd
old mode 100644
new mode 100755
index a6548a79..853c6fc9
--- a/src/weewx_data/util/init.d/weewx.freebsd
+++ b/src/weewx_data/util/init.d/weewx.freebsd
@@ -1,13 +1,24 @@
+#!/bin/sh
#
# PROVIDE: weewx
# REQUIRE: DAEMON
+# KEYWORD: shutdown
#
-# Add the following line to /etc/rc.conf.local or /etc/rc.conf
-# to enable weewx:
+# install this file as /usr/local/etc/rc.d/weewx
#
-# weewx_enable (bool): Set to NO by default
-# Set it to YES to enable weewx
+# to enable it, put this in /etc/rc.conf.local
+# weewx_enable=YES
#
+# to disable it, use weewx_enable=NO
+
+WEEWX_PYTHON=/usr/local/bin/python3
+WEEWX_BINDIR=/usr/local/weewx/src
+WEEWX_CFGDIR=/usr/local/etc/weewx
+WEEWX_RUNDIR=/var/run
+WEEWX_CFG=weewx.conf
+
+# Read configuration variable file if it is present
+[ -r /etc/defaults/weewx ] && . /etc/defaults/weewx
. /etc/rc.subr
@@ -17,15 +28,26 @@ rcvar=weewx_enable
load_rc_config $name
start_cmd=weewx_start
-weewx_daemon=/usr/local/etc/weewx/bin/weewxd
+stop_cmd=weewx_stop
+
+weewx_daemon="${WEEWX_PYTHON} ${WEEWX_BINDIR}/weewxd.py"
command=${weewx_daemon}
-procname=${weewx_procname:-/usr/local/bin/python3}
-weewx_pid=/var/run/weewx.pid
-weewx_config=/usr/local/etc/weewx/weewx.conf
+procname=${weewx_procname:-${WEEWX_PYTHON}}
+weewx_pid=${WEEWX_RUNDIR}/weewx.pid
+weewx_config=${WEEWX_CFGDIR}/${WEEWX_CFG}
weewx_start() {
- echo "Starting ${name}."
- ${weewx_daemon} --daemon --pidfile=${weewx_pid} ${weewx_config} &
+ echo "Starting ${name}."
+ ${weewx_daemon} --daemon --pidfile=${weewx_pid} ${weewx_config}
+}
+
+weewx_stop() {
+ if [ -f ${weewx_pid} ]; then
+ echo "Stopping ${name}."
+ kill `cat ${weewx_pid}`
+ else
+ echo "${name} is not running"
+ fi
}
run_rc_command "$1"
diff --git a/src/weewx_data/util/init.d/weewx.lsb b/src/weewx_data/util/init.d/weewx.lsb
deleted file mode 100755
index 5b7ac296..00000000
--- a/src/weewx_data/util/init.d/weewx.lsb
+++ /dev/null
@@ -1,275 +0,0 @@
-#!/bin/bash
-# Author: Tom Keffer
-# LSB system startup script for weewx
-
-# derived from LSB template script by Kurt Garloff, SUSE / Novell
-#
-# see http://www.linuxbase.org/spec/
-# http://www.tldp.org/HOWTO/HighQuality-Apps-HOWTO/
-#
-# Note: This script uses functions rc_XXX defined in /etc/rc.status on
-# UnitedLinux/SUSE/Novell based Linux distributions. However, it will work
-# on other distributions as well, by using the LSB (Linux Standard Base)
-# or RH functions or by open coding the needed functions.
-
-# chkconfig: 345 99 00
-# description: weewx weather daemon
-
-### BEGIN INIT INFO
-# Provides: weewx
-# Required-Start: $local_fs $syslog $time
-# Required-Stop: $local_fs $syslog $time
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: weewx weather system
-# Description: Manages the weewx weather system
-### END INIT INFO
-
-# Note on runlevels:
-# 0 - halt/poweroff 6 - reboot
-# 1 - single user 2 - multiuser without network exported
-# 3 - multiuser w/ network (text mode) 5 - multiuser w/ network and X11 (xdm)
-
-# Check for missing binaries (stale symlinks should not happen)
-# Note: Special treatment of stop for LSB conformance
-WEEWX_BIN=/home/weewx/bin/weewxd
-WEEWX_CFG=/home/weewx/weewx.conf
-WEEWX_ARGS="--daemon $WEEWX_CFG"
-test -x $WEEWX_BIN || { echo "$WEEWX_BIN not installed";
- if [ "$1" = "stop" ]; then exit 0;
- else exit 5; fi; }
-
-# Source LSB init functions
-# providing start_daemon, killproc, pidofproc,
-# log_success_msg, log_failure_msg and log_warning_msg.
-# This is currently not used by UnitedLinux based distributions and
-# not needed for init scripts for UnitedLinux only. If it is used,
-# the functions from rc.status should not be sourced or used.
-#. /lib/lsb/init-functions
-
-# Shell functions sourced from /etc/rc.status:
-# rc_check check and set local and overall rc status
-# rc_status check and set local and overall rc status
-# rc_status -v be verbose in local rc status and clear it afterwards
-# rc_status -v -r ditto and clear both the local and overall rc status
-# rc_status -s display "skipped" and exit with status 3
-# rc_status -u display "unused" and exit with status 3
-# rc_failed set local and overall rc status to failed
-# rc_failed set local and overall rc status to
-# rc_reset clear both the local and overall rc status
-# rc_exit exit appropriate to overall rc status
-# rc_active checks whether a service is activated by symlinks
-
-# Use the SUSE rc_ init script functions;
-# emulate them on LSB, RH and other systems
-
-# Default: Assume sysvinit binaries exist
-start_daemon() { /sbin/start_daemon ${1+"$@"}; }
-killproc() { /sbin/killproc ${1+"$@"}; }
-pidofproc() { /sbin/pidofproc ${1+"$@"}; }
-checkproc() { /sbin/checkproc ${1+"$@"}; }
-if test -e /etc/rc.status; then
- # SUSE rc script library
- . /etc/rc.status
-else
- export LC_ALL=POSIX
- _cmd=$1
- declare -a _SMSG
- if test "${_cmd}" = "status"; then
- _SMSG=(running dead dead unused unknown reserved)
- _RC_UNUSED=3
- else
- _SMSG=(done failed failed missed failed skipped unused failed failed reserved)
- _RC_UNUSED=6
- fi
- if test -e /lib/lsb/init-functions; then
- # LSB
- . /lib/lsb/init-functions
- echo_rc()
- {
- if test ${_RC_RV} = 0; then
- log_success_msg " [${_SMSG[${_RC_RV}]}] "
- else
- log_failure_msg " [${_SMSG[${_RC_RV}]}] "
- fi
- }
- # TODO: Add checking for lockfiles
- checkproc() { return pidofproc ${1+"$@"} >/dev/null 2>&1; }
- elif test -e /etc/init.d/functions; then
- # RHAT
- . /etc/init.d/functions
- echo_rc()
- {
- #echo -n " [${_SMSG[${_RC_RV}]}] "
- if test ${_RC_RV} = 0; then
- success " [${_SMSG[${_RC_RV}]}] "
- else
- failure " [${_SMSG[${_RC_RV}]}] "
- fi
- }
- checkproc() { return status ${1+"$@"}; }
- start_daemon() { return daemon ${1+"$@"}; }
- else
- # emulate it
- echo_rc() { echo " [${_SMSG[${_RC_RV}]}] "; }
- fi
- rc_reset() { _RC_RV=0; }
- rc_failed()
- {
- if test -z "$1"; then
- _RC_RV=1;
- elif test "$1" != "0"; then
- _RC_RV=$1;
- fi
- return ${_RC_RV}
- }
- rc_check()
- {
- return rc_failed $?
- }
- rc_status()
- {
- rc_failed $?
- if test "$1" = "-r"; then _RC_RV=0; shift; fi
- if test "$1" = "-s"; then rc_failed 5; echo_rc; rc_failed 3; shift; fi
- if test "$1" = "-u"; then rc_failed ${_RC_UNUSED}; echo_rc; rc_failed 3; shift; fi
- if test "$1" = "-v"; then echo_rc; shift; fi
- if test "$1" = "-r"; then _RC_RV=0; shift; fi
- return ${_RC_RV}
- }
- rc_exit() { exit ${_RC_RV}; }
- rc_active()
- {
- if test -z "$RUNLEVEL"; then read RUNLEVEL REST < <(/sbin/runlevel); fi
- if test -e /etc/init.d/S[0-9][0-9]${1}; then return 0; fi
- return 1
- }
-fi
-
-# Reset status of this service
-rc_reset
-
-# Return values acc. to LSB for all commands but status:
-# 0 - success
-# 1 - generic or unspecified error
-# 2 - invalid or excess argument(s)
-# 3 - unimplemented feature (e.g. "reload")
-# 4 - user had insufficient privileges
-# 5 - program is not installed
-# 6 - program is not configured
-# 7 - program is not running
-# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
-#
-# Note that starting an already running service, stopping
-# or restarting a not-running service as well as the restart
-# with force-reload (in case signaling is not supported) are
-# considered a success.
-
-case "$1" in
- start)
- echo -n "Starting weewx "
- ## Start daemon with startproc(8). If this fails
- ## the return value is set appropriately by startproc.
- start_daemon $WEEWX_BIN $WEEWX_ARGS
-
- # Remember status and be verbose
- rc_status -v
- ;;
- stop)
- echo -n "Shutting down weewx "
- ## Stop daemon with killproc(8) and if this fails
- ## killproc sets the return value according to LSB.
-
- killproc -TERM $WEEWX_BIN
-
- # Remember status and be verbose
- rc_status -v
- ;;
- try-restart|condrestart)
- ## Do a restart only if the service was active before.
- ## Note: try-restart is now part of LSB (as of 1.9).
- ## RH has a similar command named condrestart.
- if test "$1" = "condrestart"; then
- echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
- fi
- $0 status
- if test $? = 0; then
- $0 restart
- else
- rc_reset # Not running is not a failure.
- fi
- # Remember status and be quiet
- rc_status
- ;;
- restart)
- ## Stop the service and regardless of whether it was
- ## running or not, start it again.
- $0 stop
- $0 start
-
- # Remember status and be quiet
- rc_status
- ;;
- force-reload)
- ## Signal the daemon to reload its config. Most daemons
- ## do this on signal 1 (SIGHUP).
- ## If it does not support it, restart the service if it
- ## is running.
-
- echo -n "Reload service weewx "
- ## if it supports it:
- killproc -HUP $WEEWX_BIN
- touch /var/run/weewx.pid
- rc_status -v
-
- ## Otherwise:
- #$0 try-restart
- #rc_status
- ;;
- reload)
- ## Like force-reload, but if daemon does not support
- ## signaling, do nothing (!)
-
- # If it supports signaling:
- echo -n "Reload service weewx "
- killproc -HUP $WEEWX_BIN
- touch /var/run/weewx.pid
- rc_status -v
-
- ## Otherwise if it does not support reload:
- #rc_failed 3
- #rc_status -v
- ;;
- status)
- echo -n "Checking for service weewx "
- ## Check status with checkproc(8), if process is running
- ## checkproc will return with exit status 0.
-
- # Return value is slightly different for the status command:
- # 0 - service up and running
- # 1 - service dead, but /var/run/ pid file exists
- # 2 - service dead, but /var/lock/ lock file exists
- # 3 - service not running (unused)
- # 4 - service status unknown :-(
- # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
-
- # NOTE: checkproc returns LSB compliant status values.
- checkproc $WEEWX_BIN
- # NOTE: rc_status knows that we called this init script with
- # "status" option and adapts its messages accordingly.
- rc_status -v
- ;;
- probe)
- ## Optional: Probe for the necessity of a reload, print out the
- ## argument to this init script which is required for a reload.
- ## Note: probe is not (yet) part of LSB (as of 1.9)
-
- #test /etc/FOO/FOO.conf -nt /var/run/FOO.pid && echo reload
- echo "Probe not supported"
- ;;
- *)
- echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
- exit 1
- ;;
-esac
-rc_exit
diff --git a/src/weewx_data/util/init.d/weewx.redhat b/src/weewx_data/util/init.d/weewx.redhat
deleted file mode 100755
index 731eac44..00000000
--- a/src/weewx_data/util/init.d/weewx.redhat
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/bin/sh
-# Author: Mark Jenks
-# Startup script for Redhat derivatives
-#
-# chkconfig: 2345 99 01
-# description: start and stop the weewx weather system
-#
-# Do NOT "set -e"
-
-# PATH should only include /usr/* if it runs after the mountnfs.sh script
-PATH=/sbin:/usr/sbin:/bin:/usr/bin
-
-NAME=weewx
-
-WEEWX_BIN=/home/weewx/bin/weewxd
-WEEWX_CFG=/home/weewx/weewx.conf
-WEEWX_PID=/var/run/$NAME.pid
-WEEWX_LOCK=/var/lock/subsys/$NAME
-
-# Read configuration variable file if it is present
-[ -r /etc/default/$NAME ] && . /etc/default/$NAME
-
-# Exit if the package is not installed
-[ -x "$WEEWX_BIN" ] || exit 0
-
-DAEMON_ARGS="--daemon --pidfile=$WEEWX_PID $WEEWX_CFG"
-
-# Source function library.
-. /etc/init.d/functions
-
-# See how we were called.
-case "$1" in
- start)
- # Start daemon.
- echo -n $"Starting $NAME: "
- daemon --pidfile $WEEWX_PID $WEEWX_BIN $DAEMON_ARGS
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && touch $WEEWX_LOCK
- ;;
- stop)
- # Stop daemon.
- echo -n $"Shutting down $NAME: "
- killproc $NAME
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && rm -f $WEEWX_LOCK
- ;;
- status)
- echo -n $"Checking for $NAME: "
- status $NAME
- RETVAL=$?
- ;;
- restart)
- echo -n $"Restarting $NAME: "
- $0 stop
- $0 start
- ;;
- reload)
- echo -n $"Reloading $NAME: "
- killproc $NAME -HUP
- RETVAL=$?
- echo
- ;;
- condrestart)
- [ -f $WEEWX_LOCK ] && restart || :
- ;;
- *)
- echo $"Usage: $0 {start|stop|status|restart|reload}"
- RETVAL=1
- ;;
-esac
-
-exit $RETVAL
diff --git a/src/weewx_data/util/init.d/weewx.suse b/src/weewx_data/util/init.d/weewx.suse
deleted file mode 100755
index cd3c7781..00000000
--- a/src/weewx_data/util/init.d/weewx.suse
+++ /dev/null
@@ -1,151 +0,0 @@
-#!/bin/bash
-# Author: Tom Keffer
-# Startup script for SuSE derivatives
-
-### BEGIN INIT INFO
-# Provides: weewx
-# Required-Start: $local_fs $syslog $time
-# Required-Stop: $local_fs $syslog $time
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: weewx weather system
-# Description: Manages the weewx weather system
-### END INIT INFO
-# chkconfig: 345 99 00
-# description: weewx weather daemon
-
-# runlevels:
-# 0 - halt/poweroff 6 - reboot
-# 1 - single user 2 - multiuser without network exported
-# 3 - multiuser w/ network (text mode) 5 - multiuser w/ network and X11 (xdm)
-
-# LSB compatible service control script; see http://www.linuxbase.org/spec/
-# Please send feedback to http://www.suse.de/feedback/
-# See also http://www.tldp.org/HOWTO/HighQuality-Apps-HOWTO/
-#
-# This scriopt uses functions rc_XXX defined in /etc/rc.status on
-# UnitedLinux/SUSE/Novell based Linux distributions.
-
-WEEWX_BIN=/home/weewx/bin/weewxd
-WEEWX_CFG=/home/weewx/weewx.conf
-WEEWX_ARGS="--daemon $WEEWX_CFG"
-WEEWX_PID_FILE=/var/run/weewx.pid
-
-# Read configuration variable file if it is present
-[ -r /etc/default/weewx ] && . /etc/default/weewx
-
-test -x $WEEWX_BIN || { echo "$WEEWX_BIN not installed";
- if [ "$1" = "stop" ]; then exit 0;
- else exit 5; fi; }
-
-# Shell functions sourced from /etc/rc.status:
-# rc_check check and set local and overall rc status
-# rc_status check and set local and overall rc status
-# rc_status -v be verbose in local rc status and clear it afterwards
-# rc_status -v -r ditto and clear both the local and overall rc status
-# rc_status -s display "skipped" and exit with status 3
-# rc_status -u display "unused" and exit with status 3
-# rc_failed set local and overall rc status to failed
-# rc_failed set local and overall rc status to
-# rc_reset clear both the local and overall rc status
-# rc_exit exit appropriate to overall rc status
-# rc_active checks whether a service is activated by symlinks
-
-# Assume sysvinit binaries exist
-start_daemon() { /sbin/start_daemon ${1+"$@"}; }
-killproc() { /sbin/killproc ${1+"$@"}; }
-pidofproc() { /sbin/pidofproc ${1+"$@"}; }
-checkproc() { /sbin/checkproc ${1+"$@"}; }
-# SUSE rc script library
-. /etc/rc.status
-
-# Reset status of this service
-rc_reset
-
-# Return values according to LSB for all commands but status:
-# 0 - success
-# 1 - generic or unspecified error
-# 2 - invalid or excess argument(s)
-# 3 - unimplemented feature (e.g. "reload")
-# 4 - user had insufficient privileges
-# 5 - program is not installed
-# 6 - program is not configured
-# 7 - program is not running
-# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
-#
-# Note that starting an already running service, stopping
-# or restarting a not-running service as well as the restart
-# with force-reload (in case signaling is not supported) are
-# considered a success.
-
-case "$1" in
- start)
- echo -n "Starting weewx "
- ## Start daemon with startproc(8). If this fails
- ## the return value is set appropriately by startproc.
- start_daemon $WEEWX_BIN $WEEWX_ARGS
- rc_status -v
- ;;
- stop)
- echo -n "Shutting down weewx "
- ## Stop daemon with killproc(8) and if this fails
- ## killproc sets the return value according to LSB.
- killproc -TERM -p $WEEWX_PID_FILE python
- rc_status -v
- ;;
- try-restart|condrestart)
- ## Do a restart only if the service was active before.
- ## RH has a similar command named condrestart.
- if test "$1" = "condrestart"; then
- echo "Use try-restart rather than condrestart"
- fi
- $0 status
- if test $? = 0; then
- $0 restart
- else
- rc_reset # Not running is not a failure.
- fi
- rc_status
- ;;
- restart)
- ## Stop the service and regardless of whether it was
- ## running or not, start it again.
- $0 stop
- $0 start
- rc_status
- ;;
- force-reload)
- echo -n "Reload service weewx "
- killproc -HUP -p $WEEWX_PID_FILE python
- rc_status -v
- ;;
- reload)
- echo -n "Reload service weewx "
- killproc -HUP -p $WEEWX_PID_FILE python
- rc_status -v
- ;;
- status)
- echo -n "Checking for service weewx "
- ## Check status with checkproc(8), if process is running
- ## checkproc will return with exit status 0.
-
- # Return value is slightly different for the status command:
- # 0 - service up and running
- # 1 - service dead, but /var/run/ pid file exists
- # 2 - service dead, but /var/lock/ lock file exists
- # 3 - service not running (unused)
- # 4 - service status unknown :-(
- # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
-
- checkproc $WEEWX_BIN
- rc_status -v
- ;;
- probe)
- echo "Probe not supported"
- ;;
- *)
- echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
- exit 1
- ;;
-esac
-rc_exit
diff --git a/src/weewx_data/util/systemd/weewx.service b/src/weewx_data/util/systemd/weewx.service
index 0259acd1..96acc2e5 100644
--- a/src/weewx_data/util/systemd/weewx.service
+++ b/src/weewx_data/util/systemd/weewx.service
@@ -1,7 +1,4 @@
# systemd service configuration file for WeeWX
-#
-# For information about running WeeWX under systemd, see:
-# https://github.com/weewx/weewx/wiki/systemd
[Unit]
Description=WeeWX weather system
@@ -10,11 +7,11 @@ Requires=time-sync.target
After=time-sync.target
[Service]
-ExecStart=weewxd weewx.conf
+ExecStart=WEEWX_PYTHON WEEWXD WEEWX_CFGDIR/weewx.conf
StandardOutput=null
StandardError=journal+console
-#User=weewx
-#Group=weewx
+User=WEEWX_USER
+Group=WEEWX_GROUP
[Install]
WantedBy=multi-user.target
diff --git a/src/weewx_data/util/systemd/weewx@.service b/src/weewx_data/util/systemd/weewx@.service
index 4228760c..4058b817 100644
--- a/src/weewx_data/util/systemd/weewx@.service
+++ b/src/weewx_data/util/systemd/weewx@.service
@@ -7,9 +7,6 @@
# config ~/weewx-data/XXX.conf configuration directory
# database_name ~/weewx-data/archive/XXX.sdb specified in XXX.conf
# HTML_ROOT ~/weewx-data/public_html/XXX specified in XXX.conf
-#
-# For information about running WeeWX under systemd, see:
-# https://github.com/weewx/weewx/wiki/systemd
[Unit]
Description=WeeWX %i
@@ -19,11 +16,11 @@ After=time-sync.target
PartOf=weewx.service
[Service]
-ExecStart=weewxd --log-label weewxd-%i $HOME/weewx-data/%i.conf
+ExecStart=WEEWX_PYTHON WEEWXD --log-label weewxd-%i WEEWX_CFGDIR/%i.conf
StandardOutput=null
StandardError=journal+console
-#User=weewx
-#Group=weewx
+User=WEEWX_USER
+Group=WEEWX_GROUP
[Install]
WantedBy=multi-user.target