MIAOU-BASH is a collection of scripts and configurations designed to enhance your terminal experience. As the name suggests, it is built on Bash and is designed to work on most modern GNU/Linux systems.
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.

59 lines
1.2 KiB

#!/usr/bin/env miaou-bash
# CONSTANTS
# FUNCTIONS
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
sudo rm -rf "$backup"
echo -n "version: "
miaou-bash --version
else
echo "ERROR: trouble during self-upgrade: revert back"
sudo rm -rf "$MIAOU_BASH_DIR"
sudo mv "$backup" "$MIAOU_BASH_DIR"
fi
}
# MAIN
source "$MIAOU_BASH_DIR"/lib/functions.bash
fetch_mode
case "$MIAOU_BASH_MODE" in
hosted) hosted_upgrade ;;
development) development_upgrade ;;
system) system_upgrade ;;
esac