Compare commits
2 Commits
1f244b9953
...
c4be2a8e52
Author | SHA1 | Date |
---|---|---|
ida schmidt | c4be2a8e52 | |
ida schmidt | 47546ee248 |
|
@ -1,8 +1,8 @@
|
|||
# auto-mc
|
||||
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`.
|
||||
while i wrote this with ubuntu in mind, i dont see why it wouldnt work on any debian based distro.
|
||||
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`.
|
||||
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
|
||||
to install, do:
|
||||
|
|
12
automate.sh
12
automate.sh
|
@ -16,7 +16,7 @@ function versionprompt {
|
|||
# ask the user which version of minecraft they would like to install
|
||||
echo "which version of minecraft would you like to serve?"
|
||||
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
|
||||
echo "timed out, defaulting to $LATEST..."
|
||||
return 0
|
||||
|
@ -36,11 +36,11 @@ function 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
|
||||
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
|
||||
apt install openjdk-16-jre-headless
|
||||
apt install -y openjdk-16-jre-headless
|
||||
else
|
||||
apt install default-jre-headless
|
||||
apt install -y default-jre-headless
|
||||
fi
|
||||
|
||||
# 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]`
|
||||
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
|
||||
chmod 755 systemd/mc-backup
|
||||
mkdir -p /srv/minecraft/
|
||||
|
@ -68,7 +68,7 @@ su mc -c \
|
|||
cp paperclip.jar /srv/minecraft/server/
|
||||
echo "eula=true" > /srv/minecraft/server/eula.txt"
|
||||
|
||||
# what they says on the tin
|
||||
# what they say on the tin
|
||||
echo "loading units..."
|
||||
systemctl daemon-reload
|
||||
|
||||
|
|
Loading…
Reference in New Issue