2021-06-15 10:26:26 +02:00
|
|
|
#!/bin/bash
|
2019-11-23 17:40:03 +01:00
|
|
|
|
|
|
|
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}
|
2020-06-25 11:23:11 +02:00
|
|
|
TAG=${TAG:-gwh}
|
2019-11-23 17:40:03 +01:00
|
|
|
|
|
|
|
TMP=${TMP:-/tmp/$TAG}
|
|
|
|
PKG=$TMP/pkg-$PRGNAM
|
|
|
|
OUTPUT=${OUTPUT:-/tmp}
|
|
|
|
PREFIX=/usr
|
|
|
|
|
2022-01-22 19:52:02 +01:00
|
|
|
REPOSITORY=${REPOSITORY:-/home/installs/SlackBuilds/_repositories/$PRGNAM}
|
2021-09-29 13:11:33 +02:00
|
|
|
|
|
|
|
mkdir -p $REPOSITORY
|
|
|
|
|
|
|
|
[ ! -e $REPOSITORY/${PRGNAM}-${VERSION}.jar ] && wget -c $(curl https://www.minecraft.net/en-us/download/server | grep -o "https.*server\.jar") -O $REPOSITORY/${PRGNAM}-${VERSION}.jar
|
2019-11-23 17:40:03 +01:00
|
|
|
|
|
|
|
rm -fr $PKG
|
|
|
|
|
|
|
|
mkdir -p $PKG/opt/$PRGNAM
|
2021-09-29 13:11:33 +02:00
|
|
|
cp $REPOSITORY/${PRGNAM}-${VERSION}.jar $PKG/opt/$PRGNAM/$PRGNAM.jar
|
2019-11-23 17:40:03 +01:00
|
|
|
cat <<EOF > $PKG/opt/$PRGNAM/start.sh
|
2021-06-15 10:26:26 +02:00
|
|
|
#!/bin/bash
|
2019-11-23 17:40:03 +01:00
|
|
|
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 <<EOF > $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 <<EOF > $PKG/install/doinst.sh
|
2021-06-15 10:26:26 +02:00
|
|
|
#!/bin/bash
|
2019-11-23 17:40:03 +01:00
|
|
|
[ ! -e /opt/$PRGNAM/eula.txt ] && /etc/rc.d/rc.$PRGNAM start
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat <<EOF > $PKG/install/slack-desc
|
|
|
|
|-----handy-ruler--------------------------------------------------------|
|
|
|
|
$PRGNAM: $PRGNAM (Proprietary Minecraft Server)
|
|
|
|
$PRGNAM:
|
|
|
|
$PRGNAM:
|
2021-09-29 13:11:33 +02:00
|
|
|
$PRGNAM:
|
|
|
|
$PRGNAM:
|
|
|
|
$PRGNAM:
|
2019-11-23 17:40:03 +01:00
|
|
|
$PRGNAM: https://www.minecraft.net/en-us/download/server/
|
|
|
|
$PRGNAM:
|
|
|
|
$PRGNAM:
|
2021-09-29 13:11:33 +02:00
|
|
|
$PRGNAM:
|
2019-11-23 17:40:03 +01:00
|
|
|
$PRGNAM:
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cd $PKG
|
|
|
|
rm -f $PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la
|
|
|
|
|
2023-08-16 12:23:26 +02:00
|
|
|
/sbin/makepkg --linkadd y --chown n --prepend $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.txz
|