This repository has been archived by the owner on Dec 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathfury
executable file
·119 lines (103 loc) · 4.24 KB
/
fury
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
#
# This is the Fury launcher script, which will download and run Fury in "standalone" mode. You can
# distribute this file in a Git repository to make it easier for users to run Fury.
#
# Copyright 2018-20 Jon Pretty, Propensive OÜ.
#
version="0.31.0"
ipfsHash="QmVczF1vhtMhJZn4nz1gmbWxgtd3gMPRgDkzVidkrRXw7h"
md5Hash="85cf06e3c0ca1833aa7f5adb4e08440b"
jdkVersion="11"
xdgUsrHome="${XDG_DATA_HOME:-"$HOME/.local/share"}"
xdgSysHome="${XDG_DATA_HOME:-/usr/share}"
xdgHome="$([ "$EUID" = "0" ] && echo "${xdgSysHome}" || echo "${xdgUsrHome}")"
furyDir="${xdgHome}/fury"
jdkDir="${furyDir}/jdk/${jdkVersion}"
furyUsr="${furyDir}/usr"
currentDir="${furyUsr}/current"
currentVersion="$(head -n1 "${currentDir}/.version" 2> /dev/null || echo "")"
downloadDir="${furyDir}/downloads"
downloadFile="${downloadDir}/fury-${version}.tar.gz"
ipfsGateway="https://gateway.pinata.cloud/ipfs"
downloadUrl="${ipfsGateway}/${ipfsHash}"
installDir="${furyUsr}/$([ "${currentVersion}" = "${version}" ] && echo "current" || echo "${version}")"
args="$@"
info="\033[1m\033[42m INFO \033[0m "
installFury() {
checkJava && download && checkFile && extractTar
}
checkJava() {
(command -v javac > /dev/null && javac -version > /dev/null) || [ -x "${jdkDir}"/**/java ] || installJava
}
installJava() {
printf "${info}Installing a JDK..."
case $(uname -s) in
Darwin*) os="mac" ;;
Linux*) os="linux" ;;
CYGWIN*) os="windows" ;;
MINGW*) os="windows" ;;
MSYS*) os="windows" ;;
*) fail os ;;
esac
case $(uname -m) in
i386|i686|x86) arch="x32" ;;
x86_64|x64) arch="x64" ;;
aarch64_be|aarch64|armv8b|armv8l) arch="aarch64" ;;
arm) arch="arm" ;;
*) fail os ;;
esac
command -v curl > /dev/null || fail curl
mkdir -p "${jdkDir}/tmp"
curl -X GET -Ls "https://api.adoptopenjdk.net/v3/binary/latest/${jdkVersion}/ga/${os}/${arch}/jdk/hotspot/normal/adoptopenjdk?project=jdk" -H "accept: */*" | tar xz -C "${jdkDir}/tmp"
case "${os}" in
"linux") mv "${jdkDir}/tmp"/*/* "${jdkDir}/" ;;
"windows") mv "${kdkDir}/tmp"/*/* "${jdkDir}/" ;;
"mac") mv "${jdkDir}/tmp"/*/Contents/Home/* "${jdkDir}/" ;;
esac
rm -r "${jdkDir}/tmp"
printf "done\n"
}
runFury() {
printf "${info}Launching Fury ${version} in standalone mode...\n"
if [[ -t 0 || ! -t 1 ]]; then
FURY_HOME="${installDir}" "${installDir}/bin/fury" standalone ${args}
else
FURY_HOME="${installDir}" "${installDir}/bin/fury" standalone system install
fi
}
download() {
command -v curl > /dev/null || fail curl
mkdir -p "${downloadDir}"
printf "${info}Downloading Fury ${version}..."
[ -f "${downloadFile}" ] || curl -Lso "${downloadFile}" "${downloadUrl}" || fail download
printf "done\n"
}
checkFile() {
command -v md5sum > /dev/null || command -v md5 > /dev/null || fail md5sum
printf "${info}Checking MD5 checksum of ${downloadFile}..."
calcHash=$( (md5sum "${downloadFile}" 2> /dev/null || md5 -r "${downloadFile}" 2> /dev/null) | head -c 32)
[ "${md5Hash}" = "${calcHash}" ] || (rm -f "${downloadFile}" && fail checksum)
printf "done\n"
}
extractTar() {
printf "${info}Extracting Fury ${version} into ${installDir}..."
command -v tar > /dev/null || fail tar
mkdir -p "${installDir}" && tar xf "${downloadFile}" -C "${installDir}" || fail extract
printf "done\n"
}
fail() {
printf "fail\n\033[1m\033[41m FAIL \033[0m \033[1m"
case "$1" in
curl) printf "Could not find \033[0;36mcurl\033[0m, which is required to download Fury." ;;
download) printf "Could not download Fury version ${version}." ;;
tar) printf "Could not find \033[0;36mtar\033[0m to extract Fury." ;;
extract) printf "An unexpected error occurred while attempting to extract Fury." ;;
md5sum) printf "Could not find \033[0;36mmd5sum\033[0m, which is necessary to check the integrity of the downloaded file." ;;
checksum) printf "The downloaded file fails the MD5 checksum test." ;;
os) printf "A JDK could not be found, and the operating system type could not be identified to install one." ;;
esac
printf "\033[0m\n"
exit 1
}
([ -d "${installDir}" ] || [ "${currentVersion}" = "${version}" ] || installFury) && runFury