tazcraft diff web/tazcraft.cgi @ 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 | |
children | 6eac67be306d |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/web/tazcraft.cgi Sun Mar 19 17:44:13 2017 +0100 1.3 @@ -0,0 +1,72 @@ 1.4 +#!/bin/sh 1.5 +# 1.6 +# tazcraft.cgi - A Minecraft server info/admin CGI interface 1.7 +# 1.8 +# Authors: Kayam Lincoln-Vazquez, Christophe Lincoln 1.9 +# Copyright (C) 2017 SliTaz GNU/Linux - BSD License 1.10 +# 1.11 +. /usr/lib/slitaz/httphelper.sh 1.12 +header 1.13 + 1.14 +home="/home/minecraft" 1.15 +server="$home/server" 1.16 +config="$server/server.properties" 1.17 + 1.18 +# Get a value in 1.19 +get_value() { 1.20 + val=$(grep ^${1}= ${config} | cut -d "=" -f 2) 1.21 + cat << EOT 1.22 +<tr> 1.23 + <td>$1</td> 1.24 + <td>$val</td> 1.25 +</tr> 1.26 +EOT 1.27 +} 1.28 + 1.29 +# HTML header 1.30 +cat << EOT 1.31 +<!DOCTYPE html> 1.32 +<html> 1.33 +<head> 1.34 + <meta charset="utf-8" /> 1.35 + <title>Tazcraft</title> 1.36 + <link rel="stylesheet" href="http://play.slitaz.me/style.css" /> 1.37 +</head> 1.38 +<body> 1.39 +<header> 1.40 + <div id="logo"></div> 1.41 + <div id="network"> 1.42 + <a href="http://play.slitaz.me">play.SliTaz.me</a> 1.43 + <a href="http://www.slitaz.org">SliTaz.org</a> 1.44 + </div> 1.45 + <h1>Tazcraft Server</h1> 1.46 +</header> 1.47 +<div id="content"> 1.48 + 1.49 +<h2>Welcome to Tazcraft</h2> 1.50 +<p>A SliTaz GNU/Linux Minecraft server</p> 1.51 +<pre> 1.52 +<img src="minecraft.png" alt="*" />Server address: <b>play.slitaz.me</b> 1.53 +</pre> 1.54 + 1.55 +<h3>Configuration</h3> 1.56 +<table> 1.57 + <thead> 1.58 + <td>$(gettext "Variable")</td> 1.59 + <td>$(gettext "Value")</td> 1.60 + </thead> 1.61 +EOT 1.62 + 1.63 +for var in gamemode server-port level-name difficulty max-players; do 1.64 + get_value ${var} 1.65 +done 1.66 + 1.67 +# HTML footer 1.68 +cat << EOT 1.69 +</table> 1.70 +</div> 1.71 +<footer></footer> 1.72 +</body> 1.73 +</htnl> 1.74 +EOT 1.75 +exit 0