# HG changeset patch # User Christophe Lincoln # Date 1489958976 -3600 # Node ID 6eac67be306d5beb1373bd85499ae3b30c473c84 # Parent d588912d23cda00bc6f486b06d9d33b42e25fcac Quiet a few improvment to tazcraft and cgi interface diff -r d588912d23cd -r 6eac67be306d Makefile --- a/Makefile Sun Mar 19 17:44:13 2017 +0100 +++ b/Makefile Sun Mar 19 22:29:36 2017 +0100 @@ -13,13 +13,17 @@ install -m 0755 -d $(DESTDIR)$(PREFIX)/bin install -m 0755 -d $(DESTDIR)$(PREFIX)/share/applications install -m 0755 -d $(DESTDIR)$(PREFIX)/share/pixmaps + install -m 0755 -d $(DESTDIR)$(PREFIX)/share/doc/slitaz install -m 0755 $(PACKAGE) $(DESTDIR)$(PREFIX)/bin install data/minecraft.desktop $(DESTDIR)$(PREFIX)/share/applications - install images/minecraft.png $(DESTDIR)$(PREFIX)/share/pixmaps + install web/minecraft.png $(DESTDIR)$(PREFIX)/share/pixmaps + install README $(DESTDIR)$(PREFIX)/share/doc/slitaz/tazcraft.txt install-server: install -m 0755 -d $(DESTDIR)$(PREFIX)/bin + install -m 0755 -d $(DESTDIR)$(PREFIX)/share/doc/slitaz install -m 0755 $(PACKAGE) $(DESTDIR)$(PREFIX)/bin + install README $(DESTDIR)$(PREFIX)/share/doc/slitaz/tazcraft.txt # Uninstallation diff -r d588912d23cd -r 6eac67be306d README --- a/README Sun Mar 19 17:44:13 2017 +0100 +++ b/README Sun Mar 19 22:29:36 2017 +0100 @@ -6,24 +6,44 @@ also optionally install the Java Runtime Environment (JRE). -Server operator ---------------- -From the server console: /op username +== Play to Minecraft on SliTaz == +--------------------------------- +Tazcraft is not yet packaged, you have to grab the source from Hg and run + $ sudo make install -Server configuration --------------------- -Config file: server.properties +Tazcraft will automaticaly download Minecraft client and start it. Minecraft +is powered by Java, it may work with icetea but Tazcraft let you install the +Sun Java Runtime environment, please see the Java section. When Java and +Tazcraft are installed you will find a menu entry in the Games category. To +start playing from command line: -gamemode= - 0 - Survival - 1 - Creative - 2 - Adventure - 3 - Spectator + $ tazcraft -p -MOTD text colours and formatting -------------------------------- +== Minecraft server console commands == +---------------------------------------- +Just a few useful console commands Use the built-in help the get all commands: + + /help [1-9] + /op [username] + /whitelist [on|off|list|add|remove|reload] + /stop + + +== Server configuration: server.properties == +--------------------------------------------- + + gamemode= + 0 - Survival + 1 - Creative + 2 - Adventure + 3 - Spectator + + +== MOTD text colours and formatting == +-------------------------------------- + \u00A70 - BLACK \u00A71 - DARK BLUE \u00A72 - DARK GREEN @@ -47,7 +67,9 @@ \u00A7o - Italic \u00A7r - Reset -Online resources ----------------- -MOTD creator: https://mctools.org/motd-creator +== Online resources == +---------------------- + + MOTD creator: http://mctools.org/motd-creator + diff -r d588912d23cd -r 6eac67be306d images/minecraft-256x256.png Binary file images/minecraft-256x256.png has changed diff -r d588912d23cd -r 6eac67be306d images/minecraft.png Binary file images/minecraft.png has changed diff -r d588912d23cd -r 6eac67be306d tazcraft --- a/tazcraft Sun Mar 19 17:44:13 2017 +0100 +++ b/tazcraft Sun Mar 19 22:29:36 2017 +0100 @@ -5,7 +5,7 @@ # Authors: Kayam Lincoln-Vazquez, Christophe Lincoln # Copyright (C) 2017 SliTaz GNU/Linux - BSD License # -# TODO: add spigot support, rcon handler, properties settings +# TODO: add spigot support, rcon handler ?, properties settings # . /lib/libtaz.sh @@ -13,6 +13,8 @@ home="/home/minecraft" server="$home/server" config="$server/server.properties" +ops="$server/ops.json" +whitelist="${server}/whitelist.json" server_jar="minecraft_server.${version}.jar" client_jar="Minecraft.jar" @@ -20,6 +22,7 @@ spigot_jar="spigot-${version}.jar" +# Java settings java_version="8u121" java_id="218821" java_md5="e9e7ea248e2c4826b92b3f075a80e441" @@ -37,19 +40,24 @@ help() { cat << EOT -$(colorize 032 Usage:) $(basename $0) command +$(colorize 032 Usage:) $(basename $0) [command|key] [value] $(colorize 032 Commands:) + -d downlaod Download the Minecraft server -s start Start your Minecraft server -p play Launch the Minecraft client -j java Install Sun Java Runtime Environment + -k key Get or set a key value in server.properties -i info Display server and java information - motd Raw display of the Message Of The Day - ops Show server operators name + -m motd Raw display of the Message Of The Day + -o ops Show server operators name + -w with-list Show allowed user from white list $(colorize 032 Options:) + --gui Run the server with a graphical user interface + --mem Set the max memory usage for Minecraft server EOT } @@ -76,10 +84,10 @@ fi } -# Get a value in -get_value() { +# Get a key value from server config file +get_key() { val=$(grep ^${1}= ${config} | cut -d "=" -f 2) - echo -n "$1"; indent 15 ": $val" + echo -n "$1"; indent 15 "= $(colorize 033 $val)" } # @@ -90,21 +98,26 @@ -d|downlaod) if [ ! -f "$server/$jar" ]; then echo "Downloading Minecraft..." + mkdir -p ${server} wget --no-check-certificate \ https://s3.amazonaws.com/Minecraft.Download/versions/${version}/minecraft_server.${version}.jar \ -O ${server}/minecraft_server.${version}.jar + else colorize 032 "Minecraft is already downloaded :-)" fi ;; -s|start) check_java || exit 1 - defaut_motd + [ "$mem" ] || mem="1024" + colorize 032 "Starting Minecraft server..." [ ! "$gui" ] && opts="nogui" cd ${server} - ${java} -Xmx1024M -Xms1024M -jar ${server_jar} ${opts} ;; + ${java} -Xmx${mem}M -Xms${mem}M -jar ${server_jar} ${opts} + + newline ;; -p|play) if [ ! -f "$client_path" ]; then @@ -135,8 +148,17 @@ colorize 032 "Java Runtime Environment is installed" ${java} -version fi ;; + + -k|key) + key="$2" + val="$3" + if [ "$val" ]; then + echo "Setting $key to: $val" + sed -i s"/${key}=.*/${key}=${val}/" ${config} + fi + get_key ${key} ;; - motd) + -m|motd) defaut_motd motd=$(grep ^motd= ${config} | sed s'/motd=//') title "Message Of The Day (motd)" @@ -145,39 +167,21 @@ -o|ops) title "Server operators" - ops_json="$server/ops.json" - #echo "Config file: $server/ops.json" - fgrep name ${ops_json} | cut -d '"' -f 4 + fgrep name ${ops} | cut -d '"' -f 4 + newline + colorize 033 "Config file: $ops" newline ;; -w|white-list) - # Usage: tazcraft -w [username|--true|--false] - white_list="${server}/white-list.txt" title "Minecraft server white list" - case "$2" in - - --true) - echo "Activaction white list support..." - sed -i s'/white-list=*./white-list=true/' ${config} - touch ${white_list} ;; - - --false) ;; - *) ;; - esac - # Add/remove users - - - # --true - if [ "$true" ]; then - - fi - # Display white list users or give settings info if [ -f "$white_list" ]; then + users=$(wc -l < $white_list) cat ${white_list} + echo -e "\nAllowed users: $users" else - get_value "white-list" + get_key "white-list" colorize 031 "White list file is not activated $val" fi @@ -192,9 +196,9 @@ colorize 032 "Server properties" for var in gamemode server-port level-name difficulty max-players \ - allow-flight + allow-flight white-list do - get_value ${var} + get_key ${var} done newline diff -r d588912d23cd -r 6eac67be306d web/tazcraft.cgi --- a/web/tazcraft.cgi Sun Mar 19 17:44:13 2017 +0100 +++ b/web/tazcraft.cgi Sun Mar 19 22:29:36 2017 +0100 @@ -11,9 +11,10 @@ home="/home/minecraft" server="$home/server" config="$server/server.properties" +whitelist="${server}/whitelist.json" -# Get a value in -get_value() { +# Get a key value from server config file +get_key() { val=$(grep ^${1}= ${config} | cut -d "=" -f 2) cat << EOT @@ -23,50 +24,116 @@ EOT } +# HTML footer +html_footer() { + cat << EOT + + + + +EOT +} + # HTML header -cat << EOT +html_header() { + cat << EOT - Tazcraft + Tazcraft - $1

