merge openwebrx-admin into openwebrx

This commit is contained in:
Jakob Ketterl 2021-04-24 19:39:48 +02:00
parent 6ad3a80fc6
commit 71b0fa968b
11 changed files with 43 additions and 32 deletions

View File

@ -6,7 +6,7 @@
- Added support for demodulating M17 digital voice signals using m17-cxx-demod - Added support for demodulating M17 digital voice signals using m17-cxx-demod
- New reporting infrastructure, allowing WSPR and FST4W spots to be sent to wsprnet.org - New reporting infrastructure, allowing WSPR and FST4W spots to be sent to wsprnet.org
- Add some basic filtering capabilities to the map - Add some basic filtering capabilities to the map
- New command-line tool `openwebrx-admin` that facilitates the administration of users - New arguments to the `openwebrx` command-line to facilitate the administration of users (try `openwebrx admin`)
- Default bandwidth changes: - Default bandwidth changes:
- "WFM" changed to 150kHz - "WFM" changed to 150kHz
- "Packet" (APRS) changed to 12.5kHz - "Packet" (APRS) changed to 12.5kHz

2
debian/changelog vendored
View File

@ -10,6 +10,8 @@ openwebrx (0.21.0) UNRELEASED; urgency=low
* New reporting infrastructure, allowing WSPR and FST4W spots to be sent to * New reporting infrastructure, allowing WSPR and FST4W spots to be sent to
wsprnet.org wsprnet.org
* Add some basic filtering capabilities to the map * Add some basic filtering capabilities to the map
* New arguments to the `openwebrx` command-line to facilitate the
administration of users (try `openwebrx admin`)
* New command-line tool `openwebrx-admin` that facilitates the * New command-line tool `openwebrx-admin` that facilitates the
administration of users administration of users
* Default bandwidth changes: * Default bandwidth changes:

View File

@ -1,7 +1,8 @@
#!/bin/sh -e #!/bin/sh -e
. /usr/share/debconf/confmodule . /usr/share/debconf/confmodule
if ! openwebrx-admin --silent hasuser admin; then db_get openwebrx/admin_user_configured
if [ "${RET}" != true ]; then
db_input high openwebrx/admin_user_password || true db_input high openwebrx/admin_user_password || true
db_go db_go
fi fi

View File

@ -26,10 +26,12 @@ case "$1" in
db_get openwebrx/admin_user_password db_get openwebrx/admin_user_password
if [ ! -z "${RET}" ]; then if [ ! -z "${RET}" ]; then
# create initial openwebrx user # create initial openwebrx user
OWRX_PASSWORD="${RET}" openwebrx-admin --noninteractive adduser admin OWRX_PASSWORD="${RET}" openwebrx admin --noninteractive adduser admin
fi fi
# remove password from debconf database # remove password from debconf database
db_unregister openwebrx/admin_user_password db_unregister openwebrx/admin_user_password
# set a marker that admin is configured to avoid future questions
db_set openwebrx/admin_user_configured true
;; ;;
*) *)
echo "postinst called with unknown argument '$1'" 1>&2 echo "postinst called with unknown argument '$1'" 1>&2

View File

@ -11,6 +11,6 @@ Description: OpenWebRX "admin" user password:
empty for now. You can return to this prompt at a later time by running the empty for now. You can return to this prompt at a later time by running the
command "sudo dpkg-reconfigure openwebrx". command "sudo dpkg-reconfigure openwebrx".
. .
You can also use the "openwebrx-admin" command to create, delete or manage You can also use the "openwebrx admin" command to create, delete or manage
existing users. More information is available in by running the command existing users. More information is available in by running the command
"openwebrx-admin --help". "openwebrx admin --help".

View File

@ -17,8 +17,8 @@ if [[ ! -f /etc/openwebrx/openwebrx.conf ]] ; then
cp openwebrx.conf /etc/openwebrx/ cp openwebrx.conf /etc/openwebrx/
fi fi
if [[ ! -z "${OPENWEBRX_ADMIN_USER:-}" ]] && [[ ! -z "${OPENWEBRX_ADMIN_PASSWORD:-}" ]] ; then if [[ ! -z "${OPENWEBRX_ADMIN_USER:-}" ]] && [[ ! -z "${OPENWEBRX_ADMIN_PASSWORD:-}" ]] ; then
if ! python3 openwebrx-admin.py --silent hasuser "${OPENWEBRX_ADMIN_USER}" ; then if ! python3 openwebrx.py admin --silent hasuser "${OPENWEBRX_ADMIN_USER}" ; then
OWRX_PASSWORD="${OPENWEBRX_ADMIN_PASSWORD}" python3 openwebrx-admin.py --noninteractive adduser "${OPENWEBRX_ADMIN_USER}" OWRX_PASSWORD="${OPENWEBRX_ADMIN_PASSWORD}" python3 openwebrx.py admin --noninteractive adduser "${OPENWEBRX_ADMIN_USER}"
fi fi
fi fi

