|
|
|
@ -2,8 +2,34 @@ |
|
|
|
|
|
|
|
# CONSTANTS |
|
|
|
|
|
|
|
#FIXME: source from functions.bash |
|
|
|
readonly DESTINATION=/opt |
|
|
|
readonly MAIN_TAR_GZ_URL="https://git.artcode.re/miaou/miaou-bash/archive/main.tar.gz" |
|
|
|
|
|
|
|
# FUNCTIONS |
|
|
|
|
|
|
|
#FIXME: source from functions.bash |
|
|
|
function bootstrap { |
|
|
|
if [[ ! -d "$DESTINATION/miaou-bash" ]]; then |
|
|
|
local temp_dir |
|
|
|
temp_dir=$(mktemp -d) |
|
|
|
pushd "$temp_dir" >/dev/null || return 2 |
|
|
|
curl -s -O $MAIN_TAR_GZ_URL |
|
|
|
tar -xzf main.tar.gz --directory "$DESTINATION" |
|
|
|
echo "directory: miaou-bash successfully deployed to $DESTINATION" |
|
|
|
popd >/dev/null || return 3 |
|
|
|
fi |
|
|
|
|
|
|
|
local source_bin="$DESTINATION/miaou-bash/bin/miaou-bash" |
|
|
|
local dest_bin="/usr/bin/miaou-bash" |
|
|
|
if ! cmp -s "$source_bin" "$dest_bin"; then |
|
|
|
cp -f "$source_bin" "$dest_bin" |
|
|
|
echo "executable: /usr/bin/miaou-bash freshly created" |
|
|
|
fi |
|
|
|
|
|
|
|
export MIAOU_BASH_DIR="$DESTINATION/miaou-bash" |
|
|
|
} |
|
|
|
|
|
|
|
# MAIN |
|
|
|
|
|
|
|
[[ "$UID" -ne 0 ]] && echo 'root privilege required' && exit 1 |
|
|
|
@ -14,9 +40,8 @@ latest=$("$MIAOU_BASH_DIR/tools/wget_semver" artcode miaou/miaou-bash) |
|
|
|
if [[ "$current" == "$latest" ]]; then |
|
|
|
echo "up-to-date version: $current" |
|
|
|
else |
|
|
|
OLD_DIR="$MIAOU_BASH_DIR" |
|
|
|
export -n MIAOU_BASH_DIR |
|
|
|
unset MIAOU_BASH_DIR |
|
|
|
source "$OLD_DIR/install.sh" |
|
|
|
bootstrap |
|
|
|
miaou-bash "$MIAOU_BASH_DIR/lib/init.bash" |
|
|
|
echo "miaou-bash successfully updated" |
|
|
|
miaou-bash --version |
|
|
|
fi |