From 50d48b635930f567250e1aa8684084183ec2fdac Mon Sep 17 00:00:00 2001 From: pvincent Date: Sat, 8 Aug 2026 12:10:15 +0400 Subject: [PATCH] boostrap twice --- install.sh | 4 +--- lib/functions.bash | 8 -------- lib/self-upgrade.bash | 14 ++++++-------- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/install.sh b/install.sh index 615f00a..9cf4458 100755 --- a/install.sh +++ b/install.sh @@ -6,11 +6,10 @@ 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 "$MIAOU_BASH_DIR/.." + 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" @@ -18,7 +17,6 @@ function bootstrap { cp -f "$source_bin" "$dest_bin" fi echo "miaou-bash deployed to: $MIAOU_BASH_DIR" - } function assert_supported_distro { diff --git a/lib/functions.bash b/lib/functions.bash index 7c76de5..cf4ff3c 100644 --- a/lib/functions.bash +++ b/lib/functions.bash @@ -4,14 +4,6 @@ ## ARRAY Functions ## =============== -function is_debian_like { - grep -E 'ID=debian|ID_LIKE=debian' /etc/os-release -} - -function is_arch_like { - grep -E 'ID=arch|ID_LIKE=arch' /etc/os-release -} - function _array_contains { local -n array=$1 local element=$2 diff --git a/lib/self-upgrade.bash b/lib/self-upgrade.bash index 9b2a720..46fba02 100755 --- a/lib/self-upgrade.bash +++ b/lib/self-upgrade.bash @@ -2,26 +2,22 @@ # CONSTANTS -if [[ ! -v MAIN_TAR_GZ_URL ]]; then - readonly MAIN_TAR_GZ_URL="https://git.artcode.re/miaou/miaou-bash/archive/main.tar.gz" -fi +readonly MAIN_TAR_GZ_URL="https://git.artcode.re/miaou/miaou-bash/archive/main.tar.gz" # FUNCTIONS -#FIXME: source from functions.bash function bootstrap { - cd "$(mktemp -d)" || exit 4 + cd "$(mktemp -d)" || exit 3 curl -s -O $MAIN_TAR_GZ_URL - tar -xzf main.tar.gz --directory "$MIAOU_BASH_DIR/.." + 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" - echo "/usr/bin/miaou-bash updated" fi + echo "miaou-bash refreshed from: $MIAOU_BASH_DIR" } - # MAIN [[ "$UID" -ne 0 ]] && echo 'root privilege required' && exit 1 @@ -31,8 +27,10 @@ latest=$("$MIAOU_BASH_DIR/tools/wget_semver" artcode miaou/miaou-bash) if [[ "$current" == "$latest" ]]; then echo "up-to-date version: $current" else + # TODO: prevent refresh from development purpose rm -rf "$MIAOU_BASH_DIR" bootstrap + miaou-bash "$MIAOU_BASH_DIR/lib/init.bash" echo "miaou-bash successfully updated" miaou-bash --version