Tazcraft Server

+EOT +} +# +# Handle GET commands +# + +case " $(GET) " in + + *\ README\ *) + + if [ -f "../README" ]; then + README="../README" + else + README="/usr/share/doc/slitaz/tazcraft.txt" + fi + + html_header "README" + echo "

README

" + echo "
"
+		# Let have a few color in README
+		cat ${README} | sed \
+			-e "/^====.*/"d -e "/^----.*/"d \
+			-e s"#==\([^']*\)==#

\1

#"g \ + -e s"#^ [\#|\$|\/]\([^']*\)#\0#"g \ + -e s"#http://\([^']*\).*#\0#"g + echo "
" + html_footer + exit 0 ;; + +esac + +# +# Home page with server information and configuration +# +html_header "Welcome" + +uptime=$(ps | grep minecraft_server | grep -v grep | awk '{print $3}') +if [ ! "$uptime" ]; then + uptime="Not running" +fi + +cat << EOT

Welcome to Tazcraft

-

A SliTaz GNU/Linux Minecraft server

+

+ A SliTaz GNU/Linux Minecraft server + - Uptime: $uptime +

+
-*Server address: play.slitaz.me
+*Server address: \
+play.slitaz.me
 

Configuration

- + EOT -for var in gamemode server-port level-name difficulty max-players; do - get_value ${var} +for var in gamemode server-port level-name difficulty max-players \ + allow-flight white-list +do + get_key ${var} done +echo "
$(gettext "Variable")$(gettext "Key") $(gettext "Value")
" -# HTML footer -cat << EOT - -
- - - -EOT +# White listed users names +if grep -q "white-list=true" ${config}; then + echo "

White list

" + echo "
"
+	fgrep name ${whitelist} | cut -d '"' -f 4
+	echo "
" +fi + +html_footer exit 0