abra/scripts/installer/installer

117 lines
4.0 KiB
Plaintext
Raw Permalink Normal View History

2021-09-07 11:01:22 +00:00
#!/usr/bin/env bash
2024-03-12 09:05:31 +00:00
ABRA_VERSION="0.9.0-beta"
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"
fix-integration-tests (!403) In preparation for the new abra release, let's fix all integration tests After merging, this needs to be cherry-picked into the release-0-9 branch. - [x] app_backup.bats (skip this one) - [x] app_check.bats (fixed by https://git.coopcloud.tech/coop-cloud/abra/commit/bd21014fedf6f8d4fb8f1baf44fb8b0df99fc326) - [x] app_cmd.bats (partially fixed in https://git.coopcloud.tech/coop-cloud/abra/commit/08232b74f6d512ab2ca7c08f67bb7c227b82a2ca), has known regression https://git.coopcloud.tech/coop-cloud/organising/issues/581 - [x] app_config.bats (no changes needed) - [x] app_cp.bats (no changes needed) - [x] app_deploy.bats - [x] app_errors.bats (no changes needed) - [x] app_list.bats (no changes needed) - [x] app_logs.bats (no changes needed) - [x] app_new.bats (no changes needed) - [x] app_ps.bats (no changes needed) - [x] app_remove.bats (fixed by [2f29fbeb2e](https://git.coopcloud.tech/coop-cloud/abra/pulls/403/commits/2f29fbeb2e018656413fa25f8615b7a98cdcb083)) - [x] app_restart.bats (no changes needed - [x] app_restore.bats (fixed by [f2dd5afc38](https://git.coopcloud.tech/coop-cloud/abra/pulls/403/commits/f2dd5afc38a25a8316899fa0c6d59499445868d7)) - [x] app_rollback.bats (partially fixed by https://git.coopcloud.tech/coop-cloud/abra/commit/6e99b74c24e92a293a5f71d7aacd552441dc8613) - [x] app_run.bats (no changes needed) - [x] app_secret.bats (fixed by https://git.coopcloud.tech/coop-cloud/abra/commit/bd069d32f6d58f12cf8b0d2a1fef0e4cdc50d94d) - [x] app_services.bats (no changes needed) - [x] app_undeploy.bats (no changes needed) - [x] app_upgrade.bats (no changes needed) - [x] app_version.bats (partially fixed by https://git.coopcloud.tech/coop-cloud/abra/commit/ad323ad2bd6184c69baf909f891a8bf8ffc168a4) - [x] app_volume.bats (fixed by [03c3823770](https://git.coopcloud.tech/coop-cloud/abra/pulls/403/commits/03c38237707ae795b723180eb07a7edc84a8de35)) - [x] autocomplete.bats (no changes needed) - [x] catalogue.bats (no changes needed) - [x] dirs.bats (no changes needed) - [x] install.bats (failes, but is expected) - [x] recipe_diff.bats (no changes needed) - [x] recipe_fetch.bats (no changes needed) - [x] recipe_lint.bats (fixed by [b6b0808066](https://git.coopcloud.tech/coop-cloud/abra/pulls/403/commits/b6b0808066a11e4bcd77517ec39600d500bcb944)) - [x] recipe_list.bats (no changes needed) - [x] recipe_new.bats (fixed by [0aac464ded](https://git.coopcloud.tech/coop-cloud/abra/pulls/403/commits/0aac464ded6b43afb3ec37ade2f64d6191b9838f)) - [x] recipe_release.bats (no changes needed) - [x] recipe_reset.bats (no changes needed) - [x] recipe_sync.bats (no changes needed) - [x] recipe_upgrade.bats (fixed by [ab86904cf4](https://git.coopcloud.tech/coop-cloud/abra/pulls/403/commits/ab86904cf45db89c7c189ca1fd9971909bd446dd)) - [x] recipe_version.bats (fixed by https://git.coopcloud.tech/coop-cloud/abra/commit/81897bf4daf6d37f3997fdea0deafb1d8f241c6c) - [x] server_add.bats - [x] server_list.bats - [x] server_prune.bats (no changes needed) - [x] server_remove.bats - [x] upgrade.bats - [x] version.bats (no changes needed) Co-authored-by: decentral1se <cellarspoon@riseup.net> Reviewed-on: https://git.coopcloud.tech/coop-cloud/abra/pulls/403 Co-authored-by: p4u1 <p4u1_f4u1@riseup.net> Co-committed-by: p4u1 <p4u1_f4u1@riseup.net>
2024-03-11 13:27:21 +00:00
RC_VERSION="0.8.0-rc1-beta"
2021-11-09 12:27:57 +00:00
RC_VERSION_URL="https://git.coopcloud.tech/api/v1/repos/coop-cloud/abra/releases/tags/$RC_VERSION"
2021-09-07 11:01:22 +00:00
for arg in "$@"; do
if [ "$arg" == "--rc" ]; then
ABRA_VERSION="$RC_VERSION"
ABRA_RELEASE_URL="$RC_VERSION_URL"
fi
done
2021-09-07 11:01:22 +00:00
function show_banner {
echo ""
echo " ____ ____ _ _ "
echo " / ___|___ ___ _ __ / ___| | ___ _ _ __| |"
echo " | | / _ \ _____ / _ \| '_ \ | | | |/ _ \| | | |/ _' |"
echo " | |__| (_) |_____| (_) | |_) | | |___| | (_) | |_| | (_| |"
echo " \____\___/ \___/| .__/ \____|_|\___/ \__,_|\__,_|"
echo " |_|"
echo ""
echo ""
echo " === Public interest infrastructure === "
echo ""
echo ""
}
2021-10-26 10:28:56 +00:00
function print_checksum_error {
2021-12-19 15:33:15 +00:00
echo "$(tput setaf 1)ERROR: the checksum of downloaded file doesn't match the checksum in release! Either the file was corrupted during download or the file has been changed during transport$(tput sgr0)"
2021-10-26 10:28:56 +00:00
echo "expected checksum: $checksum"
echo "checksum of downloaded file: $localsum"
echo "abra was NOT installed/upgraded"
}
2021-09-07 11:01:22 +00:00
function install_abra_release {
mkdir -p "$HOME/.local/bin"
2022-01-01 20:33:50 +00:00
if ! type "wget" > /dev/null 2>&1; then
echo "'wget' is not installed, cannot proceed..."
2021-09-07 11:01:22 +00:00
echo "perhaps try installing manually via the releases URL?"
echo "https://git.coopcloud.tech/coop-cloud/abra/releases"
exit 1
fi
2022-04-20 11:13:50 +00:00
ARCH=$(uname -m)
2024-03-27 00:07:38 +00:00
if [[ $ARCH =~ "x86_64" ]]; then
ARCH="amd64"
elif [[ $ARCH =~ "aarch64" ]]; then
2022-04-20 11:13:50 +00:00
ARCH="arm64"
2022-04-20 11:37:51 +00:00
elif [[ $ARCH =~ "armv5l" ]]; then
ARCH="armv5"
elif [[ $ARCH =~ "armv6l" ]]; then
ARCH="armv6"
elif [[ $ARCH =~ "armv7l" ]]; then
ARCH="armv7"
2022-04-20 11:13:50 +00:00
fi
PLATFORM=$(uname -s | tr '[:upper:]' '[:lower:]')_$ARCH
2024-03-27 00:07:38 +00:00
FILENAME="abra_"$ABRA_VERSION"_"$PLATFORM".tar.gz"
sed_command_rel='s/.*"assets":\[\{[^]]*"name":"'$FILENAME'"[^}]*"browser_download_url":"([^"]*)".*\].*/\1/p'
2021-10-26 10:28:56 +00:00
sed_command_checksums='s/.*"assets":\[\{[^\]*"name":"checksums.txt"[^}]*"browser_download_url":"([^"]*)".*\].*/\1/p'
2022-01-01 20:33:50 +00:00
json=$(wget -q -O- $ABRA_RELEASE_URL)
2021-10-26 10:28:56 +00:00
release_url=$(echo $json | sed -En $sed_command_rel)
checksums_url=$(echo $json | sed -En $sed_command_checksums)
2022-01-01 20:46:48 +00:00
checksums=$(wget -q -O- $checksums_url)
2021-10-26 10:28:56 +00:00
checksum=$(echo "$checksums" | grep "$FILENAME" - | sed -En 's/([0-9a-f]{64})\s+'"$FILENAME"'.*/\1/p')
2024-03-27 00:07:38 +00:00
abra_download="/tmp/abra-download.tar.gz"
2021-09-07 11:01:22 +00:00
echo "downloading $ABRA_VERSION $PLATFORM binary release for abra..."
wget -q "$release_url" -O $abra_download
localsum=$(sha256sum $abra_download | sed -En 's/([0-9a-f]{64})\s+.*/\1/p')
2021-10-26 10:28:56 +00:00
echo "checking if checksums match..."
if [[ "$localsum" != "$checksum" ]]; then
print_checksum_error
exit 1
fi
echo "$(tput setaf 2)check successful!$(tput sgr0)"
2024-03-27 00:07:38 +00:00
cd /tmp/
tar xf abra-download.tar.gz
mv abra "$HOME/.local/bin/abra"
tar tf abra-download.tar.gz | xargs rm -f
2021-09-07 11:01:22 +00:00
chmod +x "$HOME/.local/bin/abra"
2021-10-26 10:28:56 +00:00
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
2021-11-30 11:07:40 +00:00
echo "$com >> $HOME/.bashrc"
elif [[ $SHELL =~ "fizsh" ]]; then
2021-11-30 11:07:40 +00:00
echo "$com >> $HOME/.fizsh/.fizshrc"
elif [[ $SHELL =~ "zsh" ]]; then
2021-11-30 11:07:40 +00:00
echo "$com >> $HOME/.zshrc"
else
2021-11-30 11:07:40 +00:00
echo "$com >> $HOME/.profile"
fi
fi
2021-09-07 11:01:22 +00:00
echo "abra installed to $HOME/.local/bin/abra"
2021-12-19 15:33:24 +00:00
echo "test your installation is working by running \"abra\" on your command-line"
echo "run \"abra autocomplete -h\" to see how to set up command-line autocompletion"
2021-09-07 11:01:22 +00:00
}
2021-11-09 12:27:57 +00:00
2021-09-07 11:01:22 +00:00
function run_installation {
show_banner
install_abra_release
}
run_installation "$@"
exit 0