Add --purge to uninstall script, remove wmbusmeters-admin and add deb_local build target.

pull/954/head
Fredrik Öhrström 2023-05-06 20:44:52 +02:00
rodzic 98ce7eae2c
commit 509a810764
12 zmienionych plików z 1106 dodań i 1885 usunięć

Wyświetl plik

@ -12,7 +12,7 @@ jobs:
run: | run: |
sudo apt install -y eatmydata sudo apt install -y eatmydata
sudo eatmydata apt install -y devscripts debhelper sudo eatmydata apt install -y devscripts debhelper
sudo eatmydata apt build-dep -y . || sudo eatmydata apt install -y librtlsdr-dev libncurses-dev adduser sudo eatmydata apt build-dep -y . || sudo eatmydata apt install -y librtlsdr-dev adduser
- id: PREPARE_SOURCE - id: PREPARE_SOURCE
run: | run: |
ln -s deb debian ln -s deb debian

Wyświetl plik

@ -11,7 +11,7 @@ jobs:
- id: INSTALL_ADDITIONAL_BUILD_DEPENDENCIES - id: INSTALL_ADDITIONAL_BUILD_DEPENDENCIES
run: | run: |
sudo apt install -y eatmydata sudo apt install -y eatmydata
sudo eatmydata apt-get install librtlsdr-dev libusb-dev ncurses-dev sudo eatmydata apt-get install librtlsdr-dev libusb-dev
- id: CONFIGURE - id: CONFIGURE
run: eatmydata ./configure run: eatmydata ./configure
- id: MAKE - id: MAKE

22
CHANGES
Wyświetl plik

@ -1,3 +1,25 @@
The ha-addon has been moved to https://github.com/wmbusmeters/wmbusmeters-ha-addon
Bug fixed where an mbus telegram was mistakenly detected as wmbus.
The snap package can now use the serial port so that it works with mbus.
DeDragonSlayer improved the amiplus with the maximum power consumption field. Thanks DeDragonSlayer!
The calculator was improved to properly handle the m3 unit and give a better
error message when a constant number lacks unit.
The sharky driver was improved.
The kamheat driver was updated with operating_time_h and a new auto-detect combo.
Bibo added support for the hydrocal m4 meter,
improved the kem-import and kem-extract scripts and
added support for the Aerius gas meter. Thanks Bibo!
The wmusmeters-admin tool has been removed since it was never really useful.
It will probably be replaced with something better.
Version 1.12.0 2023-03-12 Version 1.12.0 2023-03-12
Version 1.12.0-RC1 2023-03-12 Version 1.12.0-RC1 2023-03-12

Wyświetl plik

