How to install MineOS-node in a jail (alternative to using the MineOS plugin)

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
@Jimstein Perrless I apologize, you are right. But I swear the setting was in the UI. There used to be a lot more options, IIRC in "Custom Properties". Does anybody still have access to an 11.3 or older system for a quick check?
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Have you read their reply? This is ridiculous. They had a perfectly working feature and simply dropped it for no reason. It's labelled "Custom Properties" for crying out loud. :mad:

And this reads like a threat:
We don't plan on making any more changes to the UI for Jails in CORE.

So CORE is dead, then, because there will not be any new feature related to jails ever?
 
Joined
Jul 10, 2016
Messages
521
I reported the same a while ago, but just like @Patrick M. Hausen 's ticket it was unceremoniously closed. My ticket was:


I still run an instance of FreeNAS-11.3-U5. These are under "Jail Properties"
  • mount_devfs
  • mount_fdescfs
These are under "Custom Properties" in FreeNAS-11.3-U5
  • mount_procfs
  • mount_linprocfs
 

andre-geert

Cadet
Joined
Dec 2, 2017
Messages
2
Hey Jurgen,

Firstly, just wanted to say thanks a bunch for staying active on this thread. I dabble in Minecraft hosting once in a blue moon, and this thread has been a go-to lifesaver for many years now thanks to your continued support.

This morning I wanted to start a server for 1.17-rc1, and it seems that you now need Java 16 to run Minecraft >= 1.17.

Code:
pkg search
seems to indicate that there is no JRE available for Java 16 from OpenJDK; is installing the whole JDK the best way to upgrade?

Thanks again!
 
Joined
Jul 10, 2016
Messages
521
Thanks for letting me know! I did recently up the java version from 8 to 11 for that same reason.

Looks like openjdk16 is available; that should work.
 

jzdm

Cadet
Joined
Sep 16, 2017
Messages
8
Thank you for the installation instructions, this helped a lot on a FreeBSD 12.2 jail.
Unfortunately the web UI seems to be broken, see image.
Any suggestions on how to resolve this?
CleanShot 2021-06-11 at 09.37.18.png
 
Joined
Jul 10, 2016
Messages
521
Check that mount_fdescfs, mount_procfs and mount_linprocfs are set and SHIFT-refresh the page.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Check that mount_fdescfs, mount_procfs and mount_linprocfs are set and SHIFT-refresh the page.
These are gone from the UI, now. You will probably need to use iocage set ...
 
Joined
Jul 10, 2016
Messages
521
You will probably need to use iocage set ...

Thanks, Patrick. The first post lists these commands, but indeed also refers to the infamous checkboxes that no longer exist. :frown:
mount_fdescfs is on by default, so it's not listed.
 

jzdm

Cadet
Joined
Sep 16, 2017
Messages
8
Check that mount_fdescfs, mount_procfs and mount_linprocfs are set and SHIFT-refresh the page.

Yes, they are set. Outside the jail:
Code:
$ iocage get -a mcserver | grep ^mount
mount_devfs:1
mount_fdescfs:1
mount_linprocfs:1
mount_procfs:1
mountpoint:readonly

Inside the jail:
Code:
$ mount -l
Media/iocage/jails/mcserver/root on / (zfs, local, nfsv4acls)
procfs on /proc (procfs, local)
linprocfs on /compat/linux/proc (linprocfs, local)
devfs on /dev (devfs, local, multilabel)
fdescfs on /dev/fd (fdescfs)


Software versions are npm 6.14.8, node v15.14.0, openjdk version "16", freebsd-version 12.2-RELEASE-p6, mineos-node is on commit b2ce276c212170da1a24549d1e2b066ccf62f3a8, from May 26 (currently the latest one).
Shift reload, switching browser, using private browsing dit not help. I cannot click any link on the page.
 
Joined
Jul 10, 2016
Messages
521
Anything interesting in /var/log/mineos.log inside the jail?

The MineOS plugin is using node v16.2.0, and the "latest" pkg repo, where by default standard jails are using "quarterly".
Did try with "latest", or the plugin (it was just updated yesterday)?
 

jzdm

Cadet
Joined
Sep 16, 2017
Messages
8
Anything interesting in /var/log/mineos.log inside the jail?

The MineOS plugin is using node v16.2.0, and the "latest" pkg repo, where by default standard jails are using "quarterly".
Did try with "latest", or the plugin (it was just updated yesterday)?
Thank you! It seems to me that this helped. I changed to "latest" pkg repo and updated all packages. node is now in version v16.2.0.
I then removed the git repo from /usr/local/games/minecraft, checked it out again and built/downloaded the npm packages as instructed.
Now the server seems to run.
Only thing was that the latest BuildTools cannot be downloaded via the web UI, instead I needed to download them manually to /var/games/minecraft/profiles/BuildTools-latest.


