-
Notifications
You must be signed in to change notification settings - Fork 33
/
install.sh
44 lines (35 loc) · 1.2 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
#!/bin/bash
die() { echo "error: $@" 1>&2 ; exit 1; }
# Getting operating system
os=`uname -s`
os=${os,,}
# Getting architecture
arch=`uname -m`
case "$arch" in
"armv7l")
arch="arm"
;;
"x86_64")
arch="amd64"
;;
esac
release_url="https://api.github.com/repos/ncarlier/readflow/releases/latest"
artefact_url=`curl -s $release_url | grep browser_download_url | head -n 1 | cut -d '"' -f 4`
[ -z "$artefact_url" ] && die "Unable to extract artefact URL"
base_download_url=`dirname $artefact_url`
download_url=$base_download_url/readflow-$os-${arch}.tgz
download_file=/tmp/readflow-$os-${arch}.tgz
bin_target=${1:-$HOME/.local/bin}
echo "Downloading $download_url to $download_file ..."
curl -o $download_file --fail -L $download_url
[ $? != 0 ] && die "Unable to download binary for your architecture."
echo "Extracting $download_file to $bin_target ..."
[ -d $bin_target ] || mkdir -p $bin_target
tar xvzf ${download_file} -C $bin_target
[ $? != 0 ] && die "Unable to extract archive."
echo "Cleaning..."
rm $download_file \
$bin_target/LICENSE \
$bin_target/README.md
[ $? != 0 ] && die "Unable to clean installation files."
echo "Installation done. Type '$bin_target/readflow' to start the server."