diff options
author | Aaron LI <aly@aaronly.me> | 2018-03-10 23:43:58 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2018-03-10 23:43:58 +0800 |
commit | 16eae64a973956a95bc6f2388aa8f5af75556db3 (patch) | |
tree | 9e1087386de78fe21b2b60108f6bfd8c713ddcfe | |
parent | f25d2060f4ed63585b9aae49e35794a0cba3643a (diff) | |
download | dfly-update-16eae64a973956a95bc6f2388aa8f5af75556db3.tar.bz2 |
Implement fly command for one-command upgrade procedure :)
XXX: Use global variables shared between cmd_status() and cmd_fly()
-rwxr-xr-x | dfly-update | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/dfly-update b/dfly-update index 9c8f171..b492196 100755 --- a/dfly-update +++ b/dfly-update @@ -78,6 +78,14 @@ NEW_SUF="__new__" # +# XXX: Variables share across two or more functions +# +_FILENAME= # The latest remote system image filename +_MD5= +_HAS_UPDATE= + + +# # Helper Functions # @@ -581,6 +589,8 @@ Usage: Install the new kernel, world, and config files cleanup Clean up obsolete files, umount and remove image file + fly + Synthetic command to upgrade the system! _EOF_ echo cmd_version @@ -620,6 +630,11 @@ _EOF_ else echo "??? Your DragonFly is newer than remote ???" fi + + # XXX: set the global variables for use in `cmd_fly()` + _FILENAME="${_filename}" + _MD5=${_md5} + _HAS_UPDATE=${has_update} } # Download the given image and check aginst the given MD5 @@ -691,6 +706,21 @@ cmd_cleanup() { postupgrade } +# Integrate all the upgrading steps -> fly :-) +cmd_fly() { + [ $# -eq 0 ] || \ + error ${EC_ARGS} "cmd_fly: invalid arguments: $@" + echo "Checking status ..." + cmd_status + if [ ${_HAS_UPDATE} -eq 1 ]; then + local file="${CACHE_DIR}/${_FILENAME}" + cmd_download "${_FILENAME}" ${_MD5} + cmd_mount ${file} + cmd_backup + cmd_upgrade + cmd_cleanup + fi +} # # Main @@ -707,7 +737,7 @@ case "${COMMAND}" in ;; status) shift - cmd_status "$@" + cmd_status ;; download) shift @@ -729,6 +759,10 @@ case "${COMMAND}" in shift cmd_cleanup ;; + fly|go) + shift + cmd_fly + ;; help|--help|-h|*) cmd_usage ;; |