self-upgrade various mode

This commit is contained in:
pvincent
2026-08-22 10:29:53 +04:00
parent 342c2916a5
commit 00b597a4d2
+37 -12
View File
@@ -4,7 +4,37 @@
# FUNCTIONS
function self_upgrade {
function hosted_upgrade {
cat >&2 <<EOF
FAILURE:
You are running inside a container within the HOSTED miaou mode.
Perform the same action again underneath HOST machine!
EOF
builtin exit 10
}
function development_upgrade {
echo TODO:...
# CHECK same user
# GIT CLONE
# INITIATE
:
}
function system_upgrade {
local current latest
current=$("$MIAOU_BASH_DIR"/bin/miaou-bash --version)
latest=$("$MIAOU_BASH_DIR"/tools/wget_semver artcode miaou/miaou-bash)
if [[ "$current" == "$latest" ]]; then
echo "up-to-date version: $current"
else
echo "new version available: $latest"
perform_upgrade
fi
}
function perform_upgrade {
sudo_root
local backup="$MIAOU_BASH_DIR".before_upgrade
sudo mv "$MIAOU_BASH_DIR" "$backup"
if "$backup"/install.sh upgraded; then
@@ -21,14 +51,9 @@ function self_upgrade {
# MAIN
source "$MIAOU_BASH_DIR"/lib/functions.bash
assert_system_mode
current=$("$MIAOU_BASH_DIR"/bin/miaou-bash --version)
latest=$("$MIAOU_BASH_DIR"/tools/wget_semver artcode miaou/miaou-bash)
if [[ "$current" == "$latest" ]]; then
echo "up-to-date version: $current"
else
echo "new version available: $latest"
sudo_root
self_upgrade
fi
fetch_mode
case "$MIAOU_BASH_MODE" in
hosted) hosted_upgrade ;;
development) development_upgrade ;;
system) system_upgrade ;;
esac