move to curl and stop using regex to parse json like a fuckass
This commit is contained in:
parent
53d07ae902
commit
de20785efc
1 changed files with 17 additions and 14 deletions
31
automate.sh
31
automate.sh
|
@ -5,27 +5,30 @@ if [ "`id -u`" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
echo "fetching..."
|
||||
apt-get install -y screen tar xz-utils default-jdk-headless wget
|
||||
#ask the user which version of minecraft they would like to install
|
||||
|
||||
echo "fetching..."
|
||||
apt-get install -y screen tar xz-utils default-jdk-headless curl jq
|
||||
|
||||
|
||||
#ask the user which version of minecraft they would like to install
|
||||
LATEST=`curl -s https://papermc.io/api/v2/projects/paper/ | jq -r .versions[-1]`
|
||||
printf "\n\n\n"
|
||||
echo "which version of minecraft would you like to serve?"
|
||||
echo "version [1.16.5]:"
|
||||
echo "version [$LATEST]:"
|
||||
#have a timeout for user input handy for unattented installs
|
||||
read -t 60 VERSION
|
||||
if [ -v $VERSION ]
|
||||
then
|
||||
if [ -v $VERSION ]; then
|
||||
#TODO: add something to verify inputted version incase of typo
|
||||
echo
|
||||
else
|
||||
echo "timed out - defaulting to 1.16.5"
|
||||
$VERSION = 1.16.5
|
||||
$VERSION = $LATEST
|
||||
fi
|
||||
#find the latest release since lastSuccessfulBuild broke
|
||||
echo "downloading minecraft..."
|
||||
RELEASE=`wget https://papermc.io/api/v2/projects/paper/versions/1.16.5/ -qO - | sed 's/^.*,//g' | egrep '([0-9])*' -o`
|
||||
wget "https://papermc.io/api/v2/projects/paper/versions/$VERSION/builds/$RELEASE/downloads/paper-$VERSION-$RELEASE.jar"
|
||||
RELEASE=`curl -s https://papermc.io/api/v2/projects/paper/versions/$VERSION/ | jq -r .builds[-1]`
|
||||
curl https://papermc.io/api/v2/projects/paper/versions/$VERSION/builds/$RELEASE/downloads/paper-$VERSION-$RELEASE.jar -o paperclip.jar
|
||||
|
||||
|
||||
echo "preparing..." # making sure things are clean and have the right owners
|
||||
adduser --disabled-password --gecos "" mc
|
||||
|
@ -37,18 +40,18 @@ chown mc:mc systemd/mc-backup
|
|||
chown root:root systemd/{*.timer,*.service}
|
||||
echo "PATH=/home/mc/.local/bin/:$PATH" >> /home/mc/.bashrc
|
||||
|
||||
|
||||
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 -p /home/mc/.local/bin/
|
||||
su mc -c \
|
||||
"mkdir -p /home/mc/.local/bin/
|
||||
cp systemd/mc-backup /home/mc/.local/bin/
|
||||
mkdir /srv/minecraft/{server,backups}
|
||||
cp paperclip.jar /srv/minecraft/server/
|
||||
echo "eula=true" > /srv/minecraft/server/eula.txt
|
||||
"
|
||||
echo "eula=true" > /srv/minecraft/server/eula.txt"
|
||||
|
||||
# this should be pretty obvious
|
||||
# what it says on the tin
|
||||
echo "loading units..."
|
||||
systemctl daemon-reload
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue