Skip to content

Commit

Permalink
use a process counting technique that does not break and that does no…
Browse files Browse the repository at this point in the history
…t depend on systemd
  • Loading branch information
matthewwall committed Jul 4, 2024
1 parent 491a2a0 commit 55a367d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
3 changes: 3 additions & 0 deletions pkg/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
weewx (5.1.0-4) unstable; urgency=low
* ?
-- Matthew Wall <mwall.weewx@gmail.com> Thu, 04 Jul 2024 16:40:00 -0400
weewx (5.1.0-3) unstable; urgency=low
* do not try to validate lat/lon
-- Matthew Wall <mwall.weewx@gmail.com> Thu, 04 Jul 2024 15:59:00 -0400
Expand Down
20 changes: 8 additions & 12 deletions pkg/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ WEEWX_HTMLDIR="${WEEWX_HTMLDIR:-/var/www/html/weewx}"
WEEWX_USERDIR=/etc/weewx/bin/user
WEEWX_INSTANCES="${WEEWX_INSTANCES:-weewx}"

is_num() { x=`echo "$1" | grep "^[+-]\?[0-9]\+$"`; echo $x; }

# insert the driver and stanza into the configuration file
insert_driver() {
if [ ! -f $cfgfile ]; then
Expand Down Expand Up @@ -166,10 +164,8 @@ install_weewxconf() {
db_get weewx/latlon
lat=$(echo $RET | cut -d, -f1 | sed 's/^ //g' | sed 's/ $//g')
lon=$(echo $RET | cut -d, -f2 | sed 's/^ //g' | sed 's/ $//g')
# lat=$(is_num $lat)
# lon=$(is_num $lon)
# if [ "$lat" = "" ]; then lat=0.0; fi
# if [ "$lon" = "" ]; then lon=0.0; fi
if [ "$lat" = "" ]; then lat=0.0; fi
if [ "$lon" = "" ]; then lon=0.0; fi

db_get weewx/altitude
altitude=$(echo $RET | cut -d, -f1 | sed 's/^ //g' | sed 's/ $//g')
Expand Down Expand Up @@ -516,7 +512,7 @@ stop_old_weewxd() {

# see how many instances of weewxd are running
count_instances() {
NUM_INSTANCES=$(ps ax | grep -c [wee]wxd)
NUM_INSTANCES=$(ps ax | grep weewxd | egrep -v grep | wc -l)
echo $NUM_INSTANCES
}

Expand All @@ -537,12 +533,12 @@ fi
# - multiple instances
case "$1" in
configure)
num_weewxd=1
num_weewxd=1
if [ "$2" != "" ]; then
# this is an upgrade, so see if weewx is already running
num_weewxd=$(count_instances)
# this is an upgrade so ensure that weewxd is not running
stop_old_weewxd $pid1
# this is an upgrade, so see if weewx is already running
num_weewxd=$(count_instances)
# this is an upgrade, so ensure that weewx is not running
stop_old_weewxd $pid1
fi
get_user_info
create_user
Expand Down
2 changes: 1 addition & 1 deletion pkg/weewx.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ stop_old_weewxd() {

# see how many instances of weewxd are running
count_instances() {
NUM_INSTANCES=$(ps ax | grep -c [wee]wxd)
NUM_INSTANCES=$(ps ax | grep weewxd | egrep -v grep | wc -l)
echo $NUM_INSTANCES
}

Expand Down

0 comments on commit 55a367d

Please sign in to comment.