MIAOU-BASH is a collection of settings and helpers for leveraging BASH. Developer-friendly, it may be used as solo package with or without the miaou project.
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.

40 lines
1.0 KiB

#!/usr/bin/env miaou-bash
# CONSTANTS
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 "$(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"
fi
cd - || exit 3
echo "miaou-bash refreshed from: $MIAOU_BASH_DIR"
}
# MAIN
[[ "$UID" -ne 0 ]] && echo 'root privilege required' && exit 1
current=$(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
# TODO: prevent refresh from development purpose
rm -rf "$MIAOU_BASH_DIR"
bootstrap
echo BEFORE init
miaou-bash "$MIAOU_BASH_DIR/lib/init.bash"
echo AFTER INIT
echo "miaou-bash successfully updated"
miaou-bash --version
fi