Compare commits

...

2 Commits

Author SHA1 Message Date
ida schmidt c4be2a8e52 update readme 2021-05-31 09:01:41 -07:00
ida schmidt 47546ee248 fix apt prompting for user input 2021-05-31 08:47:04 -07:00
2 changed files with 8 additions and 8 deletions

View File

@ -1,8 +1,8 @@
# auto-mc # auto-mc
automate automation for minecraft servers. automate automation for minecraft servers.
this is just a few systemd units and a backup script that auto install, the server runs inside a gnu `screen` session controlled by the user `mc`. this is an installer for the minecraft server (paper), with a few systemd units and a backup script. the server runs inside a gnu `screen` session controlled by the user `mc`.
while i wrote this with ubuntu in mind, i dont see why it wouldnt work on any debian based distro. it works best on ubuntu 20.04+ because of java versioning, but any distro with `apt` (and a version of openjdk >=16 for 1.17+ installs) should work fine.
# installation # installation
to install, do: to install, do:

View File

@ -16,7 +16,7 @@ function versionprompt {
# ask the user which version of minecraft they would like to install # ask the user which version of minecraft they would like to install
echo "which version of minecraft would you like to serve?" echo "which version of minecraft would you like to serve?"
echo -n "version [$LATEST]:" echo -n "version [$LATEST]:"
if ! read -t 60 VERSION; then # have a timeout for user input handy for unattented installs if ! read -t 30 VERSION; then # have a timeout for user input handy for unattented installs
VERSION=$LATEST VERSION=$LATEST
echo "timed out, defaulting to $LATEST..." echo "timed out, defaulting to $LATEST..."
return 0 return 0
@ -36,11 +36,11 @@ function versionprompt {
versionprompt versionprompt
# this has to be seperate from the first run of apt since java versions before 16 is deprecated for minecraft 1.17+ and java 16 is quite new # this has to be seperate from the first run of apt since java versions before 16 is deprecated for minecraft 1.17+ and java 16 is quite new
echo "downloading java..." echo "installing java..."
if printf '%s\n' 1.16.5 $VERSION | sort -VC; then # check if $VERSION is above 1.16.5 if printf '%s\n' 1.16.5 $VERSION | sort -VC; then # check if $VERSION is above 1.16.5
apt install openjdk-16-jre-headless apt install -y openjdk-16-jre-headless
else else
apt install default-jre-headless apt install -y default-jre-headless
fi fi
# find the latest release of the requested version and download it # find the latest release of the requested version and download it
@ -48,7 +48,7 @@ echo "downloading minecraft $VERSION..."
RELEASE=`curl -s https://papermc.io/api/v2/projects/paper/versions/$VERSION/ | jq -r .builds[-1]` RELEASE=`curl -s https://papermc.io/api/v2/projects/paper/versions/$VERSION/ | jq -r .builds[-1]`
curl https://papermc.io/api/v2/projects/paper/versions/$VERSION/builds/$RELEASE/downloads/paper-$VERSION-$RELEASE.jar -o paperclip.jar curl https://papermc.io/api/v2/projects/paper/versions/$VERSION/builds/$RELEASE/downloads/paper-$VERSION-$RELEASE.jar -o paperclip.jar
echo "preparing..." # making sure things are clean and have the right owners echo "preparing..." # making sure things have the right owners
adduser --disabled-password --gecos "" mc adduser --disabled-password --gecos "" mc
chmod 755 systemd/mc-backup chmod 755 systemd/mc-backup
mkdir -p /srv/minecraft/ mkdir -p /srv/minecraft/
@ -68,7 +68,7 @@ su mc -c \
cp paperclip.jar /srv/minecraft/server/ cp paperclip.jar /srv/minecraft/server/
echo "eula=true" > /srv/minecraft/server/eula.txt" echo "eula=true" > /srv/minecraft/server/eula.txt"
# what they says on the tin # what they say on the tin
echo "loading units..." echo "loading units..."
systemctl daemon-reload systemctl daemon-reload