Ansible adaptions

This commit is contained in:
Dirk Alders 2023-11-04 08:30:25 +01:00
parent 5140a7c51f
commit 8d9508f4fb
6 changed files with 17 additions and 50 deletions

View File

@ -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 <UID> <GID> <TARGET_PATH>")
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()

View File

@ -3,10 +3,10 @@
import os
import report
MQTT_USER = "user"
MQTT_PASS = "pass"
MQTT_SERVER = "localhost"
MQTT_TOPIC = "hifi/mpd"
MQTT_SERVER = "<mqtt_smarthome_hostname>"
MQTT_USER = "<mqtt_smarthome_username>"
MQTT_PASS = "<mqtt_smarthome_password>"
MQTT_TOPIC = "<mqtt_mpd_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

8
init_venv Executable file
View File

@ -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

View File

@ -1,4 +0,0 @@
#!/bin/sh
#
BASEPATH=`dirname $0`
$BASEPATH/venv/bin/python $BASEPATH/mpd_monitor.py

4
smart_mpd.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
#
BASEPATH=`dirname $0`
$BASEPATH/venv/bin/python $BASEPATH/smart_mpd.py