Compare commits

...

4 commits

3 changed files with 25 additions and 20 deletions

View file

@ -21,16 +21,9 @@ else
apt install -y default-jre-headless
fi
# find the latest release of the requested version and download it
echo "downloading minecraft $VERSION..."
RELEASE=`curl -s https://api.papermc.io/v2/projects/paper/versions/$VERSION/ | jq -r .builds[-1]`
curl https://api.papermc.io/v2/projects/paper/versions/$VERSION/builds/$RELEASE/downloads/paper-$VERSION-$RELEASE.jar -o paperclip.jar
echo "preparing..." # making sure things have the right owners
adduser --disabled-password --gecos "" mc
mkdir -p /srv/minecraft/
chown -R mc:mc /srv/minecraft/
chown mc:mc paperclip.jar
mkdir -p /srv/minecraft/{server,backups}
cat <<- 'EOF' > /etc/systemd/system/mc-server.service
[Unit]
Description=Minecraft server
@ -59,13 +52,13 @@ EOF
chown root:root /root/.local/bin/mc-backup
chmod 755 /root/.local/bin/mc-backup
echo "copying..." # move those files haha
cp systemd/{*.timer,*.service} /etc/systemd/system/
# dont like how this feels but i dont wanna have to change the permissions on .local folders if they exist
su mc -c \
"mkdir /srv/minecraft/{server,backups}
cp paperclip.jar /srv/minecraft/server/
echo "eula=true" > /srv/minecraft/server/eula.txt"
# find the latest release of the requested version and download it
echo "downloading minecraft $VERSION..."
RELEASE=`curl -s https://api.papermc.io/v2/projects/paper/versions/$VERSION/ | jq -r .builds[-1]`
curl https://api.papermc.io/v2/projects/paper/versions/$VERSION/builds/$RELEASE/downloads/paper-$VERSION-$RELEASE.jar -o /srv/minecraft/server/paperclip.jar
chown -R mc:mc /srv/minecraft/
su mc -c 'echo "eula=true" > /srv/minecraft/server/eula.txt'
# what they say on the tin
echo "loading units..."

View file

@ -12,7 +12,7 @@ reigon="sfo3"
config get
keys check
machine create
machine show ipv4 | jq .ip_address | read ipv4_address
machine show ipv4 | jq -r .ip_address | read ipv4_address
echo "Machine created at $ipv4_address!"
if ! firewall check; then
firewall create
@ -22,13 +22,15 @@ fi
latest=`curl -s https://api.papermc.io/v2/projects/paper/ | jq -r .versions[-1]`
versionprompt
echo "Waiting for machine to respond"
echo -n "Waiting for machine to respond"
# send pings every second, waiting for 1 second
until ping -w 1 -c 1 $ip_address >/dev/null 2>&1; do
until ping -w 1 -c 1 $ipv4_address >/dev/null 2>&1; do
echo -n '.'
sleep 1
done
echo
cat <(cat <(echo VERSION=$version) ./automate.sh)
echo "Now installing!"
ssh root@$ipv4_address < <(cat <(echo VERSION=$version) ./automate.sh)
#machine destroy

View file

@ -48,7 +48,7 @@ firewall(){
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d @- \
"https://api.digitalocean.com/v2/firewalls" <<-json
"https://api.digitalocean.com/v2/firewalls" <<-json > /dev/null
{
"name": "auto-mc",
"tags":["auto-mc"],
@ -63,6 +63,16 @@ firewall(){
]
}
},
{
"protocol": "tcp",
"ports": "22",
"sources": {
"addresses": [
"0.0.0.0/0",
"::/0"
]
}
},
{
"protocol": "tcp",
"ports": "25565",