tazcraft rev 4
Add the CGI web interface
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sun Mar 19 17:44:13 2017 +0100 (2017-03-19) |
parents | 525121d3c8e8 |
children | 6eac67be306d |
files | web/minecraft.png web/tazcraft.cgi |
line diff
1.1 Binary file web/minecraft.png has changed
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/web/tazcraft.cgi Sun Mar 19 17:44:13 2017 +0100 2.3 @@ -0,0 +1,72 @@ 2.4 +#!/bin/sh 2.5 +# 2.6 +# tazcraft.cgi - A Minecraft server info/admin CGI interface 2.7 +# 2.8 +# Authors: Kayam Lincoln-Vazquez, Christophe Lincoln 2.9 +# Copyright (C) 2017 SliTaz GNU/Linux - BSD License 2.10 +# 2.11 +. /usr/lib/slitaz/httphelper.sh 2.12 +header 2.13 + 2.14 +home="/home/minecraft" 2.15 +server="$home/server" 2.16 +config="$server/server.properties" 2.17 + 2.18 +# Get a value in 2.19 +get_value() { 2.20 + val=$(grep ^${1}= ${config} | cut -d "=" -f 2) 2.21 + cat << EOT 2.22 +<tr> 2.23 + <td>$1</td> 2.24 + <td>$val</td> 2.25 +</tr> 2.26 +EOT 2.27 +} 2.28 + 2.29 +# HTML header 2.30 +cat << EOT 2.31 +<!DOCTYPE html> 2.32 +<html> 2.33 +<head> 2.34 + <meta charset="utf-8" /> 2.35 + <title>Tazcraft</title> 2.36 + <link rel="stylesheet" href="http://play.slitaz.me/style.css" /> 2.37 +</head> 2.38 +<body> 2.39 +<header> 2.40 + <div id="logo"></div> 2.41 + <div id="network"> 2.42 + <a href="http://play.slitaz.me">play.SliTaz.me</a> 2.43 + <a href="http://www.slitaz.org">SliTaz.org</a> 2.44 + </div> 2.45 + <h1>Tazcraft Server</h1> 2.46 +</header> 2.47 +<div id="content"> 2.48 + 2.49 +<h2>Welcome to Tazcraft</h2> 2.50 +<p>A SliTaz GNU/Linux Minecraft server</p> 2.51 +<pre> 2.52 +<img src="minecraft.png" alt="*" />Server address: <b>play.slitaz.me</b> 2.53 +</pre> 2.54 + 2.55 +<h3>Configuration</h3> 2.56 +<table> 2.57 + <thead> 2.58 + <td>$(gettext "Variable")</td> 2.59 + <td>$(gettext "Value")</td> 2.60 + </thead> 2.61 +EOT 2.62 + 2.63 +for var in gamemode server-port level-name difficulty max-players; do 2.64 + get_value ${var} 2.65 +done 2.66 + 2.67 +# HTML footer 2.68 +cat << EOT 2.69 +</table> 2.70 +</div> 2.71 +<footer></footer> 2.72 +</body> 2.73 +</htnl> 2.74 +EOT 2.75 +exit 0