new install

This commit is contained in:
pvincent
2026-08-06 22:09:42 +04:00
parent 556fad02df
commit 359e57e900
3 changed files with 32 additions and 61 deletions
+18 -43
View File
@@ -2,56 +2,31 @@
## CONSTANTS
readonly MAIN_TAR_GZ_URL="https://git.artcode.re/miaou/miaou-bash/archive/main.tar.gz"
readonly DESTINATION=/opt/miaou-bash
readonly REQUIRED_PKGS=(file jq)
readonly MAIN_TAR_GZ_URL="https://git.artcode.re/miaou/miaou-bash/archive/main.tar.gz"
## FUNCTIONS
function push_directory {
pushd "$1" || (echo "unable to push directory <$1>" && exit 1)
}
function bootstrap {
if [[ ! -d "$DESTINATION" ]]; then
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
function pop_directory {
popd || (echo "unable to pop from previous directory" && exit 1)
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
[[ "$UUID" -ne 0 ]] && echo 'root privilege required' && exit 1
[[ "$UID" -ne 0 ]] && echo 'root privilege required' && exit 1
if [[ -v MIAOU_BASH_DIR ]]; then
miaou-bash "$MIAOU_BASH_DIR/init.sh"
else
MIAOU_BASH_DIR="$DESTINATION"
export MIAOU_BASH_DIR
cd "$(mktemp -d)"
curl --no-progress-meter -O $MAIN_TAR_GZ_URL
fi
if [[ $PWD != "$DESTINATION" ]]; then
# download and fullfill /opt/miaou-bash, then run it from folder
if [[ -L /opt/miaou-bash ]]; then
/opt/miaou-bash/install.sh
else
rm -rf "$DESTINATION"
pushd "$(mktemp -d)"
curl --no-progress-meter -O $MAIN_TAR_GZ_URL
tar -xzf main.tar.gz
mv miaou-bash /opt/
pop_directory
rm -rf "$TEMP"
push_directory /opt/miaou-bash && ./install.sh
fi
else
MIAOU_BASH_DIR=$CURDIR
export MIAOU_BASH_DIR
source "$MIAOU_BASH_DIR/lib/functions.bash"
"$MIAOU_BASH_DIR/tools/idem_apt_install" "${REQUIRED_PKGS[@]}"
./init.sh
fi
[[ -v MIAOU_BASH_DIR ]] || bootstrap
miaou-bash "$MIAOU_BASH_DIR/lib/init.bash"