fix
This commit is contained in:
+29
-4
@@ -2,8 +2,34 @@
|
|||||||
|
|
||||||
# CONSTANTS
|
# 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
|
# 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
|
# MAIN
|
||||||
|
|
||||||
[[ "$UID" -ne 0 ]] && echo 'root privilege required' && exit 1
|
[[ "$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
|
if [[ "$current" == "$latest" ]]; then
|
||||||
echo "up-to-date version: $current"
|
echo "up-to-date version: $current"
|
||||||
else
|
else
|
||||||
OLD_DIR="$MIAOU_BASH_DIR"
|
bootstrap
|
||||||
export -n MIAOU_BASH_DIR
|
miaou-bash "$MIAOU_BASH_DIR/lib/init.bash"
|
||||||
unset MIAOU_BASH_DIR
|
echo "miaou-bash successfully updated"
|
||||||
source "$OLD_DIR/install.sh"
|
|
||||||
miaou-bash --version
|
miaou-bash --version
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user