FreeBSD10 enderman

From wikinotes
Revision as of 16:48, 1 October 2016 by Will (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Enderman is my personal minecraft server. After the mishaps last time while using dropbox as an in-between to store my savegame so I could login from anywhere it occurred to me that there is absolutely no reason at all why I wouldn't just host it on my server. It's just sitting there anyways, and then it's easily connected to from any machine I like, no matter what OS I'm running. Clearly, the way to go.

Install

Base System

sudo jexec enderman /bin/csh

pkg install bash zsh git tmux openssh-portable sudo vim gnuls minecraft-server
adduser will
adduser minecraft						## make sure to create a home directory for minecraft
visudo

#### /etc/ssh/sshd_config
Port 8610
# you're definitely going to want to change the seed/levelname.
# the default gives you a horrible waterworld.
####

#### /etc/rc.conf
sshd_enable="YES"
minecraft_enable="YES"
####
service sshd start

ssh -p 8610 will@enderman
mkdir progs; cd progs
git clone ssh://git@192.168.1.202:8610/home/git/bash
git clone ssh://git@192.168.1.202:8610/home/git/progs

minecraft config

#### /usr/local/etc/minecraft-server/eula.txt
eula=true
####
#### /usr/local/etc/minecraft-server/server.properties
server-port=8611
####

Service File

#!/usr/bin/env sh
#
# $FreeBSD: head/games/mcserver/files/minecraft.in 399340 2015-10-15 14:14:21Z mat $
# PROVIDE: minecraft
# REQUIRE: DAEMON
# KEYWORD: shutdown

. /etc/rc.subr

#### Debug Mode
#set -xv
#exec 1>/tmp/output.txt 2>&1
####

name="minecraft"
rcvar="minecraft_enable"
pidfile="/var/run/minecraft-server.pid"         ## status/stop reads this pidfile
minecraft_chdir="/usr/local/minecraft-server"   ## cwd of run command


#### rc.conf
load_rc_config $name
: ${minecraft_runuser:=mcserver}



# ==========
# Functions
# ==========


is_running() {
   if [ -f $pidfile ] ; then
      pgrep -F $pidfile
      return $?
   fi

   return 1
}


minecraft_status() {
   if is_running; then
      echo "${name} is running."
   else
      echo "${name} is not running."
   fi
}

minecraft_stop() {
   if is_running; then
      echo "Stopping ${name}."
      kill -15 `cat $pidfile`
   else
      echo "${name} is not running."
   fi
}



# =======================
# CLI Interface & Command
# =======================

## non default commands
status_cmd=minecraft_status
stop_cmd=minecraft_stop


command="/usr/sbin/daemon"
configured_args="$(cat /usr/local/etc/minecraft-server/java-args.txt)"
command_args="-u $minecraft_runuser -f -p $pidfile /usr/local/bin/java $configured_args -jar minecraft_server.1.9.2.jar nogui"


run_rc_command "$1"

Restarting world

/usr/local/minecraft-server/<worldname>			## worlds are stored in a folder
																## delete and change seed in /usr/local/etc/minecraft-server/server.config