buildpack/bin/start
2018-11-24 23:11:57 +02:00

48 lines
1.4 KiB
Bash
Executable file

#!/bin/bash
shutdown() {
trap - SIGINT SIGTERM
kill -- -$$
}
trap shutdown SIGINT SIGTERM
mkdir -p crash-reports/ dumps/
echo "$PRIVATE_KEY" > .ssh/id_rsa
chmod -R 500 dumps/ plugins/bStats/ plugins/PluginMetrics/ plugins/ProtocolLib/
ssh-keyscan notabug.org >> .ssh/known_hosts
git clone git@notabug.org:kaboom/schematics.git plugins/WorldEdit/schematics/
.bin/tmux new -d -s server 'while true; do
.bin/java/bin/java -Xmx384M -Xss512k -Xaggressive -Xdisablejavadump -Xnoagent -Xquickstart -Xshareclasses -XX:MaxDirectMemorySize=384M -XX:-HeapDumpOnOutOfMemoryError -XX:+IdleTuningGcOnIdle -XX:+UseContainerSupport -Dcom.mojang.eula.agree=true -jar minecraft-server.jar --world-dir=worlds
sleep 1
done'
.bin/tmux new -d -s remote 'while true; do
ssh -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=no -S none -N -T -R 64518:localhost:25565 serv@kaboom.pw
sleep 1
done'
.bin/tmux new -d -s schematics 'while true; do
cd $HOME/plugins/WorldEdit/schematics/
if [ "git status --porcelain" ]; then
git add --all
git -c user.name='kaboom' -c user.email='kaboom' commit -m "Add new schematics"
git push
else
git ls-files -z | xargs -0 git update-index --assume-unchanged
fi
sleep 1
done'
sleep 60
while true; do
sleep 120
if [ "$(echo -n -e '\xFE' | nc -w 5 localhost 25565 | wc -m)" -eq 0 ]; then
kill -9 $(pgrep java)
fi
done &
sleep infinity