Relocate files, add update in script
This commit is contained in:
@@ -5,6 +5,7 @@ if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: $0 [--install|--uninstall|--help]"
|
||||
echo " --install Install the poo recorder"
|
||||
echo " --uninstall Uninstall the poo recorder"
|
||||
echo " --update Update the installation"
|
||||
echo " --help Show this help message"
|
||||
exit 0
|
||||
fi
|
||||
@@ -17,6 +18,9 @@ case $key in
|
||||
--uninstall)
|
||||
UNINSTALL=true
|
||||
;;
|
||||
--update)
|
||||
UPDATE=true
|
||||
;;
|
||||
--help)
|
||||
echo "Usage: $0 [--install|--uninstall|--help]"
|
||||
echo " --install Install the poo recorder"
|
||||
@@ -45,7 +49,8 @@ install_poo_recorder() {
|
||||
|
||||
mkdir -p $TARGET_DIR
|
||||
|
||||
cp $BASEDIR/../main.py $BASEDIR/../poo.py $BASEDIR/../requirements.txt $TARGET_DIR
|
||||
rm -rf $BASEDIR/../recorder/__pycache__
|
||||
cp -r $BASEDIR/../recorder $BASEDIR/../requirements.txt $TARGET_DIR
|
||||
|
||||
python3 -m venv "$TARGET_DIR/venv"
|
||||
|
||||
@@ -53,10 +58,10 @@ install_poo_recorder() {
|
||||
|
||||
cp $BASEDIR/poo_recorder_template.conf $BASEDIR/poo_recorder.conf
|
||||
|
||||
sed -i "s+command=+command=$TARGET_DIR/venv/bin/fastapi run $TARGET_DIR/main.py --port 8881+g" poo_recorder.conf
|
||||
sed -i "s+directory=+directory=$TARGET_DIR+g" poo_recorder.conf
|
||||
sed -i "s+user=+user=$USER+g" poo_recorder.conf
|
||||
sed -i "s+group=+group=$USER+g" poo_recorder.conf
|
||||
sed -i "s+command=+command=$TARGET_DIR/venv/bin/fastapi run $TARGET_DIR/recorder/main.py --port 8881+g" $BASEDIR/poo_recorder.conf
|
||||
sed -i "s+directory=+directory=$TARGET_DIR+g" $BASEDIR/poo_recorder.conf
|
||||
sed -i "s+user=+user=$USER+g" $BASEDIR/poo_recorder.conf
|
||||
sed -i "s+group=+group=$USER+g" $BASEDIR/poo_recorder.conf
|
||||
|
||||
sudo mv $BASEDIR/poo_recorder.conf /etc/supervisor/conf.d/poo_recorder.conf
|
||||
|
||||
@@ -80,11 +85,17 @@ uninstall_poo_recorder() {
|
||||
|
||||
echo "Uninstallation complete."
|
||||
}
|
||||
update_poo_recorder() {
|
||||
uninstall_poo_recorder
|
||||
install_poo_recorder
|
||||
}
|
||||
|
||||
if [[ $INSTALL ]]; then
|
||||
install_poo_recorder
|
||||
elif [[ $UNINSTALL ]]; then
|
||||
uninstall_poo_recorder
|
||||
elif [[ $UPDATE ]]; then
|
||||
update_poo_recorder
|
||||
else
|
||||
echo "Invalid argument: $key"
|
||||
exit 1
|
||||
|
||||
0
recorder/__init__.py
Normal file
0
recorder/__init__.py
Normal file
@@ -2,7 +2,7 @@ from contextlib import asynccontextmanager
|
||||
|
||||
from fastapi import FastAPI
|
||||
|
||||
from poo import PooRecorder
|
||||
from recorder.poo import PooRecorder
|
||||
|
||||
recorder = PooRecorder()
|
||||
|
||||
@@ -5,7 +5,7 @@ from fastapi_mqtt import FastMQTT, MQTTConfig
|
||||
|
||||
class PooRecorder:
|
||||
mqtt_config = MQTTConfig(username="mqtt", password="mqtt", reconnect_retries=-1) # noqa: S106
|
||||
mqtt = FastMQTT(config=mqtt_config)
|
||||
mqtt = FastMQTT(config=mqtt_config, client_id="poo_recorder")
|
||||
CONFIG_TOPIC = "homeassistant/text/poo_recorder/config"
|
||||
AVAILABILITY_TOPIC = "studiotj/poo_recorder/status"
|
||||
COMMAND_TOPIC = "studiotj/poo_recorder/update_text"
|
||||
Reference in New Issue
Block a user