From 453ec4294f1548a40e71a2d4a42c5860a01a0a24 Mon Sep 17 00:00:00 2001 From: Wouter R Date: Wed, 16 Mar 2016 22:33:38 +0100 Subject: [PATCH] Log rotation: - install logrotate wifibox.conf file, - create directories required for log rotation on boot. --- Makefile | 3 +++ src/script/logrotate-wifibox.conf | 13 +++++++++++++ src/script/wifibox_init | 6 ++++-- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 src/script/logrotate-wifibox.conf diff --git a/Makefile b/Makefile index e0361dc..abb567e 100644 --- a/Makefile +++ b/Makefile @@ -70,6 +70,7 @@ endef # sysupgrade to determine which files to keep (see `opkg list-changed-conffiles`). define Package/wifibox/conffiles /etc/config/wifibox +/etc/logrotate.d/wifibox.conf endef # The $(1) variable represents the root directory on the router running @@ -94,6 +95,7 @@ define Package/wifibox/install #$(INSTALL_DIR) $(1)/etc $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DIR) $(1)/etc/logrotate.d $(INSTALL_DIR) $(1)/root/ $(INSTALL_DIR) $(1)/root/sketches #$(INSTALL_DIR) $(1)/www @@ -117,6 +119,7 @@ define Package/wifibox/install $(INSTALL_BIN) $(WIFIBOX_BASE_DIR)/script/dhcpcheck_init $(1)/etc/init.d/dhcpcheck $(INSTALL_BIN) $(WIFIBOX_BASE_DIR)/script/d3dapi $(1)/$(TGT_LUA_DIR_SUFFIX)/script $(INSTALL_BIN) $(WIFIBOX_BASE_DIR)/script/signin.sh $(1)/$(TGT_LUA_DIR_SUFFIX)/script + $(CP) $(WIFIBOX_BASE_DIR)/script/logrotate-wifibox.conf $(1)/etc/logrotate.d/wifibox.conf $(CP) $(WIFIBOX_BASE_DIR)/script/wifibox.uci.config $(1)/etc/config/wifibox # copy base configuration to uci config dir $(CP) $(WIFIBOX_BASE_DIR)/FIRMWARE-VERSION $(1)/etc/wifibox-version diff --git a/src/script/logrotate-wifibox.conf b/src/script/logrotate-wifibox.conf new file mode 100644 index 0000000..edc6176 --- /dev/null +++ b/src/script/logrotate-wifibox.conf @@ -0,0 +1,13 @@ +# Doodle3D logrotate configuration + +compress +su +create + +/tmp/wifibox.log /tmp/print3d-*.log { + rotate 2 + size 1000k + missingok + olddir /tmp/wifibox-rotated + copytruncate +} diff --git a/src/script/wifibox_init b/src/script/wifibox_init index 903ad60..4123d1f 100644 --- a/src/script/wifibox_init +++ b/src/script/wifibox_init @@ -17,9 +17,11 @@ boot() { $LOGGER "Invoking Doodle3D WiFi box network auto-initialization..." /usr/share/lua/wifibox/script/d3dapi autowifi - $LOGGER "Start signing in..." - /usr/share/lua/wifibox/script/signin.sh > /dev/null 2> /dev/null & + $LOGGER "Start signing in..." + /usr/share/lua/wifibox/script/signin.sh > /dev/null 2> /dev/null & + mkdir -p /var/lib # required by logrotate for logrotate.status + mkdir -p /tmp/wifibox-rotated # this is where rotated wifibox logs are placed } start() {