forked from toolshed/abra
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 bybd21014fed
) - [x] app_cmd.bats (partially fixed in08232b74f6
), has known regression coop-cloud/organising#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](coop-cloud/abra#403/commits/2f29fbeb2e018656413fa25f8615b7a98cdcb083)) - [x] app_restart.bats (no changes needed - [x] app_restore.bats (fixed by [f2dd5afc38](coop-cloud/abra#403/commits/f2dd5afc38a25a8316899fa0c6d59499445868d7)) - [x] app_rollback.bats (partially fixed by6e99b74c24
) - [x] app_run.bats (no changes needed) - [x] app_secret.bats (fixed bybd069d32f6
) - [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 byad323ad2bd
) - [x] app_volume.bats (fixed by [03c3823770](coop-cloud/abra#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](coop-cloud/abra#403/commits/b6b0808066a11e4bcd77517ec39600d500bcb944)) - [x] recipe_list.bats (no changes needed) - [x] recipe_new.bats (fixed by [0aac464ded](coop-cloud/abra#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](coop-cloud/abra#403/commits/ab86904cf45db89c7c189ca1fd9971909bd446dd)) - [x] recipe_version.bats (fixed by81897bf4da
) - [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: coop-cloud/abra#403 Co-authored-by: p4u1 <p4u1_f4u1@riseup.net> Co-committed-by: p4u1 <p4u1_f4u1@riseup.net>
112 lines
3.9 KiB
Bash
Executable File
112 lines
3.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
ABRA_VERSION="0.8.1-beta"
|
|
ABRA_RELEASE_URL="https://git.coopcloud.tech/api/v1/repos/coop-cloud/abra/releases/tags/$ABRA_VERSION"
|
|
RC_VERSION="0.8.0-rc1-beta"
|
|
RC_VERSION_URL="https://git.coopcloud.tech/api/v1/repos/coop-cloud/abra/releases/tags/$RC_VERSION"
|
|
|
|
for arg in "$@"; do
|
|
if [ "$arg" == "--rc" ]; then
|
|
ABRA_VERSION="$RC_VERSION"
|
|
ABRA_RELEASE_URL="$RC_VERSION_URL"
|
|
fi
|
|
done
|
|
|
|
function show_banner {
|
|
echo ""
|
|
echo " ____ ____ _ _ "
|
|
echo " / ___|___ ___ _ __ / ___| | ___ _ _ __| |"
|
|
echo " | | / _ \ _____ / _ \| '_ \ | | | |/ _ \| | | |/ _' |"
|
|
echo " | |__| (_) |_____| (_) | |_) | | |___| | (_) | |_| | (_| |"
|
|
echo " \____\___/ \___/| .__/ \____|_|\___/ \__,_|\__,_|"
|
|
echo " |_|"
|
|
echo ""
|
|
echo ""
|
|
echo " === Public interest infrastructure === "
|
|
echo ""
|
|
echo ""
|
|
}
|
|
|
|
function print_checksum_error {
|
|
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)"
|
|
echo "expected checksum: $checksum"
|
|
echo "checksum of downloaded file: $localsum"
|
|
echo "abra was NOT installed/upgraded"
|
|
}
|
|
|
|
function install_abra_release {
|
|
mkdir -p "$HOME/.local/bin"
|
|
|
|
if ! type "wget" > /dev/null 2>&1; then
|
|
echo "'wget' 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
|
|
|
|
ARCH=$(uname -m)
|
|
if [[ $ARCH =~ "aarch64" ]]; then
|
|
ARCH="arm64"
|
|
elif [[ $ARCH =~ "armv5l" ]]; then
|
|
ARCH="armv5"
|
|
elif [[ $ARCH =~ "armv6l" ]]; then
|
|
ARCH="armv6"
|
|
elif [[ $ARCH =~ "armv7l" ]]; then
|
|
ARCH="armv7"
|
|
fi
|
|
PLATFORM=$(uname -s | tr '[:upper:]' '[:lower:]')_$ARCH
|
|
FILENAME="abra_"$ABRA_VERSION"_"$PLATFORM""
|
|
sed_command_rel='s/.*"assets":\[\{[^]]*"name":"'$FILENAME'"[^}]*"browser_download_url":"([^"]*)".*\].*/\1/p'
|
|
sed_command_checksums='s/.*"assets":\[\{[^\]*"name":"checksums.txt"[^}]*"browser_download_url":"([^"]*)".*\].*/\1/p'
|
|
|
|
json=$(wget -q -O- $ABRA_RELEASE_URL)
|
|
release_url=$(echo $json | sed -En $sed_command_rel)
|
|
checksums_url=$(echo $json | sed -En $sed_command_checksums)
|
|
|
|
checksums=$(wget -q -O- $checksums_url)
|
|
checksum=$(echo "$checksums" | grep "$FILENAME" - | sed -En 's/([0-9a-f]{64})\s+'"$FILENAME"'.*/\1/p')
|
|
abra_download="/tmp/abra-download"
|
|
|
|
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')
|
|
echo "checking if checksums match..."
|
|
if [[ "$localsum" != "$checksum" ]]; then
|
|
print_checksum_error
|
|
exit 1
|
|
fi
|
|
echo "$(tput setaf 2)check successful!$(tput sgr0)"
|
|
mv "$abra_download" "$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 "$com >> $HOME/.bashrc"
|
|
elif [[ $SHELL =~ "fizsh" ]]; then
|
|
echo "$com >> $HOME/.fizsh/.fizshrc"
|
|
elif [[ $SHELL =~ "zsh" ]]; then
|
|
echo "$com >> $HOME/.zshrc"
|
|
else
|
|
echo "$com >> $HOME/.profile"
|
|
fi
|
|
fi
|
|
|
|
echo "abra installed to $HOME/.local/bin/abra"
|
|
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"
|
|
}
|
|
|
|
|
|
function run_installation {
|
|
show_banner
|
|
install_abra_release
|
|
}
|
|
|
|
run_installation "$@"
|
|
exit 0
|