diff --git a/service/log/run b/service/log/run index 0655b24..4a004c4 100644 --- a/service/log/run +++ b/service/log/run @@ -1,4 +1,8 @@ #!/bin/sh exec 2>&1 +#Script Directory +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +SCRIPT_DIR=$(realpath $SCRIPT_DIR/../../) +SERVICE_NAME=$(basename $SCRIPT_DIR) # documentation on how to use multilog https://manpages.debian.org/stretch/daemontools/multilog.8.en.html -exec multilog t s153600 n2 /var/log/dbus-opendtu \ No newline at end of file +exec multilog t s153600 n2 /var/log/${SERVICE_NAME} \ No newline at end of file diff --git a/uninstall.sh b/uninstall.sh index 075e5be..465aa16 100644 --- a/uninstall.sh +++ b/uninstall.sh @@ -1,10 +1,13 @@ #!/bin/bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) SERVICE_NAME=$(basename $SCRIPT_DIR) +LOG_DIR=/var/log/$SERVICE_NAME RC_LOCAL_FILE=/data/rc.local #remove the service -rm /service/$SERVICE_NAME +if [ -f /service/$SERVICE_NAME ]; then + rm /service/$SERVICE_NAME +fi # end the dbus-opendtu process kill $(pgrep -f "python $SCRIPT_DIR/dbus-opendtu.py") @@ -16,4 +19,16 @@ fi # remove install.sh from rc.local STARTUP=$SCRIPT_DIR/install.sh -sed -i "\~$STARTUP~d" $RC_LOCAL_FILE \ No newline at end of file +sed -i "\~$STARTUP~d" $RC_LOCAL_FILE + +# delete log folder in var log if they exist +if [ -d $LOG_DIR ]; then + while true; do + read -p "Do you really wish to delete the log folder $LOG_DIR? [y/n]" yn + case $yn in + [Yy]* ) rm -rf $LOG_DIR; echo $LOG_DIR is deleted ; break;; + [Nn]* ) exit;; + * ) echo "Please answer yes or no.";; + esac + done +fi \ No newline at end of file