Compare commits
4 commits
4577cf384e
...
8241343c35
Author | SHA1 | Date | |
---|---|---|---|
8241343c35 | |||
b3b9f7360c | |||
4f79143cba | |||
e284bb605d |
3 changed files with 10 additions and 15 deletions
|
@ -23,7 +23,7 @@ fi
|
|||
|
||||
echo "preparing..." # making sure things have the right owners
|
||||
adduser --disabled-password --gecos "" mc
|
||||
mkdir -p /srv/minecraft/{server,backups}
|
||||
mkdir -p /srv/minecraft/server
|
||||
cat <<- 'EOF' > /etc/systemd/system/mc-server.service
|
||||
[Unit]
|
||||
Description=Minecraft server
|
||||
|
@ -46,7 +46,8 @@ 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
|
||||
tar -caf /srv/minecraft/backups/server.tar.xz /srv/minecraft/server/
|
||||
systemctl stop mc-server
|
||||
tar -c -f - /srv/minecraft/server/ | zstd
|
||||
EOF
|
||||
|
||||
chown root:root /root/.local/bin/mc-backup
|
||||
|
|
|
@ -20,8 +20,8 @@ fi
|
|||
|
||||
versionprompt
|
||||
echo -n "Waiting for machine to respond"
|
||||
# send pings every second, waiting for 1 second
|
||||
until ping -w 1 -c 1 $ipv4_address >/dev/null 2>&1; do
|
||||
# tests if ssh is up, waiting one second between attempts
|
||||
until nc $ipv4_address 22 <<<'' | grep -q 'SSH'; do
|
||||
echo -n '.'
|
||||
sleep 1
|
||||
done
|
||||
|
|
16
functions.sh
16
functions.sh
|
@ -184,7 +184,6 @@ 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' \
|
||||
|
@ -195,10 +194,7 @@ machine(){
|
|||
"image":"ubuntu-24-10-x64",
|
||||
"ssh_keys":["'$fingerprint'"],
|
||||
"tags":["auto-mc"]}' \
|
||||
"https://api.digitalocean.com/v2/droplets" |\
|
||||
jq .droplet.id | read droplet
|
||||
|
||||
export droplet
|
||||
"https://api.digitalocean.com/v2/droplets" > /dev/null
|
||||
echo 'Waiting for droplet to be active...'
|
||||
while sleep 5; do
|
||||
machine show status
|
||||
|
@ -220,23 +216,21 @@ machine(){
|
|||
curl -s -X GET \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
"https://api.digitalocean.com/v2/droplets/$droplet" |\
|
||||
jq '.droplet.networks.v4[] | select(.type == "public")'
|
||||
"https://api.digitalocean.com/v2/droplets?tag_name=auto-mc" |\
|
||||
jq '.droplets[].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/$droplet" |\
|
||||
jq -r .droplet.status | read status
|
||||
"https://api.digitalocean.com/v2/droplets?tag_name=auto-mc" |\
|
||||
jq -r .droplets[].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]`
|
||||
|
|
Loading…
Add table
Reference in a new issue