-
Notifications
You must be signed in to change notification settings - Fork 11
/
install.sh
executable file
·66 lines (57 loc) · 1.81 KB
/
install.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
#!/bin/sh
set -e
main() {
if ! command -v tar >/dev/null; then
echo "Error: tar is required to install nitrogen" 1>&2
exit 1
fi
ext=".tar.gz"
nitrogen_install="${nitrogen_INSTALL:-$HOME/.nitrogen}"
if [ "$OS" = "Windows_NT" ]; then
target="x86_64-pc-windows-gnu"
else
case $(uname -sm) in
"Darwin x86_64") target="x86_64-apple-darwin" ;;
"Darwin arm64") target="aarch64-apple-darwin" ;;
"Linux aarch64")
echo "Error: Official nitrogen builds for Linux aarch64 are not available" 1>&2
exit 1
;;
"Linux x86_64")
target="x86_64-unknown-linux-musl"
nitrogen_install="${nitrogen_INSTALL:-$HOME/.local}"
;;
*)
echo "Error: Official nitrogen builds for Linux arm64 are not available" 1>&2
exit 1
;;
esac
fi
if [ $# -eq 0 ]; then
# get the redirect url for latest to pull the latest version
redirect_url=$(curl -s -L -I -o /dev/null -w '%{url_effective}' "https://github.com/capeprivacy/nitrogen/releases/latest/download")
version=${redirect_url##*/}
nitrogen_uri="https://github.com/capeprivacy/nitrogen/releases/latest/download/nitrogen_${version}_${target}${ext}"
else
nitrogen_uri="https://github.com/capeprivacy/nitrogen/releases/download/${1}/nitrogen_${target}${ext}"
fi
bin_dir="$nitrogen_install/bin"
exe="$bin_dir/nitrogen"
if [ ! -d "$bin_dir" ]; then
mkdir -p "$bin_dir"
fi
echo "$nitrogen_uri"
curl --fail --location --progress-bar --output "$exe.tar.gz" "$nitrogen_uri"
tar -C "$bin_dir" -xzf "$exe.tar.gz"
chmod +x "$exe"
rm "$exe.tar.gz"
echo "nitrogen was installed successfully to $exe"
if command -v nitrogen >/dev/null; then
echo "Run 'nitrogen --help' to get started"
else
echo "Run the following to make nitrogen accessible globally:"
echo " sudo cp $bin_dir/nitrogen /usr/local/bin/"
echo "Run '$exe --help' to get started"
fi
}
main "$@"