-
Notifications
You must be signed in to change notification settings - Fork 7
/
uploadupdate.sh
executable file
·77 lines (65 loc) · 1.68 KB
/
uploadupdate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
serverurl="https://emuferal.ddns.net"
function uploadToServers() {
version="$1"
channel="$2"
baseurl="$serverurl/$channel"
function upload() {
for file in $1/* ; do
pref=$2
targetf="${file:${#pref}}"
if [ -f "$file" ]; then
echo 'curl "'"${baseurl}/${version}/${targetf}"'" -X PUT -u "REDACTED" --data-binary @"'"$file"'"'
curl "${baseurl}/${version}/${targetf}" -X PUT -u "$username:$password" --data-binary @"$file"
fi
if [ "$?" != "0" ]; then
echo Upload failure!
exit 1
fi
if [ -d "$file" ]; then
upload "$file" "$2"
fi
done
}
upload build/update build/update/
echo curl -X PUT "$baseurl/update.info" -u "REDACTED" --data-binary "$version"
curl -X PUT "$baseurl/update.info" -u "$username:$password" --data-binary "$version"
source version.info
}
# Current channel
source version.info
rm -rf build/update
read -rp "Server username: " username
read -rsp "Server upload password: " password
echo
echo
echo
echo Centuria Uploader
echo Version: $version
echo Version type: $channel
echo
echo
read -p "Are you sure you want to upload this version to the server? [Y/n] " prompt
if [ "$prompt" != "y" ] && [ "$prompt" != "Y" ]; then
exit
fi
echo Building centuria...
./gradlew build updateData || exit $?
echo
echo Uploading data...
uploadToServers "$version" "$channel"
# Other channels
if [ "$channel" == "beta" ]; then
uploadToServers "$version" alpha
fi
if [ "$channel" == "prerelease" ]; then
uploadToServers "$version" alpha
uploadToServers "$version" beta
fi
if [ "$channel" == "release" ]; then
uploadToServers "$version" alpha
uploadToServers "$version" beta
uploadToServers "$version" prerelease
fi
echo
echo Upload completed.