forked from dockcenter/velocity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_versions.sh
executable file
·52 lines (41 loc) · 1.18 KB
/
get_versions.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
#! /bin/bash
version=$1
if [ -n "$VELOCITY_VERSION" ]; then
version=$VELOCITY_VERSION
fi
echo -n " "
function check_for_curl() {
if ! command -v curl &> /dev/null
then
echo "curl could not be found"
exit
fi
}
function check_for_jq() {
if ! command -v jq &> /dev/null
then
echo "jq could not be found"
exit
fi
}
function get_latest_version() {
build_version=$(curl -sSL https://api.papermc.io/v2/projects/velocity | jq -r ".versions[-1]")
echo "$build_version"
}
function download_latest_build() {
build_version=$1
build_number=$(curl -sSL https://api.papermc.io/v2/projects/velocity/versions/"$build_version"/builds | jq -r ".builds[-1].build")
echo -n "$build_number"
curl -sSL https://api.papermc.io/v2/projects/velocity/versions/"$build_version"/builds/"$build_number"/downloads/velocity-"$build_version"-"$build_number".jar -o velocity.jar
}
check_for_curl
check_for_jq
if [ "$version" == "latest" ]; then
echo -n "latest "
version=$(get_latest_version)
fi
if [ -z "$version" ]; then
version=$(get_latest_version)
fi
build_num=$(download_latest_build "$version")
echo "$version $version-$build_num"