summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xMakefile14
-rw-r--r--config.cpp2
-rw-r--r--debian/README.Debian7
-rw-r--r--debian/control2
-rwxr-xr-xdebian/rules6
-rw-r--r--debian/whiteboard.conf3
-rw-r--r--debian/whiteboard.dirs (renamed from debian/dirs)0
-rw-r--r--debian/whiteboard.install1
-rw-r--r--debian/whiteboard.whiteboard-cleanup.service10
-rw-r--r--debian/whiteboard.whiteboard-cleanup.timer10
-rw-r--r--debian/whiteboard.whiteboard.service (renamed from debian/whiteboard.service)0
-rwxr-xr-xwhiteboard-cleanup24
-rw-r--r--whiteboard.conf13
-rw-r--r--whiteboard.cron2
14 files changed, 84 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 640a081..a387f1c 100755
--- a/Makefile
+++ b/Makefile
@@ -67,14 +67,22 @@ all: build
install:
mkdir -p $(DESTDIR)/usr/lib/whiteboard
cp whiteboard.fcgi $(DESTDIR)/usr/lib/whiteboard/
-
+
mkdir -p $(DESTDIR)/usr/lib/whiteboard/html
cp -r html/* $(DESTDIR)/usr/lib/whiteboard/html/
-
+
uglifyjs html/whiteboard.js -m -c > $(DESTDIR)/usr/lib/whiteboard/html/whiteboard.js
htmlmin html/index.html $(DESTDIR)/usr/lib/whiteboard/html/index.html
cleancss -o $(DESTDIR)/usr/lib/whiteboard/html/whiteboard.css html/whiteboard.css
-
+
+ mkdir -p $(DESTDIR)/etc
+ cp whiteboard.conf $(DESTDIR)/etc
+
+ mkdir -p $(DESTDIR)/usr/bin
+ cp whiteboard-cleanup $(DESTDIR)/usr/bin/
+
+ mkdir -p $(DESTDIR)/etc/cron.d
+ cp whiteboard.cron $(DESTDIR)/etc/cron.d/whiteboard
whiteboard.fcgi: $(OBJECTS)
diff --git a/config.cpp b/config.cpp
index 6e2e2b6..e3ef68f 100644
--- a/config.cpp
+++ b/config.cpp
@@ -20,7 +20,7 @@ Config::Config(): m_dataPath{default_datapath}
pt::read_xml(config_filename, tree, pt::xml_parser::no_comments | pt::xml_parser::trim_whitespace);
- m_dataPath = tree.get<std::string>("whiteboard.datapath", default_datapath);
+ m_dataPath = tree.get<std::string>("config.datapath", default_datapath);
} catch (const std::exception& ex) {
std::cerr << "Error reading config file " << config_filename << ". Using " << default_datapath << "." << std::endl;
}
diff --git a/debian/README.Debian b/debian/README.Debian
index f3f2434..07ab4d6 100644
--- a/debian/README.Debian
+++ b/debian/README.Debian
@@ -3,6 +3,10 @@ whiteboard for Debian
This package is the Debian version of whiteboard.
+It is an FCGI application communicating to a webserver, e.g. Reichwein.IT webserver.
+
+Via cron or systemd, whiteboard data in /var/lib/whiteboard is cleaned up once a day.
+Data location and maximum data age can be configured via /etc/whiteboard.conf.
Configuration
-------------
@@ -18,6 +22,9 @@ Configuration
<target>127.0.0.1:9014</target>
</path>
+* Edit /etc/whiteboard.conf to adjust the whiteboard data path if different
+ from /var/lib/whiteboard
+
* Enable:
# systemctl enable whiteboard.service
diff --git a/debian/control b/debian/control
index dc159fa..62b6e4c 100644
--- a/debian/control
+++ b/debian/control
@@ -8,7 +8,7 @@ Homepage: http://www.reichwein.it/whiteboard/
Package: whiteboard
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, spawn-fcgi
+Depends: ${shlibs:Depends}, ${misc:Depends}, spawn-fcgi, libxml2-utils
Recommends: webserver
Homepage: http://www.reichwein.it/whiteboard/
Description: Web application for an collaborative editor
diff --git a/debian/rules b/debian/rules
index 9f52133..2ee2604 100755
--- a/debian/rules
+++ b/debian/rules
@@ -6,3 +6,9 @@
override_dh_fixperms:
dh_fixperms
chmod a+rwx debian/whiteboard/var/lib/whiteboard
+
+
+override_dh_auto_install:
+ dh_auto_install
+ dh_installsystemd --name whiteboard
+ dh_installsystemd --name whiteboard-cleanup
diff --git a/debian/whiteboard.conf b/debian/whiteboard.conf
deleted file mode 100644
index 91a868a..0000000
--- a/debian/whiteboard.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-<whiteboard>
- <datapath>/var/lib/whiteboard</datapath>
-<whiteboard>
diff --git a/debian/dirs b/debian/whiteboard.dirs
index 7b03c85..7b03c85 100644
--- a/debian/dirs
+++ b/debian/whiteboard.dirs
diff --git a/debian/whiteboard.install b/debian/whiteboard.install
deleted file mode 100644
index fa446b2..0000000
--- a/debian/whiteboard.install
+++ /dev/null
@@ -1 +0,0 @@
-debian/whiteboard.conf etc
diff --git a/debian/whiteboard.whiteboard-cleanup.service b/debian/whiteboard.whiteboard-cleanup.service
new file mode 100644
index 0000000..339c143
--- /dev/null
+++ b/debian/whiteboard.whiteboard-cleanup.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Cleanup whiteboard data
+Wants=whiteboard-cleanup.timer
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/whiteboard-cleanup
+
+[Install]
+WantedBy=multi-user.target
diff --git a/debian/whiteboard.whiteboard-cleanup.timer b/debian/whiteboard.whiteboard-cleanup.timer
new file mode 100644
index 0000000..e2c93f9
--- /dev/null
+++ b/debian/whiteboard.whiteboard-cleanup.timer
@@ -0,0 +1,10 @@
+[Unit]
+Description=Clean up whiteboard data
+Requires=whiteboard-cleanup.service
+
+[Timer]
+Unit=whiteboard-cleanup.service
+OnCalendar=*-*-* 00:00:00
+
+[Install]
+WantedBy=timers.target
diff --git a/debian/whiteboard.service b/debian/whiteboard.whiteboard.service
index c60f3f0..c60f3f0 100644
--- a/debian/whiteboard.service
+++ b/debian/whiteboard.whiteboard.service
diff --git a/whiteboard-cleanup b/whiteboard-cleanup
new file mode 100755
index 0000000..7a987e0
--- /dev/null
+++ b/whiteboard-cleanup
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# Cleanup global whiteboard files
+#
+# To be called by cron
+#
+
+set -e
+
+# look up config file
+CONFIGFILE=/etc/whiteboard.conf
+XMLLINTOPTS="--nonet --nocdata --nocatalogs"
+DATAPATH=`xmllint --xpath "/config/datapath/text()" $XMLLINTOPTS $CONFIGFILE`
+MAXAGE=`xmllint --xpath "/config/maxage/text()" $XMLLINTOPTS $CONFIGFILE`
+
+cd $DATAPATH
+
+ls -1 | while read i ; do
+ AGE=$((`date +"%s"` - `stat -c "%Y" $i`))
+ if [[ "$AGE" -gt "$MAXAGE" ]] ; then
+ echo "Deleting entry $i ..."
+ rm $i
+ fi
+done
diff --git a/whiteboard.conf b/whiteboard.conf
index d269e46..80ae173 100644
--- a/whiteboard.conf
+++ b/whiteboard.conf
@@ -1,3 +1,14 @@
<config>
- <datapath>/home/ernie/code/whiteboard/data</datapath>
+ <!--
+ datapath: location in filesystem to store whiteboard data
+ Example: /var/lib/whiteboard
+ -->
+ <datapath>/var/lib/whiteboard</datapath>
+
+ <!--
+ Maximum age of individual whiteboard pages in seconds.
+ Older pages will be removed by whiteboard-cleanup and crond.
+ Example: 2592000 (~30 days)
+ -->
+ <maxage>2592000</maxage>
</config>
diff --git a/whiteboard.cron b/whiteboard.cron
new file mode 100644
index 0000000..705c2eb
--- /dev/null
+++ b/whiteboard.cron
@@ -0,0 +1,2 @@
+# Cleanup whiteboard data once every day
+02,31 * * * * root [ -x /usr/bin/whiteboard-cleanup ] && if [ ! -d /run/systemd/system ]; then /usr/bin/whiteboard-cleanup ; fi