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