telebit.js/installer/get.sh

65 lines
1.3 KiB
Bash
Raw Normal View History

2018-05-27 10:26:34 +00:00
#!/bin/bash
#<pre><code>
set -e
set -u
###############################
# #
# http_get #
# boilerplate for curl / wget #
# #
###############################
# See https://git.coolaj86.com/coolaj86/snippets/blob/master/bash/http-get.sh
2018-06-01 19:14:59 +00:00
export _my_http_get=""
export _my_http_opts=""
export _my_http_out=""
2018-05-27 10:26:34 +00:00
detect_http_get()
{
set +e
if type -p curl >/dev/null 2>&1; then
_my_http_get="curl"
_my_http_opts="-fsSL"
_my_http_out="-o"
elif type -p wget >/dev/null 2>&1; then
_my_http_get="wget"
_my_http_opts="--quiet"
_my_http_out="-O"
else
echo "Aborted, could not find curl or wget"
return 7
fi
set -e
}
http_get()
{
$_my_http_get $_my_http_opts $_my_http_out "$2" "$1"
touch "$2"
}
http_bash()
{
_http_url=$1
my_args=${2:-}
rm -rf my-tmp-runner.sh
$_my_http_get $_my_http_opts $_my_http_out my-tmp-runner.sh "$_http_url"; bash my-tmp-runner.sh $my_args; rm my-tmp-runner.sh
}
detect_http_get
2018-06-01 19:14:59 +00:00
export http_get
export http_bash
2018-05-27 10:26:34 +00:00
###############################
## END HTTP_GET ##
###############################
2018-06-01 19:14:59 +00:00
if [ -e "installer/install.sh" ]; then
bash installer/install.sh "$@"
2018-05-27 10:26:34 +00:00
else
2018-06-01 19:14:59 +00:00
http_bash https://git.coolaj86.com/coolaj86/telebit.js/raw/branch/master/installer/install.sh "$@"
2018-05-27 10:26:34 +00:00
fi