diff --git a/README.md b/README.md index 01b2390a..57f98170 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,108 @@ With that you can easily view the logs, stop, or re-start the container: **TABLE OF CONTENTS** + * [Looking for a Bedrock Dedicated Server](#looking-for-a-bedrock-dedicated-server) + * [Interacting with the server](#interacting-with-the-server) + * [Data Directory](#data-directory) + * [Attaching data directory to host filesystem](#attaching-data-directory-to-host-filesystem) + * [Converting anonymous /data volume to named volume](#converting-anonymous-data-volume-to-named-volume) + * [Versions](#versions) + * [Running Minecraft server on different Java version](#running-minecraft-server-on-different-java-version) + * [Deprecated Image Tags](#deprecated-image-tags) + * [Healthcheck](#healthcheck) + * [Deployment Templates and Examples](#deployment-templates-and-examples) + * [Helm Charts](#helm-charts) + * [Examples](#examples) + * [Amazon Web Services (AWS) Deployment](#amazon-web-services-aws-deployment) + * [Running a Forge Server](#running-a-forge-server) + * [Managing mods](#managing-mods) + * [Running a Bukkit/Spigot server](#running-a-bukkitspigot-server) + * [Running a Paper server](#running-a-paper-server) + * [Running a Tuinity server](#running-a-tuinity-server) + * [Running an Airplane server](#running-an-airplane-server) + * [Running a Purpur server](#running-a-purpur-server) + * [Running a Yatopia server](#running-a-yatopia-server) + * [Running a Magma server](#running-a-magma-server) + * [Running a Mohist server](#running-a-mohist-server) + * [Running a Catserver type server](#running-a-catserver-type-server) + * [Running a server with a Feed the Beast modpack](#running-a-server-with-a-feed-the-beast-modpack) + * [Environment Variables:](#environment-variables) + * [Upgrading](#upgrading) + * [Example](#example) + * [Running a server with a CurseForge modpack](#running-a-server-with-a-curseforge-modpack) + * [Modpack data directory](#modpack-data-directory) + * [Buggy start scripts](#buggy-start-scripts) + * [Fixing "unable to launch forgemodloader"](#fixing-unable-to-launch-forgemodloader) + * [Running a SpongeVanilla server](#running-a-spongevanilla-server) + * [Running a Fabric Server](#running-a-fabric-server) + * [Using the /data volume](#using-the-data-volume) + * [Optional plugins, mods, and config attach points](#optional-plugins-mods-and-config-attach-points) + * [Auto-downloading SpigotMC/Bukkit/PaperMC plugins](#auto-downloading-spigotmcbukkitpapermc-plugins) + * [Replacing variables inside configs](#replacing-variables-inside-configs) + * [Running with a custom server JAR](#running-with-a-custom-server-jar) + * [Force re-download of the server file](#force-re-download-of-the-server-file) + * [Using Docker Compose](#using-docker-compose) + * [Server configuration](#server-configuration) + * [Server name](#server-name) + * [Server port](#server-port) + * [Difficulty](#difficulty) + * [Whitelist Players](#whitelist-players) + * [Op/Administrator Players](#opadministrator-players) + * [Server icon](#server-icon) + * [Rcon](#rcon) + * [Query](#query) + * [Max players](#max-players) + * [Max world size](#max-world-size) + * [Allow Nether](#allow-nether) + * [Announce Player Achievements](#announce-player-achievements) + * [Enable Command Block](#enable-command-block) + * [Force Gamemode](#force-gamemode) + * [Generate Structures](#generate-structures) + * [Hardcore](#hardcore) + * [Snooper](#snooper) + * [Max Build Height](#max-build-height) + * [Max Tick Time](#max-tick-time) + * [Spawn Animals](#spawn-animals) + * [Spawn Monsters](#spawn-monsters) + * [Spawn NPCs](#spawn-npcs) + * [Set spawn protection](#set-spawn-protection) + * [View Distance](#view-distance) + * [Level Seed](#level-seed) + * [Game Mode](#game-mode) + * [Message of the Day](#message-of-the-day) + * [PVP Mode](#pvp-mode) + * [Level Type and Generator Settings](#level-type-and-generator-settings) + * [Custom Server Resource Pack](#custom-server-resource-pack) + * [World Save Name](#world-save-name) + * [Downloadable world](#downloadable-world) + * [Cloning world from a container path](#cloning-world-from-a-container-path) + * [Overwrite world on start](#overwrite-world-on-start) + * [Downloadable mod/plugin pack for Forge, Bukkit, and Spigot Servers](#downloadable-modplugin-pack-for-forge-bukkit-and-spigot-servers) + * [Remove old mods/plugins](#remove-old-modsplugins) + * [Online mode](#online-mode) + * [Allow flight](#allow-flight) + * [Other server property mappings](#other-server-property-mappings) + * [Miscellaneous Options](#miscellaneous-options) + * [Running as alternate user/group ID](#running-as-alternate-usergroup-id) + * [Memory Limit](#memory-limit) + * [JVM Options](#jvm-options) + * [Interactive and Color Console](#interactive-and-color-console) + * [OpenJ9 Specific Options](#openj9-specific-options) + * [Enabling rolling logs](#enabling-rolling-logs) + * [Timezone Configuration](#timezone-configuration) + * [Enable Remote JMX for Profiling](#enable-remote-jmx-for-profiling) + * [Enable Aikar's Flags](#enable-aikars-flags) + * [HTTP Proxy](#http-proxy) + * [Using "noconsole" option](#using-noconsole-option) + * [Explicitly disable GUI](#explicitly-disable-gui) + * [Stop Duration](#stop-duration) + * [Autopause](#autopause) + * [Description](#description) + * [Enabling Autopause](#enabling-autopause) + * [Running on RaspberryPi](#running-on-raspberrypi) + + + ## Looking for a Bedrock Dedicated Server diff --git a/gh-md-toc b/gh-md-toc new file mode 100755 index 00000000..ef389e71 --- /dev/null +++ b/gh-md-toc @@ -0,0 +1,361 @@ +#!/usr/bin/env bash + +# +# Steps: +# +# 1. Download corresponding html file for some README.md: +# curl -s $1 +# +# 2. Discard rows where no substring 'user-content-' (github's markup): +# awk '/user-content-/ { ... +# +# 3.1 Get last number in each row like ' ... sitemap.js.*<\/h/)+2, RLENGTH-5) +# +# 5. Find anchor and insert it inside "(...)": +# substr($0, match($0, "href=\"[^\"]+?\" ")+6, RLENGTH-8) +# + +gh_toc_version="0.7.0" + +gh_user_agent="gh-md-toc v$gh_toc_version" + +# +# Download rendered into html README.md by its url. +# +# +gh_toc_load() { + local gh_url=$1 + + if type curl &>/dev/null; then + curl --user-agent "$gh_user_agent" -s "$gh_url" + elif type wget &>/dev/null; then + wget --user-agent="$gh_user_agent" -qO- "$gh_url" + else + echo "Please, install 'curl' or 'wget' and try again." + exit 1 + fi +} + +# +# Converts local md file into html by GitHub +# +# -> curl -X POST --data '{"text": "Hello world github/linguist#1 **cool**, and #1!"}' https://api.github.com/markdown +#
Hello world github/linguist#1 cool, and #1!
'" +gh_toc_md2html() { + local gh_file_md=$1 + URL=https://api.github.com/markdown/raw + + if [ ! -z "$GH_TOC_TOKEN" ]; then + TOKEN=$GH_TOC_TOKEN + else + TOKEN_FILE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt" + if [ -f "$TOKEN_FILE" ]; then + TOKEN="$(cat $TOKEN_FILE)" + fi + fi + if [ ! -z "${TOKEN}" ]; then + AUTHORIZATION="Authorization: token ${TOKEN}" + fi + + # echo $URL 1>&2 + OUTPUT=$(curl -s \ + --user-agent "$gh_user_agent" \ + --data-binary @"$gh_file_md" \ + -H "Content-Type:text/plain" \ + -H "$AUTHORIZATION" \ + "$URL") + + if [ "$?" != "0" ]; then + echo "XXNetworkErrorXX" + fi + if [ "$(echo "${OUTPUT}" | awk '/API rate limit exceeded/')" != "" ]; then + echo "XXRateLimitXX" + else + echo "${OUTPUT}" + fi +} + + +# +# Is passed string url +# +gh_is_url() { + case $1 in + https* | http*) + echo "yes";; + *) + echo "no";; + esac +} + +# +# TOC generator +# +gh_toc(){ + local gh_src=$1 + local gh_src_copy=$1 + local gh_ttl_docs=$2 + local need_replace=$3 + local no_backup=$4 + local no_footer=$5 + + if [ "$gh_src" = "" ]; then + echo "Please, enter URL or local path for a README.md" + exit 1 + fi + + + # Show "TOC" string only if working with one document + if [ "$gh_ttl_docs" = "1" ]; then + + echo "Table of Contents" + echo "=================" + echo "" + gh_src_copy="" + + fi + + if [ "$(gh_is_url "$gh_src")" == "yes" ]; then + gh_toc_load "$gh_src" | gh_toc_grab "$gh_src_copy" + if [ "${PIPESTATUS[0]}" != "0" ]; then + echo "Could not load remote document." + echo "Please check your url or network connectivity" + exit 1 + fi + if [ "$need_replace" = "yes" ]; then + echo + echo "!! '$gh_src' is not a local file" + echo "!! Can't insert the TOC into it." + echo + fi + else + local rawhtml=$(gh_toc_md2html "$gh_src") + if [ "$rawhtml" == "XXNetworkErrorXX" ]; then + echo "Parsing local markdown file requires access to github API" + echo "Please make sure curl is installed and check your network connectivity" + exit 1 + fi + if [ "$rawhtml" == "XXRateLimitXX" ]; then + echo "Parsing local markdown file requires access to github API" + echo "Error: You exceeded the hourly limit. See: https://developer.github.com/v3/#rate-limiting" + TOKEN_FILE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt" + echo "or place GitHub auth token here: ${TOKEN_FILE}" + exit 1 + fi + local toc=`echo "$rawhtml" | gh_toc_grab "$gh_src_copy"` + echo "$toc" + if [ "$need_replace" = "yes" ]; then + if grep -Fxq "" $gh_src && grep -Fxq "" $gh_src; then + echo "Found markers" + else + echo "You don't have or in your file...exiting" + exit 1 + fi + local ts="<\!--ts-->" + local te="<\!--te-->" + local dt=`date +'%F_%H%M%S'` + local ext=".orig.${dt}" + local toc_path="${gh_src}.toc.${dt}" + local toc_footer="" + # http://fahdshariff.blogspot.ru/2012/12/sed-mutli-line-replacement-between-two.html + # clear old TOC + sed -i${ext} "/${ts}/,/${te}/{//!d;}" "$gh_src" + # create toc file + echo "${toc}" > "${toc_path}" + if [ "${no_footer}" != "yes" ]; then + echo -e "\n${toc_footer}\n" >> "$toc_path" + fi + + # insert toc file + if [[ "`uname`" == "Darwin" ]]; then + sed -i "" "/${ts}/r ${toc_path}" "$gh_src" + else + sed -i "/${ts}/r ${toc_path}" "$gh_src" + fi + echo + if [ "${no_backup}" = "yes" ]; then + rm ${toc_path} ${gh_src}${ext} + fi + echo "!! TOC was added into: '$gh_src'" + if [ -z "${no_backup}" ]; then + echo "!! Origin version of the file: '${gh_src}${ext}'" + echo "!! TOC added into a separate file: '${toc_path}'" + fi + echo + fi + fi +} + +# +# Grabber of the TOC from rendered html +# +# $1 - a source url of document. +# It's need if TOC is generated for multiple documents. +# +gh_toc_grab() { + common_awk_script=' + modified_href = "" + split(href, chars, "") + for (i=1;i <= length(href); i++) { + c = chars[i] + res = "" + if (c == "+") { + res = " " + } else { + if (c == "%") { + res = "\\x" + } else { + res = c "" + } + } + modified_href = modified_href res + } + print sprintf("%*s", (level-1)*3, "") "* [" text "](" gh_url modified_href ")" + ' + if [ `uname -s` == "OS/390" ]; then + grepcmd="pcregrep -o" + echoargs="" + awkscript='{ + level = substr($0, length($0), 1) + text = substr($0, match($0, /a>.*<\/h/)+2, RLENGTH-5) + href = substr($0, match($0, "href=\"([^\"]+)?\"")+6, RLENGTH-7) + '"$common_awk_script"' + }' + else + grepcmd="grep -Eo" + echoargs="-e" + awkscript='{ + level = substr($0, length($0), 1) + text = substr($0, match($0, /a>.*<\/h/)+2, RLENGTH-5) + href = substr($0, match($0, "href=\"[^\"]+?\"")+6, RLENGTH-7) + '"$common_awk_script"' + }' + fi + href_regex='href=\"[^\"]+?\"' + + # if closedfoo1
+ #
+ # became: The command foo1
+ sed -e ':a' -e 'N' -e '$!ba' -e 's/\n<\/h/<\/h/g' |
+
+ # find strings that corresponds to template
+ $grepcmd '