abra/scripts/installer/installer

65 lines
2.2 KiB
Plaintext
Raw Normal View History

2021-09-07 11:01:22 +00:00
#!/usr/bin/env bash
2021-10-21 14:03:19 +00:00
ABRA_VERSION="0.2.2-alpha"
2021-09-07 11:01:22 +00:00
ABRA_RELEASE_URL="https://git.coopcloud.tech/api/v1/repos/coop-cloud/abra/releases/tags/$ABRA_VERSION"
function show_banner {
echo ""
echo " ____ ____ _ _ "
echo " / ___|___ ___ _ __ / ___| | ___ _ _ __| |"
echo " | | / _ \ _____ / _ \| '_ \ | | | |/ _ \| | | |/ _' |"
echo " | |__| (_) |_____| (_) | |_) | | |___| | (_) | |_| | (_| |"
echo " \____\___/ \___/| .__/ \____|_|\___/ \__,_|\__,_|"
echo " |_|"
echo ""
echo ""
echo " === Public interest infrastructure === "
echo ""
echo ""
}
function install_abra_release {
mkdir -p "$HOME/.local/bin"
if ! type "curl" > /dev/null 2>&1; then
echo "'curl' is not installed, cannot proceed..."
echo "perhaps try installing manually via the releases URL?"
echo "https://git.coopcloud.tech/coop-cloud/abra/releases"
exit 1
fi
# FIXME: support different architectures
PLATFORM=$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m)
sed_command='s/.*"assets":\[\{[^}]*"name":"abra.*_'"$PLATFORM"'"[^}]*"browser_download_url":"([^"]*)".*\].*/\1/p'
release_url=$(curl -s $ABRA_RELEASE_URL | sed -En $sed_command)
2021-09-07 11:01:22 +00:00
echo "downloading $ABRA_VERSION $PLATFORM binary release for abra..."
2021-09-07 11:01:22 +00:00
curl --progress-bar "$release_url" --output "$HOME/.local/bin/abra"
chmod +x "$HOME/.local/bin/abra"
x=$(echo $PATH | grep $HOME/.local/bin)
if [ $? -ne 0 ]; then
echo "$(tput setaf 3)WARNING: $HOME/.local/bin/ is not in \$PATH! If you want to run abra by just typing "abra" you should add it to your \$PATH! To do that run:$(tput sgr0)"
p=$HOME/.local/bin
com="echo PATH=\$PATH:$p"
if [[ $SHELL =~ "bash" ]]; then
echo "echo $com >> $HOME/.bashrc"
elif [[ $SHELL =~ "fizsh" ]]; then
echo "echo $com >> $HOME/.fizsh/.fizshrc"
elif [[ $SHELL =~ "zsh" ]]; then
echo "echo $com >> $HOME/.zshrc"
else
echo "echo $com >> $HOME/.profile"
fi
fi
2021-09-07 11:01:22 +00:00
echo "abra installed to $HOME/.local/bin/abra"
}
function run_installation {
show_banner
install_abra_release
}
run_installation "$@"
exit 0