telebit.js/usr/share/install_helper.sh

42 lines
1.6 KiB
Bash
Raw Normal View History

2018-06-01 19:14:59 +00:00
#!/bin/bash
#<pre><code>
2019-07-11 08:09:51 +00:00
# This downloads the telebit zip (Windows) or tarball (Mac, Linux),
# unpacks it, and then completes the installation
2018-06-01 19:14:59 +00:00
set -e
set -u
2019-07-11 08:09:51 +00:00
### http_get, http_bash, archiver, and archive_ext are exported by get.sh
mkdir -p $HOME/Downloads
my_tmp="$(mktemp -d -t telebit.XXXX)"
http_get "https://rootprojects.org/telebit/dist/index.tab" "$my_tmp/index.tab"
latest=$(grep $TELEBIT_RELEASE $my_tmp/index.tab | grep $TELEBIT_OS | grep $TELEBIT_ARCH | head -n 1 | cut -f 1)
major=$(grep $TELEBIT_RELEASE $my_tmp/index.tab | grep $TELEBIT_OS | grep $TELEBIT_ARCH | head -n 1 | cut -f 2)
size=$(grep $TELEBIT_RELEASE $my_tmp/index.tab | grep $TELEBIT_OS | grep $TELEBIT_ARCH | head -n 1 | cut -f 3)
#latest=$(grep $TELEBIT_RELEASE $my_tmp/index.tab | grep $TELEBIT_OS | grep $TELEBIT_ARCH | head -n 1 | cut -f 1)
my_dir="telebit-$latest-$TELEBIT_OS-$TELEBIT_ARCH"
my_file="$my_dir.$archive_ext"
if [ -f "$HOME/Downloads/$my_file" ]; then
my_size=$(($(wc -c < "$HOME/Downloads/$my_file")))
if [ "$my_size" -eq "$size" ]; then
echo "File exists in ~/Downloads, skipping download"
2018-06-28 20:47:32 +00:00
else
2019-07-11 08:09:51 +00:00
echo "Removing corrupt download '~/Downloads/$my_file'"
rm -f "$HOME/Downloads/$my_file"
2018-06-28 20:47:32 +00:00
fi
2018-06-28 21:09:24 +00:00
fi
2019-07-11 08:09:51 +00:00
if [ ! -f "$HOME/Downloads/$my_file" ]; then
echo "Downloading from https://rootprojects.org/telebit/dist/$major/$my_file ..."
sleep 0.3
http_get "https://rootprojects.org/telebit/dist/$major/$my_file" "$HOME/Downloads/$my_file"
echo "Saved to '$HOME/Downloads/$my_file' ..."
2018-06-28 21:37:31 +00:00
echo ""
2019-07-11 08:09:51 +00:00
sleep 0.3
2018-06-28 21:37:31 +00:00
fi
2019-07-11 08:09:51 +00:00
echo "Unpacking and installing Telebit ..."
unarchiver $my_file $my_tmp
pushd $my_tmp/$my_dir
bash ./setup.sh