You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
#!/usr/bin/bash -E
|
|
|
|
## CONSTANTS
|
|
|
|
readonly MIAOU_BASH_DIR=/opt/miaou-bash
|
|
readonly MAIN_TAR_GZ_URL="https://git.artcode.re/miaou/miaou-bash/archive/main.tar.gz"
|
|
|
|
## FUNCTIONS
|
|
function bootstrap {
|
|
cd "$(mktemp -d)" || exit 3
|
|
curl -s -O $MAIN_TAR_GZ_URL
|
|
tar -xzf main.tar.gz --directory "$(dirname $MIAOU_BASH_DIR)"
|
|
|
|
local source_bin="$MIAOU_BASH_DIR/bin/miaou-bash"
|
|
local dest_bin="/usr/bin/miaou-bash"
|
|
if ! cmp -s "$source_bin" "$dest_bin"; then
|
|
cp -f "$source_bin" "$dest_bin"
|
|
fi
|
|
echo "miaou-bash deployed to: $MIAOU_BASH_DIR"
|
|
}
|
|
|
|
function assert_supported_distro {
|
|
grep -E '^ID=debian|^ID_LIKE=debian' /etc/os-release ||
|
|
grep -E '^ID=arch|^ID_LIKE=arch' /etc/os-release
|
|
}
|
|
|
|
## MAIN
|
|
|
|
set -Eeuo pipefail
|
|
|
|
[[ "$UID" -ne 0 ]] && echo 'root privilege required' && exit 1
|
|
! assert_supported_distro && echo 'unsupported distro: debian-like OR arch-like expected' && exit 2
|
|
|
|
export MIAOU_BASH_DIR
|
|
if [[ -d "$MIAOU_BASH_DIR" ]]; then
|
|
miaou-bash "$MIAOU_BASH_DIR/lib/self-upgrade.bash"
|
|
else
|
|
bootstrap
|
|
miaou-bash "$MIAOU_BASH_DIR/lib/init.bash"
|
|
echo "miaou-bash successfully installed"
|
|
fi
|