Edit:
The only problem with Java 16 is, that it does not bind to IPv6. Therefore I am stuck to Minecraft 1.16.5 with OpenJDK 1.8. (But that problem is most likely off-topic here)
 
Last edited:

chravis

Contributor
Joined
Jan 27, 2019
Messages
104
Would anyone be able to help me with the syntax for putting all of this info into a .sh script? I'm not all that fluent in my scripting syntax, but I'm trying. This start of the script isn't quite right. Part of what's wrong is the mount point at the end. The first page of this thread says to create /usr/local/games (and subsequently /usr/local/games/minecraft is created) but then it suggests creating a mountpoint to /var/games/minecraft, but that's not where the minecraft folder is.

Code:
#!/bin/sh

JAILNAME=mineos
JAILDIR=/mnt/tank/iocage/jails/$JAILNAME/root
DATADIR=/mnt/tank/mineosdata

echo '{"pkgs":["py37-rdiff-backup","rsync","gmake","screen","git-lite","python37","py37-supervisor","node","npm","openjdk16","wget","bash","nano"]}' > /tmp/pkg.json
iocage create -n $JAILNAME -p /tmp/pkg.json -r 12.2-RELEASE ip4_addr="vnet0|192.168.1.14/24" defaultrouter="192.168.1.1" vnet="on" allow_raw_sockets="1" boot="on"
iocage set mount_procfs=1 $JAILNAME
iocage set mount_linprocfs=1 $JAILNAME
rm /tmp/pkg.json

mkdir -p $JAILDIR/usr/compat/linux/proc
mkdir -p $JAILDIR/usr/local/games
cd $JAILDIR/usr/local/games && git clone git://github.com/hexparrot/mineos-node minecraft
cd $JAILDIR/usr/local/games/minecraft && chmod +x *.sh && ./generate-sslcert.sh
cd $JAILDIR/usr/local/games/minecraft && cp mineos.conf /etc/mineos.conf
cd $JAILDIR/usr/local/games/minecraft && npm install jsegaert/node-userid
cd $JAILDIR/usr/local/games/minecraft && echo "CXX=c++ npm install" | sh

iocage exec $JAILNAME "cat /usr/local/games/minecraft/init/supervisor_conf.bsd >> /usr/local/etc/supervisord.conf"
iocage exec $JAILNAME "sysrc supervisord_enable=YES"
iocage exec $JAILNAME "service supervisord start"

iocage exec $JAILNAME "pw user add -n mcserver -G games,wheel -d /home/mcserver -m -s /usr/local/bin/bash -w yes"

iocage fstab -a $JAILNAME "$DATADIR /var/games/minecraft nullfs rw 0 0"
 
Joined
Jul 10, 2016
Messages
521
The first page of this thread says to create /usr/local/games (and subsequently /usr/local/games/minecraft is created) but then it suggests creating a mountpoint to /var/games/minecraft, but that's not where the minecraft folder is.

The mineos application itself is installed in /usr/local/games/minecraft and the minecraft server data it will generate lives in /var/games/minecraft

Some other remarks:
  • Revamp the $JAILDIR lines. Once you created your jail with the desired packages, run all subsequent commands inside your jail with iocage exec. As a reference, look at the plugin's post-install script.
  • Adding user mcserver to the wheel group is not needed and might make things less secure.
 

chravis

Contributor
Joined
Jan 27, 2019
Messages
104
Thanks @Jurgen Segaert. I've made some changes but having a problem executing chmod inside the script. I'm not positive which directory I'm supposed to be in. Also, in the instruction in this thread we create the directory "/usr/compat/linux/proc" and then we start the service with something like:
Code:
iocage exec $JAILNAME "cat /usr/local/games/minecraft/init/supervisor_conf.bsd >> /usr/local/etc/supervisord.conf"
iocage exec $JAILNAME "sysrc supervisord_enable=YES"
iocage exec $JAILNAME "service supervisord start"

However, in the post-install script you referenced, I don't see it creating the directory /usr/compat/linux/proc and it enables and starts the service like this:
Code:
# Enable the service
chmod +x *.sh
chmod +x /usr/local/etc/rc.d/mineos
sysrc -f /etc/rc.conf mineos_enable="YES"

# Start the service
service mineos start

I'm having trouble following what is actually needed.
I attempted this:
Code:
echo "Enable the service"
iocage exec $JAILNAME "chmod +x *.sh"
iocage exec $JAILNAME "chmod +x /usr/local/etc/rc.d/mineos"
iocage exec $JAILNAME "sysrc -f /etc/rc.conf mineos_enable=YES"

echo "Start the service"
iocage exec $JAILNAME "service mineos start"

