Relocate files, add update in script

This commit is contained in:
2024-07-23 14:06:40 +02:00
parent 0761ef349d
commit b90d519fcb
4 changed files with 18 additions and 7 deletions

View File

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