summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/pingscript30
-rw-r--r--scripts/settings1
-rwxr-xr-xscripts/template.py71
-rwxr-xr-xscripts/webcamscript20
4 files changed, 122 insertions, 0 deletions
diff --git a/scripts/pingscript b/scripts/pingscript
new file mode 100755
index 0000000..f6671b4
--- /dev/null
+++ b/scripts/pingscript
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+. settings
+
+logger -t sublab-updater starting status update
+
+insertstatus() {
+ local status
+ if [ $? -eq 0 ]; then
+ status=online
+ else
+ status=offline
+ fi
+ cp ${WEBPATH}/csstemplate/${status}.${1}.status.css ${WEBPATH}/public/css/${1}.status.css.new
+ mv -f ${WEBPATH}/public/css/${1}.status.css.new ${WEBPATH}/public/css/${1}.status.css
+}
+
+# Ping Taifun
+ping -q -c 2 -W 1 172.22.83.5 &> /dev/null
+insertstatus taifun
+
+# Ping Trieste
+ping -q -c 2 -W 1 172.22.80.4 &> /dev/null
+insertstatus trieste
+
+# Ping Nautilus
+ping -q -c 2 -W 1 172.22.80.7 &> /dev/null
+insertstatus nautilus
+
+exit 0
diff --git a/scripts/settings b/scripts/settings
new file mode 100644
index 0000000..62b42a7
--- /dev/null
+++ b/scripts/settings
@@ -0,0 +1 @@
+WEBPATH=../
diff --git a/scripts/template.py b/scripts/template.py
new file mode 100755
index 0000000..eaa1682
--- /dev/null
+++ b/scripts/template.py
@@ -0,0 +1,71 @@
+#!/usr/bin/python
+
+import string
+import time
+import datetime
+from string import Template
+
+def readfiles(prefix):
+
+ #set globals
+ global content
+ global keywords
+ global desc_de
+ global desc_en
+
+ #set content
+ f = open(prefix + ".content.html", "r")
+ content = f.read()
+ f.close
+
+ #set keywords
+ f = open(prefix + ".keywords", "r")
+ keywords = f.read()
+ f.close
+
+ #set german description
+ f = open(prefix + ".desc_de", "r")
+ desc_de = f.read()
+ f.close
+
+ #set english description
+ f = open(prefix + ".desc_en", "r")
+ desc_en = f.read()
+ f.close
+
+def substitute(target, prefix, htmltemplate, datenow, chattopic, keywords, content, desc_de, desc_en):
+
+ #create template-string
+ htmltext = Template(htmltemplate)
+ htmltext = htmltext.substitute(template_date = datenow, template_chattopic = chattopic, template_keywords = keywords, template_content = content, template_desc_de = desc_de, template_desc_en = desc_en)
+
+ #write it to the outpufile
+ outputfile = open(target + prefix + ".html", "w")
+ outputfile.write(htmltext)
+ outputfile.close()
+
+contentpath = "../template/"
+target = "../public/"
+
+#set template
+f = open(contentpath + "template.html", "r")
+htmltemplate = f.read()
+f.close
+print ("template read")
+
+#set chattopic
+f = open(contentpath + "chattopic", "r")
+chattopic = f.read()
+f.close
+print ("chattopic read")
+
+#set date
+datenow = time.strftime("%Y-%m-%dT%H:%M:%S +0100")
+print ("Set date: " + datenow)
+
+prefixes = ['index', 'neues', 'termine', 'raeume', 'lage', 'kontakt', 'verein', 'impressum', 'webcam']
+
+for prefix in prefixes:
+ readfiles(contentpath + prefix)
+ substitute(target, prefix, htmltemplate, datenow, chattopic, keywords, content, desc_de, desc_en)
+ print(prefix + ".html written")
diff --git a/scripts/webcamscript b/scripts/webcamscript
new file mode 100755
index 0000000..c48a0a2
--- /dev/null
+++ b/scripts/webcamscript
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+. settings
+
+TODAY=`date`
+TIME=`date +"%H"`
+
+wget http://taifun.local.sublab.org/webcam.jpg -O ${WEBPATH}/public/img/buffer.rack.webcam.jpg &> /dev/null || exit 1
+
+cp ${WEBPATH}/public/img/buffer.rack.webcam.jpg ${WEBPATH}/public/img/buffer.thumb.rack.webcam.jpg
+mogrify -resize 200x150 ${WEBPATH}/public/img/buffer.thumb.rack.webcam.jpg
+if [ $TIME -lt 6 ] || [ $TIME -ge 18 ]; then
+ mogrify -fill white -gravity SouthEast -draw "text 10,10 '${TODAY}'" ${WEBPATH}/public/img/buffer.rack.webcam.jpg
+else
+ mogrify -fill black -gravity SouthEast -draw "text 10,10 '${TODAY}'" ${WEBPATH}/public/img/buffer.rack.webcam.jpg
+fi
+
+mv -f ${WEBPATH}/public/img/buffer.rack.webcam.jpg ${WEBPATH}/public/img/rack.webcam.jpg &> /dev/null
+mv -f ${WEBPATH}/public/img/buffer.thumb.rack.webcam.jpg ${WEBPATH}/public/img/thumb.rack.webcam.jpg &> /dev/null
+exit 0