summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVG <vg@devys.org>2014-11-29 18:23:29 +0100
committerVG <vg@devys.org>2014-11-29 18:23:29 +0100
commit394ad3a32cd37ec96641f63492cc5065c7210e17 (patch)
tree3db9b8a42c665dd4a1e7a6be739338a648819cda
parent900b8d1abe149645249c53e7befca7e8895f5bc8 (diff)
downloadpasteme-394ad3a32cd37ec96641f63492cc5065c7210e17.tar.gz
pasteme-394ad3a32cd37ec96641f63492cc5065c7210e17.tar.bz2
pasteme-394ad3a32cd37ec96641f63492cc5065c7210e17.zip
add cron script to purge old pastes
-rw-r--r--config.py4
l---------scripts/config.py1
-rwxr-xr-xscripts/purge-old-pastes.sh8
3 files changed, 13 insertions, 0 deletions
diff --git a/config.py b/config.py
index 4454890..8b53f8c 100644
--- a/config.py
+++ b/config.py
@@ -1,3 +1,7 @@
# configuration file of pastme service
+# the directory where the pastes are stored
pastedir = '/tmp/pastes'
+
+# how many days a paste remain stored
+timeout = 30
diff --git a/scripts/config.py b/scripts/config.py
new file mode 120000
index 0000000..3721332
--- /dev/null
+++ b/scripts/config.py
@@ -0,0 +1 @@
+../config.py \ No newline at end of file
diff --git a/scripts/purge-old-pastes.sh b/scripts/purge-old-pastes.sh
new file mode 100755
index 0000000..a22ded8
--- /dev/null
+++ b/scripts/purge-old-pastes.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+# This script is intend to be run as a cron job (every day for ex) to purge
+# old pastes.
+
+pastedir="$(python3 -c 'import config; print(config.pastedir)')"
+timeout="$(python3 -c 'import config; print(config.timeout)')"
+find "$pastedir" -type f -mtime +"$timeout" -exec rm {} \;