View File

@ -1,6 +0,0 @@
#!/usr/bin/env python3
from owrxadmin.__main__ import main
if __name__ == "__main__":
main()

View File

@ -10,7 +10,9 @@ from owrx.websocket import WebSocketConnection
from owrx.reporting import ReportingEngine from owrx.reporting import ReportingEngine
from owrx.version import openwebrx_version from owrx.version import openwebrx_version
from owrx.audio.queue import DecoderQueue from owrx.audio.queue import DecoderQueue
from owrx.admin import add_admin_parser, run_admin_action
import signal import signal
import argparse
import logging import logging
@ -31,6 +33,26 @@ def handleSignal(sig, frame):
def main(): def main():
parser = argparse.ArgumentParser(description="OpenWebRX - Open Source SDR Web App for Everyone!")
parser.add_argument("-v", "--version", action="store_true", help="Show the software version")
moduleparser = parser.add_subparsers(title="Modules", dest="module")
adminparser = moduleparser.add_parser("admin", help="OpenWebRX admin actions")
add_admin_parser(adminparser)
args = parser.parse_args()
if args.version:
print("OpenWebRX version {version}".format(version=openwebrx_version))
elif args.module == "admin":
# override loglevel for admin commands, they shouldn't be that verbose
logging.basicConfig(level=logging.INFO, force=True)
run_admin_action(adminparser, args)
else:
start_receiver()
def start_receiver():
print( print(
""" """

View File

@ -1,16 +1,10 @@
from owrx.version import openwebrx_version from owrx.admin.commands import NewUser, DeleteUser, ResetPassword, ListUsers, DisableUser, EnableUser, HasUser
from owrxadmin.commands import NewUser, DeleteUser, ResetPassword, ListUsers, DisableUser, EnableUser, HasUser
import argparse
import sys import sys
import traceback import traceback
import logging
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
def main(): def add_admin_parser(moduleparser):
parser = argparse.ArgumentParser() subparsers = moduleparser.add_subparsers(title="Commands", dest="command")
subparsers = parser.add_subparsers(title="Commands", dest="command")
adduser_parser = subparsers.add_parser("adduser", help="Add a new user") adduser_parser = subparsers.add_parser("adduser", help="Add a new user")
adduser_parser.add_argument("user", help="Username to be added") adduser_parser.add_argument("user", help="Username to be added")
@ -40,17 +34,12 @@ def main():
hasuser_parser.add_argument("user", help="Username to be checked") hasuser_parser.add_argument("user", help="Username to be checked")
hasuser_parser.set_defaults(cls=HasUser) hasuser_parser.set_defaults(cls=HasUser)
parser.add_argument("-v", "--version", action="store_true", help="Show the software version") moduleparser.add_argument(
parser.add_argument(
"--noninteractive", action="store_true", help="Don't ask for any user input (useful for automation)" "--noninteractive", action="store_true", help="Don't ask for any user input (useful for automation)"
) )
parser.add_argument("--silent", action="store_true", help="Ignore errors (useful for automation)") moduleparser.add_argument("--silent", action="store_true", help="Ignore errors (useful for automation)")
args = parser.parse_args()
if args.version:
print("OpenWebRX Admin CLI version {version}".format(version=openwebrx_version))
sys.exit(0)
def run_admin_action(parser, args):
if hasattr(args, "cls"): if hasattr(args, "cls"):
command = args.cls() command = args.cls()
else: else:
@ -67,3 +56,4 @@ def main():
traceback.print_exc() traceback.print_exc()
sys.exit(1) sys.exit(1)
sys.exit(0) sys.exit(0)

View File

@ -24,13 +24,13 @@ setup(
"owrx.config", "owrx.config",
"owrx.reporting", "owrx.reporting",
"owrx.audio", "owrx.audio",
"owrx.admin",
"csdr", "csdr",
"htdocs", "htdocs",
"owrxadmin",
] ]
), ),
package_data={"htdocs": [f[len("htdocs/") :] for f in glob("htdocs/**/*", recursive=True)]}, package_data={"htdocs": [f[len("htdocs/") :] for f in glob("htdocs/**/*", recursive=True)]},
entry_points={"console_scripts": ["openwebrx=owrx.__main__:main", "openwebrx-admin=owrxadmin.__main__:main"]}, entry_points={"console_scripts": ["openwebrx=owrx.__main__:main"]},
url="https://www.openwebrx.de/", url="https://www.openwebrx.de/",
author="Jakob Ketterl", author="Jakob Ketterl",
author_email="jakob.ketterl@gmx.de", author_email="jakob.ketterl@gmx.de",