Compare commits

..

No commits in common. "8241343c35d120611b231608576bdc3af11d303f" and "4577cf384e414d3b342d03017541dfe917e6fb87" have entirely different histories.

3 changed files with 15 additions and 10 deletions

View file

@ -23,7 +23,7 @@ fi
echo "preparing..." # making sure things have the right owners
adduser --disabled-password --gecos "" mc
mkdir -p /srv/minecraft/server
mkdir -p /srv/minecraft/{server,backups}
cat <<- 'EOF' > /etc/systemd/system/mc-server.service
[Unit]
Description=Minecraft server
@ -46,8 +46,7 @@ echo "PATH=/root/.local/bin/:$PATH" >> /root/.bashrc #FIXME: needs to me made im
cat <<- 'EOF' > /root/.local/bin/mc-backup
#!/usr/bin/env bash
systemctl stop mc-server
tar -c -f - /srv/minecraft/server/ | zstd
tar -caf /srv/minecraft/backups/server.tar.xz /srv/minecraft/server/
EOF
chown root:root /root/.local/bin/mc-backup

View file

@ -20,8 +20,8 @@ fi
versionprompt
echo -n "Waiting for machine to respond"
# tests if ssh is up, waiting one second between attempts
until nc $ipv4_address 22 <<<'' | grep -q 'SSH'; do
# send pings every second, waiting for 1 second
until ping -w 1 -c 1 $ipv4_address >/dev/null 2>&1; do
echo -n '.'
sleep 1
done

View file

@ -184,6 +184,7 @@ machine(){
case $command in
create)
# read isn't used in these pipelines because of job control shinanigans
echo 'Creating Droplet...'
curl -s -X POST \
-H 'Content-Type: application/json' \
@ -194,7 +195,10 @@ machine(){
"image":"ubuntu-24-10-x64",
"ssh_keys":["'$fingerprint'"],
"tags":["auto-mc"]}' \
"https://api.digitalocean.com/v2/droplets" > /dev/null
"https://api.digitalocean.com/v2/droplets" |\
jq .droplet.id | read droplet
export droplet
echo 'Waiting for droplet to be active...'
while sleep 5; do
machine show status
@ -216,21 +220,23 @@ machine(){
curl -s -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
"https://api.digitalocean.com/v2/droplets?tag_name=auto-mc" |\
jq '.droplets[].networks.v4[] | select(.type == "public")'
"https://api.digitalocean.com/v2/droplets/$droplet" |\
jq '.droplet.networks.v4[] | select(.type == "public")'
;;
status)
curl -s -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
"https://api.digitalocean.com/v2/droplets?tag_name=auto-mc" |\
jq -r .droplets[].status | read status
"https://api.digitalocean.com/v2/droplets/$droplet" |\
jq -r .droplet.status | read status
export status
;;
esac
esac
}
versionprompt() {
if [ -z ${latest+x} ]; then
latest=`curl -s https://api.papermc.io/v2/projects/paper/ | jq -r .versions[-1]`