pvincent 4 days ago
parent
commit
4091d2142d
  1. 3
      README.md
  2. 12
      bin/miaou-bash
  3. 12
      lib/self-upgrade.bash

3
README.md

@ -31,11 +31,12 @@ Any feedback would be appreciated.
## install ## install
```bash ```bash
curl -s https://git.artcode.re/miaou/miaou-bash/raw/branch/main/install.sh | sudo bash && exec bash
curl -s https://git.artcode.re/miaou/miaou-bash/raw/branch/main/install.sh | sudo -E bash && exec bash
``` ```
## upgrade ## upgrade
TODO: self-upgrade
`upgrade-miaou-bash` `upgrade-miaou-bash`
## uninstall ## uninstall

12
bin/miaou-bash

@ -265,6 +265,14 @@ function on_error {
fi fi
} }
function self_upgrade {
sudo -E "$MIAOU_BASH_DIR/lib/self-upgrade.bash"
}
function uninstall {
echo "TODO: uninstall"
}
function populate_error_arrays { function populate_error_arrays {
local source=$1 line=$2 payload=$3 local source=$1 line=$2 payload=$3
@ -601,7 +609,7 @@ function cleanup {
} }
function usage { function usage {
echo "$(basename "$0") <SCRIPT> [...SCRIPT_ARGS] | --version | --help"
echo "$(basename "$0") <SCRIPT> [...SCRIPT_ARGS] | --version | --help | --self-upgrade | --uninstall"
} }
function parse_options { function parse_options {
@ -609,6 +617,8 @@ function parse_options {
[[ $# == 1 ]] && case "$1" in [[ $# == 1 ]] && case "$1" in
--help) usage && builtin exit ;; --help) usage && builtin exit ;;
--version) cat "$MIAOU_BASH_DIR/.semver_git_tag" && builtin exit ;; --version) cat "$MIAOU_BASH_DIR/.semver_git_tag" && builtin exit ;;
--self-upgrade) self_upgrade && builtin exit ;;
--uninstall) uninstall && builtin exit ;;
-*) >&2 echo "ERROR: option '$1' unknown!" && usage && builtin exit 2 ;; -*) >&2 echo "ERROR: option '$1' unknown!" && usage && builtin exit 2 ;;
esac esac
[[ $1 =~ ^- ]] && >&2 echo "ERROR: too many args $#, either single option or SCRIPT + args accepted!" && builtin exit 2 [[ $1 =~ ^- ]] && >&2 echo "ERROR: too many args $#, either single option or SCRIPT + args accepted!" && builtin exit 2

12
lib/self-upgrade.bash

@ -6,6 +6,14 @@
# MAIN # MAIN
[ "$UID" -ne 0 ] && echo 'root privilege required' && exit 1
[[ "$UID" -ne 0 ]] && echo 'root privilege required' && exit 1
echo TODO: 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"
MIAOU_BASH_DIR='' source ../install.sh
else
MIAOU_BASH_DIR='' source ../install.sh
fi
Loading…
Cancel
Save