Tag Archives: server setup

Server Management for Middle Schoolers Part 3: Ease of Use

I may be crazy, but I know there are some Middle Schoolers who can run a server. So I’m teaching them headless shell management and scripting, all so they can play Minecraft (the carrot, in this case.) They are learning surprisingly well, but then, so am I. I’ve never had to create a fully group setting on Linux, and didn’t anticipate all the issues I’d run in to. Wanting to have 17 kids in an ssh group, with access to a games folder that consistently outputs files they can all use, and allows them to run an instance of Minecraft they can all access… It is a lot to figure out. This series is going to cover the settings I came up with.

Bash Script Startup and Ease of Use

The biggest problem that I knew I was going to have dealt with the running of scripts. Most of these kids had never been exposed to a Linux environment, much less actually dealt with a command line. We were secure shelling in, so there wasn’t a GUI for them to learn and play with, but they had dealt with all of that issue like a champ. Some of them were getting taxed on the amount of commands they had to use, so I didn’t want to burn them out.

The tmux script that I was working with basically did three things. It set up the temp folder for the tmux instance, made sure that the group managed it, and then dropped in to the instance to operate it. The problem was the amount of typing each of these commands took. Individually, they look like this:

tmux -S /tmp/tmuxDirectory new-session -d -s Minecraft
chgrp MyGroupName /tmp/tmuxDirectory
tmux -S /tmp/tmuxDirectory attach-session -t Minecraft

which is a lot to remember for newly minted shell users. So I opted for scripts. Fortunately, these things are easy to write, and simple to use when you teach them.

Taking those commands and working them into a new serverstart.sh file looks nearly identical. I just commented what was happening with each line before I wrote it, for clarity, and threw a hash-bang /bin/bash on the top. Then I noticed I might want a little more abstraction, so I altered the file to pull the directory, the session name, and the group (incase it needed to change for some reason) out of this file. They are represented here by the $CONSTANTS

#! /bin/bash

# Import server configuration
source config.sh

# Abstract tmux code start $CONSTANTS in config.sh
tmux -S $DIR new-session -d -s $SESSION

# Change the group setting of the $DIR
chgrp $GROUP $DIR

# Start the server
echo Starting $SESSION Server Now

And at this point using the tmux ability to pass along keys is important.

tmux -S $DIR send-keys “java -Xmx2048M -Xms1024M -jar minecraft.jar nogui” C-m

obviously, even this code could (and should) be abstracted a little bit.

With all of this set, the only command the kids will need to remember to start the server is the executable ‘./startserver.sh’. So make it executable.

chmod +x startserver.sh

Other Useful Bash Scripts

Besides starting the server, there may be a time your team will need to manage the server, or stop it. Here are those scripts

serveraccess.sh

#! /bin/bash

# load the configuration
source config.sh

# Attach to shared server instance
tmux -S $DIR attach-session -t $SESSION

serverstop.sh

#! /bin/bash

# Load the configuration
source config.sh

# Stop the server
echo Stopping $SESSION Server
tmux -S $DIR send-keys “/stop” C-m

# Wait 5, then kill the Session folder
sleep 5
tmux -S $DIR kill-session -t $SESSION

You could, of course, be much nicer in this script and give players time to log out, but the flavor of that is up to you.

Wrap Up

I’ll be writing an update soon to tell about how these lessons have been received, how they are progressing, and some interesting difficulties with this situation that have arisen.

 

Advertisements