-
Notifications
You must be signed in to change notification settings - Fork 0
/
fury
executable file
·53 lines (48 loc) · 1.91 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
#!/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.17.0"
ipfsHash="QmcGejWLh3XXEsFbbXMFo3usAatzZdvLnXWZJVxUxAgUAV"
xdgUsrHome="${XDG_DATA_HOME:-"$HOME/.local/share"}"
xdgSysHome="${XDG_DATA_HOME:-/usr/share}"
xdgHome="$([ "$EUID" = "0" ] && echo "${xdgSysHome}" || echo "${xdgUsrHome}")"
furyDir="${xdgHome}/fury"
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="$@"
installFury() {
mkdir -p "${downloadDir}"
printf "Downloading Fury ${version}..."
command -v curl > /dev/null || fail curl
[ -f "${downloadFile}" ] || curl -Lso "${downloadFile}" "${downloadUrl}" || fail download
printf "done\n"
printf "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"
}
runFury() {
printf "Launching Fury ${version} in standalone mode...\n"
FURY_HOME="${installDir}" "${installDir}/bin/fury" standalone ${args}
}
fail() {
printf "fail\n"
case "$1" in
curl) printf "Could not find `curl` to download Fury\n" ;;
download) printf "Could not download Fury version ${version}\n" ;;
tar) printf "Could not find `tar` to extract Fury\n" ;;
extract) printf "Could not extract Fury\n" ;;
esac
exit 1
}
([ -d "${installDir}" ] || [ "${currentVersion}" = "${version}" ] || installFury) && runFury