tazcraft view 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 source
1 #!/bin/sh
2 #
3 # tazcraft.cgi - A Minecraft server info/admin CGI interface
4 #
5 # Authors: Kayam Lincoln-Vazquez, Christophe Lincoln
6 # Copyright (C) 2017 SliTaz GNU/Linux - BSD License
7 #
8 . /usr/lib/slitaz/httphelper.sh
9 header
11 home="/home/minecraft"
12 server="$home/server"
13 config="$server/server.properties"
15 # Get a value in
16 get_value() {
17 val=$(grep ^${1}= ${config} | cut -d "=" -f 2)
18 cat << EOT
19 <tr>
20 <td>$1</td>
21 <td>$val</td>
22 </tr>
23 EOT
24 }
26 # HTML header
27 cat << EOT
28 <!DOCTYPE html>
29 <html>
30 <head>
31 <meta charset="utf-8" />
32 <title>Tazcraft</title>
33 <link rel="stylesheet" href="http://play.slitaz.me/style.css" />
34 </head>
35 <body>
36 <header>
37 <div id="logo"></div>
38 <div id="network">
39 <a href="http://play.slitaz.me">play.SliTaz.me</a>
40 <a href="http://www.slitaz.org">SliTaz.org</a>
41 </div>
42 <h1>Tazcraft Server</h1>
43 </header>
44 <div id="content">
46 <h2>Welcome to Tazcraft</h2>
47 <p>A SliTaz GNU/Linux Minecraft server</p>
48 <pre>
49 <img src="minecraft.png" alt="*" />Server address: <b>play.slitaz.me</b>
50 </pre>
52 <h3>Configuration</h3>
53 <table>
54 <thead>
55 <td>$(gettext "Variable")</td>
56 <td>$(gettext "Value")</td>
57 </thead>
58 EOT
60 for var in gamemode server-port level-name difficulty max-players; do
61 get_value ${var}
62 done
64 # HTML footer
65 cat << EOT
66 </table>
67 </div>
68 <footer></footer>
69 </body>
70 </htnl>
71 EOT
72 exit 0