huge longrun improvements
This commit is contained in:
@@ -40,14 +40,40 @@ export ARCH_URL="$BASE_URL/archive/master.tar.gz"
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Check for profile updates
|
||||
# ------------------------------------------------------------------------------
|
||||
# Usage: check_updates [-q]
|
||||
# If -q is specified, the function will operate in quiet mode (internal use only)
|
||||
check_updates()
|
||||
{
|
||||
if [[ $1 == "-q" ]]; then
|
||||
# Quiet mode is mostly used internally when profile_upgrade is called
|
||||
quiet=1
|
||||
local quiet=0
|
||||
local PARSED=$(getopt -o hq --long help,quiet -n 'check_updates' -- "$@")
|
||||
if [[ $? -ne 0 ]]; then
|
||||
disp E "Invalid options, use \"check_updates --help\" to display usage."
|
||||
return 1
|
||||
fi
|
||||
[[ -n $quiet ]] && disp I "Checking for updates..."
|
||||
eval set -- "$PARSED"
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
printf "check_updates: Check for new versions.\n\n"
|
||||
printf "Usage: check_updates\n"
|
||||
return 0
|
||||
;;
|
||||
-q|--quiet)
|
||||
quiet=1
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ $quiet != 1 ]] && disp I "Checking for updates..."
|
||||
local vfile="/tmp/version"
|
||||
wget "$UPDT_URL/version" -O $vfile >/dev/null 2>&1 || {
|
||||
disp E "Can't download version file, impossible to proceed!"
|
||||
@@ -58,10 +84,10 @@ check_updates()
|
||||
local lastver=$(cat $vfile)
|
||||
if [[ $lastver != $PROFVERSION ]]; then
|
||||
disp I "You have version $PROFVERSION installed. Version $lastver is available."
|
||||
[[ $quiet ]] && disp I "You should upgrade to last version when possible."
|
||||
[[ $quiet != 1 ]] && disp I "You should upgrade to last version when possible."
|
||||
result=1
|
||||
else
|
||||
[[ -n $quiet ]] && disp I "Your version is up-to-date."
|
||||
[[ $quiet != 1 ]] && disp I "Your version is up-to-date."
|
||||
result=0
|
||||
fi
|
||||
rm -f $vfile
|
||||
@@ -71,12 +97,38 @@ check_updates()
|
||||
unset lastver vfile
|
||||
return $result
|
||||
}
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Apply update to profile
|
||||
# ------------------------------------------------------------------------------
|
||||
# Usage: profile_upgrade
|
||||
profile_upgrade()
|
||||
{
|
||||
local PARSED=$(getopt -o h --long help -n 'profile_upgrade' -- "$@")
|
||||
if [[ $? -ne 0 ]]; then
|
||||
printf "Invalid options, use \"profile_upgrade --help\" to display usage."
|
||||
return 1
|
||||
fi
|
||||
eval set -- "$PARSED"
|
||||
while true; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
printf "profile_upgrade: Upgrade the profile to the latest version.\n\n"
|
||||
printf "Usage: profile_upgrade\n"
|
||||
return 0
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
disp E "Invalid options, use \"profile_upgrade --help\" to display usage."
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if check_updates -q; then
|
||||
disp "No update available."
|
||||
return 0
|
||||
@@ -130,4 +182,7 @@ profile_upgrade()
|
||||
rm -rf "$tmpdir"
|
||||
fi
|
||||
}
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
# EOF
|
||||
|
||||
Reference in New Issue
Block a user