@ -64,7 +64,6 @@ else
# Release build # Release build
DEBUG_FLAGS=-Os -g DEBUG_FLAGS=-Os -g
STRIP_BINARY=cp $(BUILD)/wmbusmeters $(BUILD)/wmbusmeters.g; $(STRIP) $(BUILD)/wmbusmeters STRIP_BINARY=cp $(BUILD)/wmbusmeters $(BUILD)/wmbusmeters.g; $(STRIP) $(BUILD)/wmbusmeters
STRIP_ADMIN=cp $(BUILD)/wmbusmeters-admin $(BUILD)/wmbusmeters-admin.g; $(STRIP) $(BUILD)/wmbusmeters-admin
GCOV=To_run_gcov_add_DEBUG=true GCOV=To_run_gcov_add_DEBUG=true
endif endif
endif endif
@ -99,14 +98,13 @@ else
endif endif
VERSION:=$(BRANCH)$(TAG) VERSION:=$(BRANCH)$(TAG)
DEBVERSION:=$(BRANCH)$(TAG) LOCALDEBVERSION:=$(BRANCH)$(TAG)
LOCALCHANGES:= LOCALCHANGES:=
ifneq ($(strip $(CHANGES)),) ifneq ($(strip $(CHANGES)),)
# There are local un-committed changes. # There are local un-committed changes.
VERSION:=$(VERSION) with local changes VERSION:=$(VERSION) with local changes
COMMIT_HASH:=$(COMMIT_HASH) with local changes COMMIT_HASH:=$(COMMIT_HASH)+
DEBVERSION:=$(DEBVERSION)l
LOCALCHANGES:=true LOCALCHANGES:=true
endif endif
@ -188,9 +186,9 @@ else
endif endif
DRIVER_OBJS:=$(patsubst src/%.cc,$(BUILD)/%.o,$(DRIVER_OBJS)) DRIVER_OBJS:=$(patsubst src/%.cc,$(BUILD)/%.o,$(DRIVER_OBJS))
all: $(BUILD)/wmbusmeters $(BUILD)/wmbusmetersd $(BUILD)/wmbusmeters.g $(BUILD)/wmbusmeters-admin $(BUILD)/testinternals all: $(BUILD)/wmbusmeters $(BUILD)/wmbusmetersd $(BUILD)/wmbusmeters.g $(BUILD)/testinternals
deb: deb_release:
@if [ "$(RELEASE)" = "" ] ; then echo "Usage: make deb RELEASE=1.2.3" ; exit 1 ; fi @if [ "$(RELEASE)" = "" ] ; then echo "Usage: make deb RELEASE=1.2.3" ; exit 1 ; fi
@if [ "$$(cat deb/changelog | grep wmbusmeters\ \( | grep -o $(RELEASE))" != "$(RELEASE)" ]; then \ @if [ "$$(cat deb/changelog | grep wmbusmeters\ \( | grep -o $(RELEASE))" != "$(RELEASE)" ]; then \
echo "Changelog not updated with this release! It says:" ; \ echo "Changelog not updated with this release! It says:" ; \
@ -211,6 +209,30 @@ deb:
@echo "Running debbuild..." @echo "Running debbuild..."
@(cd packaging/wmbusmeters-$(RELEASE) ; cp -a deb debian; debuild ) @(cd packaging/wmbusmeters-$(RELEASE) ; cp -a deb debian; debuild )
deb_local:
@rm -rf packaging
@mkdir -p packaging
@echo "Using latest commit..."
@(cd packaging ; git clone $(PWD) wmbusmeters-$(LOCALDEBVERSION) ; cd wmbusmeters-$(LOCALDEBVERSION) )
@echo "Applying local changes..."
@(git diff > packaging/local_patch_$(LOCALDEBVERSION) ; \
cd packaging/wmbusmeters-$(LOCALDEBVERSION) ; \
patch -p 1 < ../local_patch_$(LOCALDEBVERSION) )
@(cd packaging/wmbusmeters-$(LOCALDEBVERSION) ; git show -s --format=%ct > ../release_date )
@echo "Removing git history..."
@(cd packaging ; rm -rf wmbusmeters-$(LOCALDEBVERSION)/.git )
@echo "Setting file timestamps to commit date..."
@(cd packaging ; export UT=$$(cat ./release_date) ; find . -exec touch -d "@$$UT" \{\} \; )
@echo "Creating orig archive..."
@(cd packaging ; tar czf ./wmbusmeters_$(LOCALDEBVERSION).orig.tar.gz wmbusmeters-$(LOCALDEBVERSION) )
@echo "Installing debian directory..."
@(cd packaging/wmbusmeters-$(LOCALDEBVERSION) ; cp -a deb debian )
@echo "Creating local dummy changelog..."
@echo "wmbusmeters ($(LOCALDEBVERSION)-99) unstable; urgency=low\n\n" \
" * Local build of deb current sources $(VERSION) $(COMMIT_HASH)\n\n" \
" -- No User <nouser@nowhere> $(shell LANG=C date -R)\n" > packaging/wmbusmeters-$(LOCALDEBVERSION)/debian/changelog
@echo "Running debbuild..."
@(cd packaging/wmbusmeters-$(LOCALDEBVERSION) ; debuild -i -us -uc -b )
# Check docs verifies that all options in the source have been mentioned in the README and in the man page. # Check docs verifies that all options in the source have been mentioned in the README and in the man page.
# Also any option not in the source but mentioned in the docs is warned for as well. # Also any option not in the source but mentioned in the docs is warned for as well.
@ -229,9 +251,14 @@ install: $(BUILD)/wmbusmeters check_docs
echo "Installing $(BUILD)/wmbusmeters" echo "Installing $(BUILD)/wmbusmeters"
@./install.sh $(BUILD)/wmbusmeters $(DESTDIR) $(EXTRA_INSTALL_OPTIONS) @./install.sh $(BUILD)/wmbusmeters $(DESTDIR) $(EXTRA_INSTALL_OPTIONS)
# Uninstall binaries and manpages. But keep configuration data and wmbusmeters user/group.
uninstall: uninstall:
@./uninstall.sh / @./uninstall.sh /
# Uninstall everything including configuration and wmbusmeters user/group.
uninstall_purge:
@./uninstall.sh / --purge
snapcraft: snapcraft:
snapcraft snapcraft
@ -253,15 +280,6 @@ $(BUILD)/wmbusmeters: $(BUILD)/wmbusmeters.g
$(BUILD)/wmbusmetersd: $(BUILD)/wmbusmeters $(BUILD)/wmbusmetersd: $(BUILD)/wmbusmeters
cp $(BUILD)/wmbusmeters $(BUILD)/wmbusmetersd cp $(BUILD)/wmbusmeters $(BUILD)/wmbusmetersd
ifeq ($(shell uname -s),Darwin)
$(BUILD)/wmbusmeters-admin:
touch $(BUILD)/wmbusmeters-admin
else
$(BUILD)/wmbusmeters-admin: $(PROG_OBJS) $(DRIVER_OBJS) $(BUILD)/admin.o $(BUILD)/ui.o $(BUILD)/short_manual.h
$(CXX) -o $(BUILD)/wmbusmeters-admin $(PROG_OBJS) $(DRIVER_OBJS) $(BUILD)/admin.o $(BUILD)/ui.o $(LDFLAGS) -lmenu -lform -lncurses -lrtlsdr $(USBLIB) -lpthread
$(STRIP_ADMIN)
endif
$(BUILD)/short_manual.h: README.md $(BUILD)/short_manual.h: README.md
echo 'R"MANUAL(' > $(BUILD)/short_manual.h echo 'R"MANUAL(' > $(BUILD)/short_manual.h
sed -n '/wmbusmeters version/,/```/p' README.md \ sed -n '/wmbusmeters version/,/```/p' README.md \

