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

View file

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

View file

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