From b6bb1eeca15c867d2d9dc3905f4e54fe5779d73a Mon Sep 17 00:00:00 2001 From: Sky Swimmer Date: Thu, 28 Sep 2023 11:20:18 +0200 Subject: [PATCH] Add a update build script that doesnt immediately upload too --- buildupdate.sh | 78 +++++++++++++++++++++++++++++++++++++++++++++++++ uploadupdate.sh | 2 +- 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100755 buildupdate.sh mode change 100644 => 100755 uploadupdate.sh diff --git a/buildupdate.sh b/buildupdate.sh new file mode 100755 index 00000000..aa2a2978 --- /dev/null +++ b/buildupdate.sh @@ -0,0 +1,78 @@ +#!/bin/bash + +function copyUpdateData() { + version="$1" + channel="$2" + + # Create directory + mkdir -p "build/updatedata/emuferal.ddns.net/httpdocs/$channel" || exit 1 + + # Copy files + function copyData() { + for file in $1/* ; do + pref=$2 + targetf="${file:${#pref}}" + if [ -f "$file" ]; then + dir="$(dirname "build/updatedata/emuferal.ddns.net/httpdocs/$channel/${version}/${targetf}")" + if [ ! -d "$dir" ]; then + mkdir -p "$dir" || exit 1 + fi + cp -rfv "$file" "build/updatedata/emuferal.ddns.net/httpdocs/$channel/${version}/${targetf}" + fi + if [ "$?" != "0" ]; then + echo Build failure! + exit 1 + fi + if [ -d "$file" ]; then + copyData "$file" "$2" + fi + done + } + + copyData build/update build/update/ + echo -n "$version" > "build/updatedata/emuferal.ddns.net/httpdocs/$channel/update.info" + + source version.info +} + +# Current channel +echo Preparing... +source version.info +rm -rf build/updatedata +rm -rf build/update +echo +echo +echo Centuria Update Builder +echo Version: $version +echo Version type: $channel +echo +echo +read -p "Are you sure you want to build this version's update files? [Y/n] " prompt + +if [ "$prompt" != "y" ] && [ "$prompt" != "Y" ]; then + exit +fi + +echo Building centuria... +./gradlew build updateData || exit $? +echo + +echo Copying data... +copyUpdateData "$version" "$channel" + +# Other channels +if [ "$channel" == "beta" ]; then + copyUpdateData "$version" alpha +fi +if [ "$channel" == "prerelease" ]; then + copyUpdateData "$version" alpha + copyUpdateData "$version" beta +fi +if [ "$channel" == "release" ]; then + copyUpdateData "$version" alpha + copyUpdateData "$version" beta + copyUpdateData "$version" prerelease +fi + +echo +echo Build completed. diff --git a/uploadupdate.sh b/uploadupdate.sh old mode 100644 new mode 100755 index 74e91be4..1ad4d72f --- a/uploadupdate.sh +++ b/uploadupdate.sh @@ -35,7 +35,7 @@ function uploadToServers() { # Current channel source version.info -rm -rf build/Update +rm -rf build/update read -rp "Server username: " username read -rsp "Server upload password: " password echo