diff --git a/n/minecraft-server/SlackBuild b/n/minecraft-server/SlackBuild new file mode 100755 index 00000000..e0efdcd3 --- /dev/null +++ b/n/minecraft-server/SlackBuild @@ -0,0 +1,106 @@ +#!/bin/sh + +CWD=$(pwd) + +# Check if the minecraft user and group exist. If not, then bail. +if [ "$(id -g minecraft 2> /dev/null)" != "987" -o "$(id -u minecraft 2> /dev/null)" != "987" ]; then + echo " You must have an 'minecraft' user and group to run this script." + echo " # groupadd -g 987 minecraft" + echo " # useradd -d /opt/$PRGNAM -g minecraft -s /bin/bash -u 987 minecraft --system " + exit 1 +fi + +PRGNAM=$(basename $CWD) +VERSION=${VERSION:-$(curl https://www.minecraft.net/en-us/download/server | grep "minecraft_server.*\.jar" -o | grep -o "[0-9][0-9.]*[0-9]" | head -n1)} +ARCH=${ARCH:-$(uname -m)} +BUILD=${BUILD:-1} +TAG=${TAG:-cyco} + +TMP=${TMP:-/tmp/$TAG} +PKG=$TMP/pkg-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} +PREFIX=/usr + +wget -c $(curl https://www.minecraft.net/en-us/download/server | grep -o "https.*server\.jar") -O $CWD/$PRGNAM.jar + +rm -fr $PKG + +mkdir -p $PKG/opt/$PRGNAM +mv $CWD/$PRGNAM.jar $PKG/opt/$PRGNAM/$PRGNAM.jar +cat < $PKG/opt/$PRGNAM/start.sh +#!/bin/sh +java -Xms1G -Xmx1G -jar /opt/$PRGNAM/$PRGNAM.jar nogui +EOF +chmod +x $PKG/opt/$PRGNAM/start.sh +chown -R minecraft:minecraft $PKG/opt/$PRGNAM/ + +mkdir -p $PKG/etc/rc.d/ +cat < $PKG/etc/rc.d/rc.$PRGNAM +#!/bin/bash +#Slackware startup deamon script + +# Name of Service +NAME="Minecraft Daemon" + +# user used to run the daemon +USERNAME=minecraft + +PIDFILE=/var/run/minecraft.pid + +func_stop() { + [ -e \$PIDFILE ] && kill \$(cat \$PIDFILE) && rm \$PIDFILE +} + +func_start() { + echo -n "Starting \$NAME ... " + su - \$USERNAME -c /opt/$PRGNAM/start.sh & + echo $! > \$PIDFILE +} + + +case \$1 in + "start") + func_start + ;; + + "stop") + func_stop + ;; + + "restart") + func_stop + sleep 2 + func_start + ;; + *) + echo "Usage; start|stop|restart" + ;; +esac +EOF +chmod +x $PKG/etc/rc.d/rc.$PRGNAM + +mkdir -p $PKG/install +cat < $PKG/install/doinst.sh +#!/bin/sh +[ ! -e /opt/$PRGNAM/eula.txt ] && /etc/rc.d/rc.$PRGNAM start +EOF + +cat < $PKG/install/slack-desc + |-----handy-ruler--------------------------------------------------------| +$PRGNAM: $PRGNAM (Proprietary Minecraft Server) +$PRGNAM: +$PRGNAM: +$PRGNAM: +$PRGNAM: +$PRGNAM: +$PRGNAM: https://www.minecraft.net/en-us/download/server/ +$PRGNAM: +$PRGNAM: +$PRGNAM: +$PRGNAM: +EOF + +cd $PKG +rm -f $PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la + +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.txz