#!/bin/bash ## CONSTANTS readonly CURDIR=$PWD readonly REQUIRED_PKGS=(file git bc) 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 pop_directory { popd || (echo "unable to pop from previous directory" && exit 1) } function root_required { [ "$(id -u)" -ne 0 ] && echo 'root privilege required' && exit 1 } ## MAIN root_required if [[ $CURDIR != '/opt/miaou-bash' ]]; 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 /opt/miaou-bash push_directory "$(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.sh" "$MIAOU_BASH_DIR/tools/idem_apt_install" "${REQUIRED_PKGS[@]}" ./init.sh fi