From 8d9508f4fb29a9baa1e0cd032cf2b7eda2ad48e8 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Sat, 4 Nov 2023 08:30:25 +0100 Subject: [PATCH] Ansible adaptions --- __install__.py | 41 ---------------------------------- config_example/config.py | 10 ++++----- init_venv | 8 +++++++ mpd_monitor.sh | 4 ---- mpd_monitor.py => smart_mpd.py | 0 smart_mpd.sh | 4 ++++ 6 files changed, 17 insertions(+), 50 deletions(-) delete mode 100644 __install__.py create mode 100755 init_venv delete mode 100755 mpd_monitor.sh rename mpd_monitor.py => smart_mpd.py (100%) create mode 100755 smart_mpd.sh diff --git a/__install__.py b/__install__.py deleted file mode 100644 index 3d0264e..0000000 --- a/__install__.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/python -# -import os -import sys - -SERVICE_FILE = """ -[Unit] -Description=MPD Monitor Service -After=network-online.target -Wants=network-online.target -[Service] -User=%(UID)d -Group=%(GID)d -ExecStart=%(MY_PATH)s/mpd_monitor.sh -Type=simple -[Install] -WantedBy=default.target -""" - - -def help(): - print("Usage: prog ") - -if __name__ == "__main__": - if len(sys.argv) == 4: - try: - uid = int(sys.argv[1]) - gid = int(sys.argv[2]) - except ValueError: - help() - else: - if os.path.isdir(sys.argv[3]): - with open(os.path.join(sys.argv[3], 'mpd_monitor.service'), "w") as fh: - fh.write(SERVICE_FILE % { - "MY_PATH": os.path.dirname(os.path.abspath(__file__)), - "UID": uid, - "GID": gid}) - else: - help() - else: - help() diff --git a/config_example/config.py b/config_example/config.py index 83da682..d4d1194 100644 --- a/config_example/config.py +++ b/config_example/config.py @@ -3,10 +3,10 @@ import os import report -MQTT_USER = "user" -MQTT_PASS = "pass" -MQTT_SERVER = "localhost" -MQTT_TOPIC = "hifi/mpd" +MQTT_SERVER = "" +MQTT_USER = "" +MQTT_PASS = "" +MQTT_TOPIC = "" # # Logging @@ -14,7 +14,7 @@ MQTT_TOPIC = "hifi/mpd" __BASEPATH__ = os.path.abspath(os.path.dirname(__file__)) APP_NAME = "mpd" LOGTARGET = 'stdout' # possible choices are: 'logfile' or 'stdout' -LOGLVL = 'DEBUG' +LOGLVL = 'INFO' LOGHOST = 'cutelog' LOGPORT = 19996 diff --git a/init_venv b/init_venv new file mode 100755 index 0000000..428ff04 --- /dev/null +++ b/init_venv @@ -0,0 +1,8 @@ +#!/bin/sh +# +BASEPATH=`realpath $(dirname $0)` + +python3 -m venv $BASEPATH/venv +$BASEPATH/venv/bin/pip install --upgrade pip +find $BASEPATH -name requirements.txt | xargs -L 1 $BASEPATH/venv/bin/pip install -r +$BASEPATH/venv/bin/pip list --outdated --format=json | jq -r '.[] | .name'|xargs -n1 $BASEPATH/venv/bin/pip install -U diff --git a/mpd_monitor.sh b/mpd_monitor.sh deleted file mode 100755 index 6157e15..0000000 --- a/mpd_monitor.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# -BASEPATH=`dirname $0` -$BASEPATH/venv/bin/python $BASEPATH/mpd_monitor.py \ No newline at end of file diff --git a/mpd_monitor.py b/smart_mpd.py similarity index 100% rename from mpd_monitor.py rename to smart_mpd.py diff --git a/smart_mpd.sh b/smart_mpd.sh new file mode 100755 index 0000000..38cc2fc --- /dev/null +++ b/smart_mpd.sh @@ -0,0 +1,4 @@ +#!/bin/sh +# +BASEPATH=`dirname $0` +$BASEPATH/venv/bin/python $BASEPATH/smart_mpd.py