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).