simplified install

This commit is contained in:
pvincent
2026-08-08 11:54:48 +04:00
parent 08335be03d
commit 9ff46a896c
3 changed files with 33 additions and 33 deletions
+17 -14
View File
@@ -2,36 +2,39 @@
## CONSTANTS
readonly DESTINATION=/opt
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 {
if [[ ! -d "$DESTINATION/miaou-bash" ]]; then
local temp_dir
temp_dir=$(mktemp -d)
pushd "$temp_dir" >/dev/null || return 2
curl -s -O $MAIN_TAR_GZ_URL
tar -xzf main.tar.gz --directory "$DESTINATION"
echo "directory: miaou-bash successfully deployed to $DESTINATION"
popd >/dev/null || return 3
fi
cd "$(mktemp -d)" || exit 3
curl -s -O $MAIN_TAR_GZ_URL
tar -xzf main.tar.gz --directory "$MIAOU_BASH_DIR/.."
local source_bin="$DESTINATION/miaou-bash/bin/miaou-bash"
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"
echo "executable: /usr/bin/miaou-bash freshly created"
fi
echo "miaou-bash deployed to: $MIAOU_BASH_DIR"
export MIAOU_BASH_DIR="$DESTINATION/miaou-bash"
}
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
if [[ -v MIAOU_BASH_DIR && -d "$MIAOU_BASH_DIR" ]]; then
! 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