Index: src/webapp/webclient/css/main.css
===================================================================
--- src/webapp/webclient/css/main.css	(revision a250eb459a1676c4a62f1cc09187005d574d5b09)
+++ src/webapp/webclient/css/main.css	(revision 5519ced720fb38c5b38c6dedc224ade1d8f5e7d7)
@@ -18,4 +18,5 @@
 body {
 	margin: 1em;
+	width: 58.3mm;
 }
 
@@ -35,5 +36,5 @@
 #display {
 	background-color: #E6E6E6;
-	width: 58.3mm;
+	width: 100%;
 	height: 38.2mm;
 	font-size: 12pt;
@@ -94,5 +95,5 @@
 
 #map {
-	width: 58.3mm;
+	width: 100%;
 	height: 76mm;
 	border: 1px solid black;
@@ -133,2 +134,15 @@
 
 }
+
+#shutdown {
+	width: 100%;
+	margin-top: 3em;
+}
+
+#shutdown button {
+	background-color: #8C1C00;
+	color: white;
+	font-weight: bold;
+	font-size: 24pt;
+	width: 100%;
+}
Index: src/webapp/webclient/javascript/main.js
===================================================================
--- src/webapp/webclient/javascript/main.js	(revision a250eb459a1676c4a62f1cc09187005d574d5b09)
+++ src/webapp/webclient/javascript/main.js	(revision 5519ced720fb38c5b38c6dedc224ade1d8f5e7d7)
@@ -102,4 +102,17 @@
 }
 
+function shutdown(){
+	$.getJSON("../webservice/?request=shutdown", function(data){
+		var shutdownTime = data["shutdownstart"];
+		var shutdownDate = new Date(shutdownTime);
+		var currentDate = new Date();
+		var shutdownHint = "Shutting down in "+ Math.floor((shutdownDate - currentDate)/1000) +"s at "+ shutdownTime.toLocaleString();
+		if(shutdownTime == -1){
+			shutdownHint = "Failed to initiate shutdown!";
+		}
+		$("#shutdownMessage").text(shutdownHint);
+	});
+}
+
 $(document).ready(function() {
 	displayDataGet();
@@ -107,3 +120,5 @@
 	
 	$.getJSON("../webservice/tileserver.php?/map.json", mapSetup);
+	
+	$("#shutdownButton").click(shutdown);
 });
Index: src/webapp/webclient/root/index.php
===================================================================
--- src/webapp/webclient/root/index.php	(revision a250eb459a1676c4a62f1cc09187005d574d5b09)
+++ src/webapp/webclient/root/index.php	(revision 5519ced720fb38c5b38c6dedc224ade1d8f5e7d7)
@@ -100,4 +100,10 @@
 		</div>
 	</form>
+	<div id="shutdown">
+		<p id="shutdownMessage"/>
+		<form>
+			<button type="button" id="shutdownButton">SHUTDOWN</button>
+		</form>
+	</div>
 <?php
 require_once("inc/footer.php");
Index: src/webapp/webservice/index.php
===================================================================
--- src/webapp/webservice/index.php	(revision a250eb459a1676c4a62f1cc09187005d574d5b09)
+++ src/webapp/webservice/index.php	(revision 5519ced720fb38c5b38c6dedc224ade1d8f5e7d7)
@@ -21,4 +21,8 @@
 $dbFile = $config->databaseFile();
 
+define("REQUEST_DATA", "data");
+define("REQUEST_SHUTDOWN", "shutdown");
+
+
 // configure roundings per value (key) and precision (value)
 $configRound = array
@@ -36,80 +40,114 @@
 	$debug = $_GET["debug"];
 
+$request = REQUEST_DATA;
+if(array_key_exists("request", $_GET)){
+	$request = $_GET["request"];
+}
+
 if($debug == 0)
 	header('Content-Type: application/json');
 
