devmode
This commit is contained in:
+1
-6
@@ -19,11 +19,6 @@ function assert_credentials {
|
||||
fi
|
||||
}
|
||||
|
||||
function assert_system_mode {
|
||||
[[ -L "$MIAOU_BASH_DIR" ]] && echo "already in develoment mode: $(realpath $MIAOU_BASH_DIR)" && return 3
|
||||
true
|
||||
}
|
||||
|
||||
function dev_mode {
|
||||
git clone "$GIT_URL"
|
||||
sudo rm "$MIAOU_BASH_DIR" -rf
|
||||
@@ -37,13 +32,13 @@ function assert_reachable_target {
|
||||
|
||||
# Main
|
||||
|
||||
source "$MIAOU_BASH_DIR"/lib/functions.bash
|
||||
assert_normal_user
|
||||
assert_system_mode
|
||||
assert_credentials
|
||||
name=$(echo "$GIT_URL" | cut -d/ -f2)
|
||||
name="${name%.git}"
|
||||
target="$PWD/$name"
|
||||
source "$MIAOU_BASH_DIR"/lib/functions.bash
|
||||
_confirm_destructive "target directory will be: ${target}"
|
||||
assert_reachable_target
|
||||
dev_mode
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
## library of useful functions, usually prefixed with '_'
|
||||
|
||||
## ASSERT Functions
|
||||
|
||||
function assert_root {
|
||||
[[ "$UID" -ne 0 ]] && echo 'root privilege required' && return 1
|
||||
true
|
||||
}
|
||||
|
||||
function assert_system_mode {
|
||||
[[ -L "$MIAOU_BASH_DIR" ]] && >&2 echo "ERROR: development mode: $(realpath $MIAOU_BASH_DIR)" && return 3
|
||||
true
|
||||
}
|
||||
## ===============
|
||||
## ARRAY Functions
|
||||
## ===============
|
||||
|
||||
+15
-9
@@ -18,20 +18,26 @@ function bootstrap {
|
||||
fi
|
||||
echo "miaou-bash refreshed from: $MIAOU_BASH_DIR"
|
||||
}
|
||||
# MAIN
|
||||
|
||||
[[ "$UID" -ne 0 ]] && echo 'root privilege required' && exit 1
|
||||
current=$(miaou-bash --version)
|
||||
latest=$("$MIAOU_BASH_DIR/tools/wget_semver" artcode miaou/miaou-bash)
|
||||
|
||||
if [[ "$current" == "$latest" ]]; then
|
||||
echo "up-to-date version: $current"
|
||||
else
|
||||
# TODO: prevent refresh from development purpose
|
||||
function self_upgrade {
|
||||
rm -rf "$MIAOU_BASH_DIR"
|
||||
bootstrap
|
||||
|
||||
. "$MIAOU_BASH_DIR/lib/init.bash"
|
||||
echo "miaou-bash successfully updated"
|
||||
miaou-bash --version
|
||||
}
|
||||
|
||||
# MAIN
|
||||
|
||||
source "$MIAOU_BASH_DIR"/lib/functions.bash
|
||||
assert_system_mode
|
||||
assert_root
|
||||
|
||||
current=$(miaou-bash --version)
|
||||
latest=$("$MIAOU_BASH_DIR/tools/wget_semver" artcode miaou/miaou-bash)
|
||||
if [[ "$current" == "$latest" ]]; then
|
||||
echo "up-to-date version: $current"
|
||||
else
|
||||
self_upgrade
|
||||
fi
|
||||
|
||||
+15
-6
@@ -1,13 +1,10 @@
|
||||
#!/usr/bin/env miaou-bash
|
||||
|
||||
# MAIN
|
||||
[[ "$UID" -ne 0 ]] && echo 'root privilege required' && exit 1
|
||||
# Constants
|
||||
|
||||
cd || exit
|
||||
# Functions
|
||||
|
||||
source "$MIAOU_BASH_DIR"/lib/functions.bash
|
||||
|
||||
if _confirm_destructive; then
|
||||
function uninstall {
|
||||
if [[ -f /etc/bash.bashrc.ORIGINAL ]]; then
|
||||
rm /etc/bash.bashrc
|
||||
mv /etc/bash.bashrc.ORIGINAL /etc/bash.bashrc
|
||||
@@ -23,4 +20,16 @@ if _confirm_destructive; then
|
||||
|
||||
unset MIAOU_BASH_DIR
|
||||
echo 'MIAOU-BASH fully uninstalled, restored from original'
|
||||
}
|
||||
|
||||
# Main
|
||||
|
||||
source "$MIAOU_BASH_DIR"/lib/functions.bash
|
||||
assert_system_mode
|
||||
assert_root
|
||||
cd || exit
|
||||
if _confirm_destructive; then
|
||||
uninstall
|
||||
else
|
||||
>&2 echo canceled && builtin exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user