which results in:
Code:
Enable the service
chmod: *.sh: No such file or directory
Command: /bin/sh -c chmod +x *.sh failed!
chmod: /usr/local/etc/rc.d/mineos: No such file or directory
Command: /bin/sh -c chmod +x /usr/local/etc/rc.d/mineos failed!
mineos_enable:  -> YES
Start the service
mineos does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d), or is not executable
Command: /bin/sh -c service mineos start failed!
 

chravis

Contributor
Joined
Jan 27, 2019
Messages
104
I managed to get the MC server up and running in the jail but I used 2 scripts. I know I could probably use one, but this works (almost).
The first script sets up the jail and then copies the second script over to the jail and executes it. After that, I attempt to set up the mount point. That is the part that fails with:
Code:
Destination: /mnt/tank/iocage/jails/mineos/root/var/games/minecraft does not exist or is not a directory.

but the folder does in fact exist. I believe this folder is created when the server starts up (?) so maybe it is a timing thing and just hasn't been created yet by the time I try to create the mount point?

Script 1:
Code:
#!/bin/sh

JAILNAME=mineos
JAILDIR=/mnt/tank/iocage/jails/$JAILNAME/root
SCRIPT2=BuildMineosJailPart2.sh
DATADIR=/mnt/tank/mineosdata


echo "Create the jail"
echo '{"pkgs":["py37-rdiff-backup","rsync","gmake","screen","git-lite","python37","py37-supervisor","node","npm","openjdk16","wget","bash","nano"]}' > /tmp/pkg.json
#iocage create -n $JAILNAME -r 12.2-RELEASE ip4_addr="vnet0|192.168.1.14/24" defaultrouter="192.168.1.1" vnet="on" allow_raw_sockets="1" boot="on"
iocage create -n $JAILNAME -p /tmp/pkg.json -r 12.2-RELEASE ip4_addr="vnet0|192.168.1.14/24" defaultrouter="192.168.1.1" vnet="on" allow_raw_sockets="1" boot="on"
iocage set mount_procfs=1 $JAILNAME
iocage set mount_linprocfs=1 $JAILNAME
rm /tmp/pkg.json

echo "Copy Part2 script to the jail"
cp $SCRIPT2 $JAILDIR/tmp

echo "Execute the Part2 script"
iocage exec $JAILNAME sh tmp/$SCRIPT2

echo "Remove Part2 script"
rm $JAILDIR/tmp/$SCRIPT2

echo "Add the mount point (will fail if script 2 failed)"
iocage fstab -a $JAILNAME "$DATADIR /var/games/minecraft nullfs rw 0 0"


Script 2:
Code:
#!/bin/sh

echo "Make directories"
mkdir -p /usr/compat/linux/proc
mkdir -p /usr/local/games
#mkdir -p /usr/local/etc/rc.d

echo "Clone source from official MineOS repository"
cd /usr/local/games
git clone git://github.com/hexparrot/mineos-node minecraft
if [ $? -ne 0 ] ; then
  echo "ERROR: Failed to get source from MineOS Repository"
  exit 1
fi

cd minecraft

echo "Generate Certificates"
chmod +x *.sh
if [ ! -f "/etc/ssl/certs/mineos.crt" ] ; then
  ./generate-sslcert.sh > /dev/null 2>&1
fi
echo

echo "Create configuration file (without https)"
if [ ! -f "/etc/mineos.conf" ] ; then
  # Option #1: Create standard configuration file
  # cp mineos.conf /etc/mineos.conf
  # Option #2: use http instead of the standard https
  sed 's/^use_https.*/use_https = false/' mineos.conf > /etc/mineos.conf
fi

echo "Install patched version of node-userid"
npm install jsegaert/node-userid

echo "Build"
echo "CXX=c++ npm install" | sh

#echo "Enable the service"
#chmod +x *.sh
#chmod +x /usr/local/etc/rc.d/mineos
#sysrc -f /etc/rc.conf mineos_enable="YES"

#echo "Start the service"
#service mineos start

#service mineos status >/dev/null 2>&1
#if [ $? -ne 0 ] ; then
#  echo "ERROR: Failed to start service"
#  exit 1
#fi

#echo

echo "Startup MineOS-node when jail starts and start the service"

cat /usr/local/games/minecraft/init/supervisor_conf.bsd >> /usr/local/etc/supervisord.conf
sysrc supervisord_enable="YES"
service supervisord start

echo "Create mcserver user account"
#not sure if these result in the same thing or not
#pw user add -n mcserver -u 199 -G games -d /nonexistent -m -s /usr/local/bin/bash -w yes
pw useradd -n mcserver -u 199 -G games -d /nonexistent -s /usr/local/bin/bash -h 0 <<EOF
mcserver
EOF



I'm also not sure why when I log into the server, it says "Uptime 13 days" when it's a brand new server.

Update: even though I can log in to the server gui with mcserver, I can create a server but I can't start it. There are no error logs or anything that I can find. It just doesn't do anything when I press the start button (after accepting the EULA).
 
Last edited:
Top