-$result["lastvalid"] = array();
-$result["track"] = array();
+$result = array();
+if($request == REQUEST_SHUTDOWN){
+	$handle = @fopen("/var/spool/gnuboat/gnuboat_shutdown", "w");
+	if($handle === false){
+		$message = "Could not create file to indicate shutdown to the daemon (Timezone: ". date_default_timezone_get() .")";
+		if($debug > 0)
+			echo $message;
+		error_log($message);
+		$result["shutdownstart"] = -1;
+		$shutdownTime = new DateTime('NOW');
+		$shutdownTime->modify("+60 seconds");
+		$result["shutdownstart"] = $shutdownTime->format(DateTime::ISO8601);
+	}
+	else{
+		$shutdownTime = new DateTime('NOW');
+		$shutdownTime>modify("+15 seconds");
+		fwrite($handle, $shutdownTime->format(DateTime::ISO8601));
+		$result["shutdownstart"] = $shutdownTime->format(DateTime::ISO8601);
+	}
+}
+elseif($request == REQUEST_DATA){
+	$result["lastvalid"] = array();
+	$result["track"] = array();
 
-// Fetch entries of the last 12hours
-$data = rrd_fetch($dbFile, array( "AVERAGE", "--start", "-12h"));
-if($data === false){
-	echo json_encode($result);
-	$message = "Could not open rrd database ". $dbFile; 
-	if($debug > 0)
-		echo $message;
-	else
-		error_log($message);
-	exit;
-}
+	if(!file_exists($dbFile)){
+		echo json_encode("");
+		if($debug > 0)
+			echo "Database file ". $dbFile ." does not exist!";
+		error_log("Database file ". $dbFile ." does not exist");
+		exit;
+	}
+	// Fetch entries of the last 12hours
+	$data = rrd_fetch($dbFile, array( "AVERAGE", "--resolution", "5", "--start", "-12h"));
+	if($data === false){
+		echo json_encode($result);
+		$message = "Could not open rrd database ". $dbFile; 
+		if($debug > 0)
+			echo $message;
+		else
+			error_log($message);
+		exit;
+	}
 
-if($debug > 2){
-	echo "<pre>";
-	var_dump($data);
-	echo "</pre>";
-}
+	if($debug > 2){
+		echo "<pre>";
+		var_dump($data);
+		echo "</pre>";
+	}
 
-$data = $data["data"];
+	$data = $data["data"];
 
-// transform them into json format
-$i = 0;
-$lastTime = -1;
-$keys = array_keys($data);
-if(count($keys) < 0 ){
-	error_log("No keys in fetched rrd data from ". $dbFile);
-	echo json_encode("");
-	exit;
-}
-for($i = 0; $i < count($data[$keys[0]]); $i++){
-	$time = array_keys($data[$keys[0]])[$i];
-	$allValid = true;
-	$tmp = array();
-	foreach($keys as $key){
-		if($key == "gpsfix"){
-			switch($data[$key][$time]){
-				case 1:
-					$tmp[$key] = "2D";
-					break;
-				case 2:
-					$tmp[$key] = "3D";
-					break;
-				default:
-					$tmp[$key] = "-";
+	// transform them into json format
+	$i = 0;
+	$lastTime = -1;
+	$keys = array_keys($data);
+	if(count($keys) < 0 ){
+		error_log("No keys in fetched rrd data from ". $dbFile);
+		echo json_encode("");
+		exit;
+	}
+	for($i = 0; $i < count($data[$keys[0]]); $i++){
+		$time = array_keys($data[$keys[0]])[$i];
+		$allValid = true;
+		$tmp = array();
+		foreach($keys as $key){
+			if($key == "gpsfix"){
+				switch($data[$key][$time]){
+					case 1:
+						$tmp[$key] = "2D";
+						break;
+					case 2:
+						$tmp[$key] = "3D";
+						break;
+					default:
+						$tmp[$key] = "-";
+				}
+			}
+			else{
+				$tmp[$key] = $data[$key][$time];
+				if(!is_numeric($tmp[$key]) || is_nan($tmp[$key])){
+					$allValid = false;
+				}
+				elseif(array_key_exists($key, $configRound) && is_integer($configRound[$key]))
+					$tmp[$key] = round($tmp[$key], $configRound[$key]);
 			}
 		}
+		// only add the timeframe to the track, if the values are valid and we had a gps fix at that time
+		if($allValid && $tmp["gpsfix"] != "-"){
+			$result["track"][$time] = $tmp;
+			$lastTime = $time;
+		}
 		else{
-			$tmp[$key] = $data[$key][$time];
-			if(!is_numeric($tmp[$key]) || is_nan($tmp[$key])){
-				$allValid = false;
+			if($debug > 0){
+				echo "Failed <pre>";
+				var_dump($tmp);
+				echo "</pre>\n";
 			}
-			elseif(array_key_exists($key, $configRound) && is_integer($configRound[$key]))
-				$tmp[$key] = round($tmp[$key], $configRound[$key]);
 		}
 	}
-	// only add the timeframe to the track, if the values are valid and we had a gps fix at that time
-	if($allValid && $tmp["gpsfix"] != "-"){
-		$result["track"][$time] = $tmp;
-		$lastTime = $time;
+	if($lastTime > -1){
+		$result["lastvalid"] = $result["track"][$lastTime];
 	}
-	else{
-		if($debug > 0){
-			echo "Failed <pre>";
-			var_dump($tmp);
-			echo "</pre>\n";
-		}
-	}
-}
-if($lastTime > -1){
-	$result["lastvalid"] = $result["track"][$lastTime];
 }
 
