Permalink
Browse files

Weekly rotate domoticz logs

  • Loading branch information...
1 parent 9817a5e commit 305c48163be1ce65f000288d3d50e5104a2e58b4 @sbouchex sbouchex committed Oct 24, 2016
Showing with 32 additions and 0 deletions.
  1. +18 −0 domoticz.sh
  2. +14 −0 scripts/logrotate/domoticz
View
@@ -37,6 +37,17 @@ DAEMON_ARGS="$DAEMON_ARGS -sslwww 443"
# and status_of_proc is working.
. /lib/lsb/init-functions
+pidof_domoticz() {
+ # if there is actually a domoticz process whose pid is in PIDFILE,
+ # print it and return 0.
+ if [ -e "$PIDFILE" ]; then
+ if pidof domoticz | tr ' ' '\n' | grep -w $(cat $PIDFILE); then
+ return 0
+ fi
+ fi
+ return 1
+}
+
#
# Function that starts the daemon/service
#
@@ -99,6 +110,13 @@ case "$1" in
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
+ reload)
+ log_daemon_msg "Reloading $DESC" "$NAME"
+ PID=$(pidof_domoticz) || true
+ if [ "${PID}" ]; then
+ kill -HUP $PID
+ fi
+ ;;
restart)
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
@@ -0,0 +1,14 @@
+/var/log/domoticz.log {
+ missingok
+ weekly
+ rotate 7
+ compress
+ notifempty
+ postrotate
+ if [ -x /usr/sbin/invoke-rc.d ]; then \
+ invoke-rc.d domoticz reload > /dev/null; \
+ else \
+ /etc/init.d/domoticz reload > /dev/null; \
+ fi
+ endscript
+}

0 comments on commit 305c481

Please sign in to comment.