From 5ee8fd94512d7f4ea7d49310dc8e1151ef833cac Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Fri, 18 Mar 2011 23:28:52 +0100 Subject: Initial commit --- .gitignore | 2 + csstemplate/offline.nautilus.status.css | 7 ++++ csstemplate/offline.taifun.status.css | 8 ++++ csstemplate/offline.trieste.status.css | 8 ++++ csstemplate/online.nautilus.status.css | 7 ++++ csstemplate/online.taifun.status.css | 8 ++++ csstemplate/online.trieste.status.css | 8 ++++ scripts/pingscript | 30 ++++++++++++++ scripts/settings | 1 + scripts/template.py | 71 +++++++++++++++++++++++++++++++++ scripts/webcamscript | 20 ++++++++++ 11 files changed, 170 insertions(+) create mode 100644 .gitignore create mode 100644 csstemplate/offline.nautilus.status.css create mode 100644 csstemplate/offline.taifun.status.css create mode 100644 csstemplate/offline.trieste.status.css create mode 100644 csstemplate/online.nautilus.status.css create mode 100644 csstemplate/online.taifun.status.css create mode 100644 csstemplate/online.trieste.status.css create mode 100755 scripts/pingscript create mode 100644 scripts/settings create mode 100755 scripts/template.py create mode 100755 scripts/webcamscript diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..61384cd --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/template +/public diff --git a/csstemplate/offline.nautilus.status.css b/csstemplate/offline.nautilus.status.css new file mode 100644 index 0000000..c856e58 --- /dev/null +++ b/csstemplate/offline.nautilus.status.css @@ -0,0 +1,7 @@ +span.nautilusonline { + color: #222; + } + +span.nautilusoffline { + color: #f00; + } diff --git a/csstemplate/offline.taifun.status.css b/csstemplate/offline.taifun.status.css new file mode 100644 index 0000000..a16e456 --- /dev/null +++ b/csstemplate/offline.taifun.status.css @@ -0,0 +1,8 @@ +span.taifunonline { + color: #222; + } + +span.taifunoffline { + color: #f00; + } + diff --git a/csstemplate/offline.trieste.status.css b/csstemplate/offline.trieste.status.css new file mode 100644 index 0000000..1b261de --- /dev/null +++ b/csstemplate/offline.trieste.status.css @@ -0,0 +1,8 @@ +span.triesteonline { + color: #222; + } + +span.triesteoffline { + color: #f00; + } + diff --git a/csstemplate/online.nautilus.status.css b/csstemplate/online.nautilus.status.css new file mode 100644 index 0000000..7232ee2 --- /dev/null +++ b/csstemplate/online.nautilus.status.css @@ -0,0 +1,7 @@ +span.nautilusonline { + color: #0f0; + } + +span.nautilusoffline { + color: #222; + } diff --git a/csstemplate/online.taifun.status.css b/csstemplate/online.taifun.status.css new file mode 100644 index 0000000..548cf2a --- /dev/null +++ b/csstemplate/online.taifun.status.css @@ -0,0 +1,8 @@ +span.taifunonline { + color: #0f0; + } + +span.taifunoffline { + color: #222; + } + diff --git a/csstemplate/online.trieste.status.css b/csstemplate/online.trieste.status.css new file mode 100644 index 0000000..733c206 --- /dev/null +++ b/csstemplate/online.trieste.status.css @@ -0,0 +1,8 @@ +span.triesteonline { + color: #0f0; + } + +span.triesteoffline { + color: #222; + } + 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..eb1c5ad --- /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() + +#set template +f = open("template.html", "r") +htmltemplate = f.read() +f.close +print ("template read") + +#set chattopic +f = open("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) + +contentpath = "../template/" +target = "../public/" + +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 -- cgit v1.2.1