Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- start(){
- echo "Starting Installation..."
- read -p "Press enter to continue"
- currentvercheck(){
- if [ -f currentversion.txt ]; then
- echo "currentversion exists..."
- cd ../
- echo "creating start..."
- cat << 'EOF' > start.sh
- #!/bin/bash
- #Check for Updates
- ../updatescript/updatething.sh
- #Start Server
- java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}
- EOF
- chmod +x start.sh
- echo "Installation Finished"
- else
- echo "creating currentversion..."
- cat << 'EOF' > currentversion.txt
- 0
- EOF
- currentvercheck
- fi
- }
- uthingcheck(){
- if [ -f updatething.sh ]; then
- echo "updatething exists..."
- currentvercheck
- else
- echo "creating updatething..."
- cat << 'EOF' > updatething.sh
- #!/bin/bash
- cd updatescript/
- current=`cat currentversion.txt`
- echo "Checking for Server Update..."
- new=`curl -s "https://papermc.io/api/v1/paper/1.14.4" | jq -r '.builds | .latest' 2>&1 | tee latestversion.txt`
- echo "Paper is on version $new"
- startserver(){
- exit
- }
- comparedemapples(){
- if [ "${new}" -gt "${current}" ]; then
- echo "paper-$new.jar is a new update."
- echo "Updating to paper-$new.jar"
- wget -nv -nc --content-disposition https://papermc.io/api/v1/paper/1.14.4/$new/download
- file="paper-$new.jar"
- if [ -f "$file" ]; then
- echo "paper-$new.jar has been downloaded. Renaming some shit..."
- cp paper-$new.jar ../server.jar
- echo "$new" > currentversion.txt
- startserver
- else
- echo "Error 404: paper-$new.jar could not be found."
- read -p "Press enter to continue"
- fi
- else
- echo "paper-$new.jar is already installed and running."
- echo "You good on your updates my dude."
- startserver
- fi
- }
- comparedemapples
- EOF
- chmod +x updatething.sh
- uthingcheck
- fi
- }
- dircheck(){
- if [ -d updatescript ]; then
- echo "updatescript exists..."
- cd updatescript
- uthingcheck
- else
- echo "creating updatescript..."
- mkdir updatescript
- dircheck
- fi
- }
- dircheck
- }
- start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement