Skip to content

Commit b24398f

Browse files
authored
Install script easy button (synadia-io#105)
* install script easy button * create scripts/ directory
1 parent ee0f246 commit b24398f

File tree

7 files changed

+90
-0
lines changed

7 files changed

+90
-0
lines changed

Diff for: _scripts/install.sh

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
command -v jq >/dev/null 2>&1 || {
6+
echo "Please install jq"
7+
exit 1
8+
}
9+
10+
get_version() {
11+
echo $(
12+
command curl -L -s \
13+
-H "Accept: application/vnd.github+json" \
14+
-H "X-GitHub-Api-Version: 2022-11-28" \
15+
https://api.github.com/repos/synadia-io/nex/releases/latest |
16+
command jq -r '.name'
17+
)
18+
}
19+
20+
get_arch() {
21+
a=$(uname -m)
22+
case ${a} in
23+
"x86_64" | "amd64")
24+
echo "amd64"
25+
;;
26+
"i386" | "i486" | "i586")
27+
echo "386"
28+
;;
29+
"aarch64" | "arm64" | "arm")
30+
echo "arm64"
31+
;;
32+
"mips64el")
33+
echo "mips64el"
34+
;;
35+
"mips64")
36+
echo "mips64"
37+
;;
38+
"mips")
39+
echo "mips"
40+
;;
41+
*)
42+
echo ${NIL}
43+
;;
44+
esac
45+
}
46+
47+
get_os() {
48+
echo $(uname -s | awk '{print tolower($0)}')
49+
}
50+
51+
echo "
52+
▐ ▄ ▄▄▄ .▐▄• ▄
53+
•█▌▐█▀▄.▀· █▌█▌▪
54+
▐█▐▐▌▐▀▀▪▄ ·██·
55+
██▐█▌▐█▄▄▌▪▐█·█▌
56+
▀▀ █▪ ▀▀▀ •▀▀ ▀▀
57+
"
58+
59+
os=$(get_os)
60+
arch=$(get_arch)
61+
binary_version=$(get_version)
62+
file_name="nex_${binary_version}_${os}_${arch}"
63+
asset_uri="https://github.com/synadia-io/nex/releases/download/${binary_version}/${file_name}"
64+
65+
downloadFolder="${TMPDIR:-/tmp}"
66+
mkdir -p ${downloadFolder}
67+
downloaded_file="${downloadFolder}/nex"
68+
executable_folder="/usr/local/bin"
69+
70+
echo "[1/3] Download ${asset_uri} to ${downloadFolder}"
71+
rm -f ${downloaded_file}
72+
curl --silent --fail --location --output "${downloaded_file}" "${asset_uri}"
73+
74+
echo "[2/3] Install nex to ${executable_folder}"
75+
mv ${downloaded_file} ${executable_folder}
76+
exe=${executable_folder}/nex
77+
chmod +x ${exe}
78+
79+
echo "[3/3] Check environment variables"
80+
echo ""
81+
echo "nex was installed successfully to ${exe}"
82+
if command -v nex --version >/dev/null; then
83+
echo "Run 'nex --help' to get started"
84+
else
85+
echo "Manually add the directory to your \$HOME/.bash_profile (or similar)"
86+
echo " export PATH=${executable_folder}:\$PATH"
87+
echo "Run '$exe_name --help' to get started"
88+
fi
89+
90+
exit 0
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)