Wyświetl plik

@ -954,10 +954,7 @@ if this hangs, then do `sudo killall -9 wmbusmetersd` and/or `sudo killall -9 wm
Wmbusmeters expects the serial baud rate for the AMB8465 USB stick to be 9600 8n1. Wmbusmeters expects the serial baud rate for the AMB8465 USB stick to be 9600 8n1.
If you have used another tool and changed the baud rate to something else If you have used another tool and changed the baud rate to something else
you need to restore the baud rate to 9600 8n1. You can do that with that other tool, you need to restore the baud rate to 9600 8n1.
or you can try wmbusmeters-admin and select `Reset wmbus receives`
this command try all potential baud rates and send the factory reset command.
Then you have to unplug and reinsert the dongle.
If you like to send the bytes manually, the correct bytes are: If you like to send the bytes manually, the correct bytes are:

2301
configure vendored

Plik diff jest za duży Load Diff

Wyświetl plik

@ -54,14 +54,6 @@ AC_CHECK_LIB(rtlsdr, rtlsdr_get_device_count, [],
AC_MSG_ERROR([Could not find rtlsdr library. Try: sudo apt install librtlsdr-dev]) AC_MSG_ERROR([Could not find rtlsdr library. Try: sudo apt install librtlsdr-dev])
]) ])
AX_WITH_CURSES
if test ! "$ax_cv_curses" = "yes"
then
echo "Could not find ncurses library. Try: sudo apt install libncurses-dev"
exit 1
fi
AC_CONFIG_FILES([$OUTPUT_ROOT/spec.gmk:$SRC_ROOT/autoconf/spec.gmk.in]) AC_CONFIG_FILES([$OUTPUT_ROOT/spec.gmk:$SRC_ROOT/autoconf/spec.gmk.in])
AC_CONFIG_FILES([$OUTPUT_ROOT/Makefile:$SRC_ROOT/autoconf/Makefile.in]) AC_CONFIG_FILES([$OUTPUT_ROOT/Makefile:$SRC_ROOT/autoconf/Makefile.in])

Wyświetl plik

@ -1,11 +1,10 @@
# Copyright (C) 2021-2022 Fredrik Öhrström (gpl-3.0-or-later) # Copyright (C) 2021-2023 Fredrik Öhrström (gpl-3.0-or-later)
rm -f "$ROOT"/usr/bin/wmbusmeters "$ROOT"/usr/sbin/wmbusmetersd "$ROOT"/usr/bin/wmbusmeters-admin rm -f "$ROOT"/usr/bin/wmbusmeters "$ROOT"/usr/sbin/wmbusmetersd
mkdir -p "$ROOT"/usr/bin mkdir -p "$ROOT"/usr/bin
mkdir -p "$ROOT"/usr/sbin mkdir -p "$ROOT"/usr/sbin
cp "$SRC" "$ROOT"/usr/bin/wmbusmeters cp "$SRC" "$ROOT"/usr/bin/wmbusmeters
cp "${SRC}-admin" "$ROOT"/usr/bin/wmbusmeters-admin
(cd "$ROOT"/usr/sbin; ln -s ../bin/wmbusmeters wmbusmetersd) (cd "$ROOT"/usr/sbin; ln -s ../bin/wmbusmeters wmbusmetersd)
echo "binaries: installed $ROOT/usr/bin/wmbusmeters $ROOT/usr/sbin/wmbusmetersd $ROOT/usr/bin/wmbusmeters-admin" echo "binaries: installed $ROOT/usr/bin/wmbusmeters $ROOT/usr/sbin/wmbusmetersd"

Wyświetl plik

@ -14,11 +14,21 @@ then
loglevel=normal loglevel=normal
# Remember to change auto here to the device you are going to use in production. # Remember to change auto here to the device you are going to use in production.
device=auto:t1 device=auto:t1
logfile=/var/log/wmbusmeters/wmbusmeters.log
# Set to true to capture all received telegrams in log file.
logtelegrams=false logtelegrams=false
format=json format=json
meterfiles=/var/lib/wmbusmeters/meter_readings # Enable the meterfiles to write telegrams to disk.
meterfilesaction=overwrite #meterfiles=/var/lib/wmbusmeters/meter_readings
logfile=/var/log/wmbusmeters/wmbusmeters.log #meterfilesaction=overwrite
# Enable execution of a shell command for each received telegram. For example: curl or mqtt
#shell=/usr/bin/mosquitto_pub -h localhost -t wmbusmeters/$METER_ID -m "$METER_JSON"
#shell=psql water -c "insert into consumption values ('$METER_ID',$METER_TOTAL_M3,'$METER_TIMESTAMP') "
# The alarmshell is executed when a problem with the receiving radio hardware is detected.
#alarmshell=/usr/bin/mosquitto_pub -h localhost -t wmbusmeters_alarm -m "$ALARM_TYPE $ALARM_MESSAGE"
# The alarmtimeout and expected activity is also used to detect failing receiving radio hardware.
#alarmtimeout=1h
#alarmexpectedactivity=mon-sun(00-23)
EOF EOF
chmod 644 "$ROOT"/etc/wmbusmeters.conf chmod 644 "$ROOT"/etc/wmbusmeters.conf
echo "conf file: created $ROOT/etc/wmbusmeters.conf" echo "conf file: created $ROOT/etc/wmbusmeters.conf"

Wyświetl plik

@ -1,466 +0,0 @@
/*
Copyright (C) 2017-2022 Fredrik Öhrström (gpl-3.0-or-later)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<syslog.h>
#include<time.h>
#include"serial.h"
#include"shell.h"
#include"ui.h"
#include"util.h"
#include"wmbus.h"
bool running_as_root_ = false;
bool member_of_dialout_ = false;
#define LIST_OF_MAIN_MENU \
X(DETECT_WMBUS_RECEIVERS, "Detect wmbus receiver") \
X(RESET_WMBUS_RECEIVERS, "Reset wmbus receiver") \
X(LISTEN_FOR_METERS, "Listen for meters") \
X(EDIT_CONFIG, "Edit config") \
X(EDIT_METERS, "Edit meters") \
X(STOP_DAEMON, "Stop daemon") \
X(START_DAEMON, "Start daemon") \
X(EXIT_ADMIN, "Exit")
enum class MainMenuType {
#define X(name,description) name,
LIST_OF_MAIN_MENU
#undef X
};
const char *main_menu[] = {
#define X(name,description) description,
LIST_OF_MAIN_MENU
#undef X
(char *)NULL,
};
#define LIST_OF_WMBUS_RECEIVERS \
X(AMB8465, "amb8465") \
X(CUL, "cul") \
X(IM871A, "im871a") \
X(RC1180, "rc1180") \
X(IU880B, "iu880b")
enum class ReceiversType {
#define X(name,description) name,
LIST_OF_WMBUS_RECEIVERS
#undef X
};
const char *receivers_menu[] = {
#define X(name,description) description,
LIST_OF_WMBUS_RECEIVERS
#undef X
(char *)NULL,
};
bool detectIfRoot();
string userName();
bool detectIfMemberOfGroup(string group);
void detectWMBUSReceiver();
void resetWMBUSReceiver();
void probeFor(string type, AccessCheck(*func)(Detected*,shared_ptr<SerialCommunicationManager>));
void stopDaemon();
void startDaemon();
shared_ptr<SerialCommunicationManager> handler;
WINDOW *status_window;
WINDOW *serial_ports_window;
WINDOW *processes_window;
void alwaysOnScreen();
int main(int argc, char **argv)
{
if (argc == 2 && (!strcmp(argv[1], "--debug") || !strcmp(argv[1], "--trace")))
{
if (!strcmp(argv[1], "--trace")) traceEnabled(true); else debugEnabled(true);
setlogmask(LOG_UPTO (LOG_INFO));
openlog("wmbusmeters-admin", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
enableSyslog();
}
// Handle exit on signals...
onExit(exitUI);
initUI();
clear();
/*
refresh();
int x=0;
int y=0;
for (int i=0;i<10; ++i) {
printAt(stdscr, y, x, "HEJSAN", COLOR_PAIR(BG_PAIR));
y++;
x++;
};
refresh();
for(;;) {}
endwin();
return 0;
*/
running_as_root_ = detectIfRoot();
member_of_dialout_ = detectIfMemberOfGroup("dialout");
handler = createSerialCommunicationManager(0, 0);
initUI();
bool running = true;
registerUpdateCB(alwaysOnScreen);
alwaysOnScreen();
do
{
int c = selectFromMenu("wmbusmeters admin", main_menu);
switch (static_cast<MainMenuType>(c))
{
case MainMenuType::DETECT_WMBUS_RECEIVERS:
detectWMBUSReceiver();
break;
case MainMenuType::RESET_WMBUS_RECEIVERS:
resetWMBUSReceiver();
break;
case MainMenuType::LISTEN_FOR_METERS:
notImplementedYet("Listen for meters");
break;
case MainMenuType::EDIT_CONFIG:
notImplementedYet("Edit config");
break;
case MainMenuType::EDIT_METERS:
notImplementedYet("Edit meters");
break;
case MainMenuType::STOP_DAEMON:
stopDaemon();
break;
case MainMenuType::START_DAEMON:
startDaemon();
break;
case MainMenuType::EXIT_ADMIN:
running = false;
break;
}
} while (running);
exitUI();
}
void alwaysOnScreen()
{
vector<string> info;
if (member_of_dialout_ == false)
{
info.push_back("Not member of dialout!");
}
vector<int> daemons;
detectProcesses("wmbusmetersd", &daemons);
if (daemons.size() == 0)
{
info.push_back("No daemons running.");
}
else
{
for (int i : daemons)
{
info.push_back("Daemon "+to_string(i));
}
}
vector<int> processes;
detectProcesses("wmbusmeters", &processes);
if (processes.size() == 0)
{
}
else
{
for (int i : processes)
{
info.push_back("Process "+to_string(i));
}
}
vector<string> status;
time_t now = time(NULL);
struct tm nowt {};
localtime_r(&now, &nowt);
status.push_back("wmbusmeters-admin");
status.push_back(strdatetimesec(&nowt));
string name = "["+userName()+"]";
status.push_back(name);
displayStatusLineNoWait(&status_window, status, 0, 0);
displayInformationNoWait(&status_window, "Problems", info, 2, 2);
vector<string> devices = handler->listSerialTTYs();
if (devices.size() == 0)
{
devices.push_back("No serial ports found!");
}
//info.insert(info.end(), devices.begin(), devices.end());
displayInformationNoWait(&serial_ports_window, "Serial ports", devices, 1, 15);
erase();
wrefresh(status_window);
wrefresh(serial_ports_window);
}
void detectWMBUSReceiver()
{
int c = selectFromMenu("Select your wmbus radio device", receivers_menu);
switch (static_cast<ReceiversType>(c))
{
/* case ReceiversType::AMB3665:
probeFor("amb3665", detectAMB3665);
break;*/
case ReceiversType::AMB8465:
probeFor("amb8465/amb3665", detectAMB8465AMB3665);
break;
case ReceiversType::CUL:
probeFor("cul", detectCUL);
break;
case ReceiversType::IM871A:
probeFor("im871a/im170a", detectIM871AIM170A);
break;
case ReceiversType::IU880B:
probeFor("iu880b", detectIU880B);
break;
case ReceiversType::RC1180:
probeFor("rc1180", detectRC1180);
break;
}
}
void resetWMBUSReceiver()
{
int c = selectFromMenu("Select your wmbus radio device", receivers_menu);
switch (static_cast<ReceiversType>(c))
{
/*
case ReceiversType::AMB3665:
{
vector<string> devices = handler->listSerialTTYs();
if (devices.size() == 0)
{
vector<string> entries;
displayInformationAndWait("No serial ports!", entries);
return;
}
int c = selectFromMenu("Select device", devices);
string device = devices[c];
int was_baud = 0;
AccessCheck ac = factoryResetAMB3665(device, handler, &was_baud);
if (ac == AccessCheck::AccessOK)
{
vector<string> entries;
entries.push_back("amb3665 "+device+" using "+to_string(was_baud));
displayInformationAndWait("Factory reset successful", entries);
}
else
{
vector<string> entries;
entries.push_back(device);
displayInformationAndWait("No amb3665 response from", entries);
}
break;
}*/
case ReceiversType::AMB8465:
{
vector<string> devices = handler->listSerialTTYs();
if (devices.size() == 0)
{
vector<string> entries;
displayInformationAndWait("No serial ports!", entries);
return;
}
int c = selectFromMenu("Select device", devices);
string device = devices[c];
int was_baud = 0;
AccessCheck ac = factoryResetAMB8465(device, handler, &was_baud);
if (ac == AccessCheck::AccessOK)
{
vector<string> entries;
entries.push_back("amb8465 "+device+" using "+to_string(was_baud));
displayInformationAndWait("Factory reset successful", entries);
}
else
{
vector<string> entries;
entries.push_back(device);
displayInformationAndWait("No amb8465 response from", entries);
}
break;
}
case ReceiversType::CUL:
notImplementedYet("Resetting cul");
break;
case ReceiversType::IM871A:
notImplementedYet("Resetting im871a");
break;
case ReceiversType::RC1180:
notImplementedYet("Resetting RC1180");
break;
case ReceiversType::IU880B:
notImplementedYet("Resetting IU880B");
break;
}
}
void probeFor(string type, AccessCheck (*probe)(Detected*,shared_ptr<SerialCommunicationManager>))
{
Detected detected {};
vector<string> devices = handler->listSerialTTYs();
vector<string> entries;
for (string& device : devices)
{
string tty = "?";
AccessCheck ac = handler->checkAccess(device,
handler,
type,
[&](string d, shared_ptr<SerialCommunicationManager> m){
detected.found_file=d;
detected.specified_device.file=d; return probe(&detected, m);});
if (ac == AccessCheck::AccessOK)
{
tty = device+" DETECTED "+type;
}
else if (ac == AccessCheck::NoSuchDevice)
{
tty = device+" no such device";
}
else if (ac == AccessCheck::NoProperResponse)
{
tty = device+" no response";
}
else if (ac == AccessCheck::NotSameGroup)
{
tty = device+" not same group";
}
else if (ac == AccessCheck::NoPermission)
{
tty = device+" same group but wrong permissions";
}
entries.push_back(tty);
}
if (entries.size() == 0)
{
entries.push_back("No serial devices found.");
}
displayInformationAndWait("Probed serial devices", entries);
}
bool detectIfRoot()
{
vector<string> args;
vector<string> envs;
args.push_back("-u");
string out;
invokeShellCaptureOutput("/usr/bin/id", args, envs, &out, true);
return out == "0\n";
}
string userName()
{
vector<string> args;
vector<string> envs;
args.push_back("-u");
args.push_back("-n");
string out;
invokeShellCaptureOutput("/usr/bin/id", args, envs, &out, true);
return out;
}
bool detectIfMemberOfGroup(string group)
{
vector<string> args;
vector<string> envs;
string out;
invokeShellCaptureOutput("/usr/bin/groups", args, envs, &out, true);
out = out+" "; // Guarantee that the line ends with space.
size_t p = out.find(group+" ");
if (p == 0) return true;
p = out.find(" "+group+" ");
if (p != string::npos) return true;
return false;
}
void stopDaemon()
{
vector<string> info;
info.push_back("Enter sudo password to execute:");
info.push_back("systemctl stop wmbusmeters");
debug("(passowrd) calling inputfield\n");
string pwd = inputField("Stop daemon", info, "Password");
debug("(passowrd) GOT %s\n", pwd.c_str());
//string pwd = displayInformationAndInput("Stop daemon", info, 1, 1);
//vector<string> args;
//vector<string> envs;
//args.push_back("gurka");
// string out;
// invokeShellCaptureOutput("systemctl stop wmbusmeters", args, envs, &out, true);
}
void startDaemon()
{
}
/*
static char* trim_whitespaces(char *str)
{
char *end;
// trim leading space
while(isspace(*str))
str++;
if(*str == 0) // all spaces?
return str;
// trim trailing space
end = str + strnlen(str, 128) - 1;
while(end > str && isspace(*end))
end--;
// write new null terminator
*(end+1) = '\0';
return str;
}
*/

Wyświetl plik

@ -2,12 +2,63 @@
if [ ! -d "$1" ] if [ ! -d "$1" ]
then then
echo Oups, please supply a valid root directory. echo Usage: uninstall.sh [root_dir] [--purge]
exit 1 exit 1
fi fi
ROOT="${1%/}" ROOT="${1%/}"
if [ "$2" = "--purge" ]
then
echo Removing config files.
if [ -f "$ROOT"/etc/wmbusmeters.conf ]
then
rm "$ROOT"/etc/wmbusmeters.conf
echo conf file: removed "$ROOT"/etc/wmbusmeters.conf
fi
if [ -d "$ROOT"/etc/wmbusmeters.d ]
then
rm -rf "$ROOT"/etc/wmbusmeters.d
echo conf dir: removed "$ROOT"/etc/wmbusmeters.d
fi
if [ -d "$ROOT"/var/log/wmbusmeters/ ]
then
rm -rf "$ROOT"/var/log/wmbusmeters/
echo log dir: removed "$ROOT"/var/log/wmbusmeters/
fi
ID=$(id -u wmbusmeters 2>/dev/null)
if [ ! "$ID" = "" ]
then
userdel wmbusmeters
echo "user: removed wmbusmeters"
fi
if [ $(getent group wmbusmeters) ]
then
groupdel wmbusmeters
echo "group: removed wmbusmeters"
fi
else
echo "The option --purge was not supplied."
echo "Not removing: $ROOT/etc/wmbusmeters.conf"
echo "Not removing: $ROOT/etc/wmbusmeters.d"
ID=$(id -u wmbusmeters 2>/dev/null)
if [ ! "$ID" = "" ]
then
echo "Not removing user: wmbusmeters"
fi
if [ $(getent group wmbusmeters) ]
then
echo "Not removing group: wmbusmeters"
fi
fi
if [ -x "$ROOT"/usr/bin/wmbusmeters ] || [ -x "$ROOT"/usr/sbin/wmbusmeters ] if [ -x "$ROOT"/usr/bin/wmbusmeters ] || [ -x "$ROOT"/usr/sbin/wmbusmeters ]
then then
rm -f "$ROOT"/usr/bin/wmbusmeters "$ROOT"/usr/sbin/wmbusmetersd rm -f "$ROOT"/usr/bin/wmbusmeters "$ROOT"/usr/sbin/wmbusmetersd
@ -20,46 +71,14 @@ then
echo man page: removed "$ROOT"/usr/share/man/man1/wmbusmeters.1.gz echo man page: removed "$ROOT"/usr/share/man/man1/wmbusmeters.1.gz
fi fi
ID=$(id -u wmbusmeters 2>/dev/null)
if [ ! "$ID" = "" ]
then
userdel wmbusmeters
echo user: removed wmbusmeters
fi
if [ -d "$ROOT"/var/log/wmbusmeters/ ]
then
rm -rf "$ROOT"/var/log/wmbusmeters/
echo log dir: removed "$ROOT"/var/log/wmbusmeters/
fi
if [ -f "$ROOT"/etc/logrotate.d/wmbusmeters ] if [ -f "$ROOT"/etc/logrotate.d/wmbusmeters ]
then then
rm "$ROOT"/etc/logrotate.d/wmbusmeters rm "$ROOT"/etc/logrotate.d/wmbusmeters
echo logrotate file: removed "$ROOT"/etc/logrotate.d/wmbusmeters echo logrotate file: removed "$ROOT"/etc/logrotate.d/wmbusmeters
fi fi
if [ -f "$ROOT"/etc/wmbusmeters.conf ]
then
rm "$ROOT"/etc/wmbusmeters.conf
echo conf file: removed "$ROOT"/etc/wmbusmeters.conf
fi
if [ -d "$ROOT"/etc/wmbusmeters.d ]
then
rm -rf "$ROOT"/etc/wmbusmeters.d
echo conf dir: removed "$ROOT"/etc/wmbusmeters.d
fi
if [ -f "$ROOT"/lib/systemd/system/wmbusmeters.service ] if [ -f "$ROOT"/lib/systemd/system/wmbusmeters.service ]
then then
rm "$ROOT"/lib/systemd/system/wmbusmeters.service rm "$ROOT"/lib/systemd/system/wmbusmeters.service
echo systemd: removed "$ROOT"/lib/systemd/system/wmbusmeters.service echo systemd: removed "$ROOT"/lib/systemd/system/wmbusmeters.service
fi fi
if [ -f "$ROOT"/etc/udev/rules.d/99-wmbus-usb-serial.rules ]
then
rm "$ROOT"/etc/udev/rules.d/99-wmbus-usb-serial.rules
echo udev: removed "$ROOT"/etc/udev/rules.d/99-wmbus-usb-serial.rules
fi

Wyświetl plik

@ -1,29 +0,0 @@
.TH WMBUSMETERS 1
.SH NAME
wmbusmeters-admin \- Interactively configure devices and meters for wireless mbus and wired mbus.
.SH SYNOPSIS
.B wmbusmeters-admin {options}
.SH DESCRIPTION
Wmbusmeters-admin is used to configure and test wmbus devices.
.SH OPTIONS
\fB\--debug\fR for a lot of information
\fB\--verbose\fR for more information
\fB\--version\fR print version
.SH AUTHOR
Written by Fredrik Öhrström.
.SH COPYRIGHT
Copyright \(co 2017-2022 Fredrik Öhrström.
.br
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
.br
This is free software: you are free to change and redistribute it.
.br
There is NO WARRANTY, to the extent permitted by law.