Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement on shell script log per service & uninstall #210

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: ["main"]
pull_request:
branches: ["main"]
fork:
henne49 marked this conversation as resolved.
Show resolved Hide resolved
schedule:
- cron: "19 16 * * 2"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Pylint

on: [push]
on: [push, fork]

jobs:
build:
Expand Down
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 [ -d /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
henne49 marked this conversation as resolved.
Show resolved Hide resolved
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]* ) break;;
* ) echo "Please answer y or n.";;
esac
done
fi
Loading