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.

33 lines
824 B

#!/usr/bin/env bash
## CONSTANTS
readonly DESTINATION=/opt/miaou-bash
readonly MAIN_TAR_GZ_URL="https://git.artcode.re/miaou/miaou-bash/archive/main.tar.gz"
## FUNCTIONS
function bootstrap {
if [[ ! -d "$DESTINATION" ]]; then
mkdir -p "$DESTINATION"
local temp_dir
temp_dir=$(mktemp -d)
pushd "$temp_dir" || return 2
curl --no-progress-meter -O $MAIN_TAR_GZ_URL
tar -xzf main.tar.gz --directory "$DESTINATION"
popd || return 3
fi
local source_bin="$MIAOU_BASH_DIR/bin/miaou-bash"
local dest_bin="/usr/bin/miaou-bash"
cmp -s "$source_bin" "$dest_bin" || cp -f "$source_bin" "$dest_bin"
export MIAOU_BASH_DIR="$DESTINATION"
}
## MAIN
[[ "$UID" -ne 0 ]] && echo 'root privilege required' && exit 1
[[ -v MIAOU_BASH_DIR ]] || bootstrap
miaou-bash "$MIAOU_BASH_DIR/lib/init.bash"