Skip to content

Commit

Permalink
use service name for /var/log folder
Browse files Browse the repository at this point in the history
  • Loading branch information
henne49 committed Aug 1, 2024
1 parent 4c25f28 commit 8f74a64
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
6 changes: 5 additions & 1 deletion service/log/run
Original file line number Diff line number Diff line change
@@ -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
exec multilog t s153600 n2 /var/log/${SERVICE_NAME}
19 changes: 17 additions & 2 deletions uninstall.sh
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -16,4 +19,16 @@ fi

# remove install.sh from rc.local
STARTUP=$SCRIPT_DIR/install.sh
sed -i "\~$STARTUP~d" $RC_LOCAL_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

0 comments on commit 8f74a64

Please sign in to comment.