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.

52 lines
1.2 KiB

#!/usr/bin/env bash
## CONSTANTS
## FUNCTIONS
function upgrade {
echo "UPGRADE: $*"
if sudo -E "$MIAOU_BASH_DIR"/bin/miaou-bash "$MIAOU_BASH_DIR"/none.sh 3>&1; then
:
else
code=$?
echo "FAILURE exit_code=$code"
fi
}
function assert_supported_distro {
if ! grep -E '^ID=debian|^ID_LIKE=debian' /etc/os-release &&
! grep -E '^ID=arch|^ID_LIKE=arch' /etc/os-release; then
local distro
distro=$(grep -oP '^ID=\K(.*)' /etc/os-release)
>&2 echo "unsupported GNU/Linux distribution: $distro"
>&2 echo 'only debian-like OR arch-like currently supported'
return 10
fi
}
function assert_bash {
if [[ $(basename "$SHELL") != 'bash' ]]; then
>&2 echo "MIAOU ERROR: you are running on SHELL=$SHELL rather than 'bash'!"
return 11
fi
}
function sudo_root {
if [[ "$UID" -ne 0 ]] && ! sudo -vp 'SUDO privilege required: '; then
>&2 echo "canceled"
return 12
fi
}
## MAIN
set -Eeuo pipefail
if assert_supported_distro && assert_bash && sudo_root; then
if [[ ! -v MIAOU_BASH_DIR ]]; then
MIAOU_BASH_DIR=/opt/miaou-bash
export MIAOU_BASH_DIR
fi
upgrade "$@"
else
>&2 echo "MIAOU_BASH_ERROR: requirements failure"
fi