Compare commits
No commits in common. "401f678842c36e1599693e644aa5eac341b32ecd" and "7fbc679e36011c32c76e54f9126ca39d4424746c" have entirely different histories.
401f678842
...
7fbc679e36
3 changed files with 20 additions and 25 deletions
23
automate.sh
23
automate.sh
|
@ -21,9 +21,16 @@ 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/{server,backups}
|
mkdir -p /srv/minecraft/
|
||||||
|
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
|
||||||
|
@ -52,13 +59,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
|
||||||
|
|
||||||
# find the latest release of the requested version and download it
|
echo "copying..." # move those files haha
|
||||||
echo "downloading minecraft $VERSION..."
|
cp systemd/{*.timer,*.service} /etc/systemd/system/
|
||||||
RELEASE=`curl -s https://api.papermc.io/v2/projects/paper/versions/$VERSION/ | jq -r .builds[-1]`
|
# dont like how this feels but i dont wanna have to change the permissions on .local folders if they exist
|
||||||
curl https://api.papermc.io/v2/projects/paper/versions/$VERSION/builds/$RELEASE/downloads/paper-$VERSION-$RELEASE.jar -o /srv/minecraft/server/paperclip.jar
|
su mc -c \
|
||||||
|
"mkdir /srv/minecraft/{server,backups}
|
||||||
chown -R mc:mc /srv/minecraft/
|
cp paperclip.jar /srv/minecraft/server/
|
||||||
su mc -c 'echo "eula=true" > /srv/minecraft/server/eula.txt'
|
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..."
|
||||||
|
|
10
deploy.sh
10
deploy.sh
|
@ -12,7 +12,7 @@ reigon="sfo3"
|
||||||
config get
|
config get
|
||||||
keys check
|
keys check
|
||||||
machine create
|
machine create
|
||||||
machine show ipv4 | jq -r .ip_address | read ipv4_address
|
machine show ipv4 | jq .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,15 +22,13 @@ 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 -n "Waiting for machine to respond"
|
echo "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 $ipv4_address >/dev/null 2>&1; do
|
until ping -w 1 -c 1 $ip_address >/dev/null 2>&1; do
|
||||||
echo -n '.'
|
echo -n '.'
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
echo
|
|
||||||
|
|
||||||
echo "Now installing!"
|
cat <(cat <(echo VERSION=$version) ./automate.sh)
|
||||||
ssh root@$ipv4_address < <(cat <(echo VERSION=$version) ./automate.sh)
|
|
||||||
|
|
||||||
#machine destroy
|
#machine destroy
|
||||||
|
|
12
functions.sh
12
functions.sh
|
@ -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 > /dev/null
|
"https://api.digitalocean.com/v2/firewalls" <<-json
|
||||||
{
|
{
|
||||||
"name": "auto-mc",
|
"name": "auto-mc",
|
||||||
"tags":["auto-mc"],
|
"tags":["auto-mc"],
|
||||||
|
@ -63,16 +63,6 @@ firewall(){
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"protocol": "tcp",
|
|
||||||
"ports": "22",
|
|
||||||
"sources": {
|
|
||||||
"addresses": [
|
|
||||||
"0.0.0.0/0",
|
|
||||||
"::/0"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"protocol": "tcp",
|
"protocol": "tcp",
|
||||||
"ports": "25565",
|
"ports": "25565",
|
||||||
|
|
Loading…
Add table
Reference in a new issue