Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CISOfy/lynis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Boelen <michael.boelen@cisofy.com>2016-07-18 11:33:52 +0300
committerMichael Boelen <michael.boelen@cisofy.com>2016-07-18 11:33:52 +0300
commit6b9240723475c5c57f94f0bcabda9e82a4d41170 (patch)
treec7c8e31717c5e7ef2f45c6e99c0090f459f47fcc /include/helper_update
parentd02cb095da5851e20f55a6bba715715a03f93eb7 (diff)
Add 'update check' functionality
Diffstat (limited to 'include/helper_update')
-rw-r--r--include/helper_update26
1 files changed, 21 insertions, 5 deletions
diff --git a/include/helper_update b/include/helper_update
index a368aae5..8b93124e 100644
--- a/include/helper_update
+++ b/include/helper_update
@@ -235,7 +235,6 @@ if [ "$1" = "release" ]; then
${ECHOCMD} " "
${ECHOCMD} "Done"
${ECHOCMD} " "
- ExitClean
# Update check
elif [ "$1" = "info" ]; then
@@ -272,14 +271,31 @@ elif [ "$1" = "info" ]; then
echo "${PROGRAM_COPYRIGHT}"
echo ""
- # Quit program
- ExitClean
+# Check if there is an update, display status on screen and use exit code to tell status as well
+elif [ "$1" = "check" ]; then
+ # CV - Current Version, LV - Latest Version
+ PROGRAM_CV=$(echo ${PROGRAM_VERSION} | awk '{ print $1 }' | sed 's/[.]//g')
+ PROGRAM_LV=0
+ CheckUpdates
+ if [ "${PROGRAM_CV}" = "" -o "${PROGRAM_LV}" = "" ]; then PROGRAM_AC=0; PROGRAM_LV=0; fi
+ if [ ${PROGRAM_LV} -eq 0 ]; then
+ echo "status=unknown";
+ ExitCustom 1
+ elif [ ${PROGRAM_LV} -gt ${PROGRAM_CV} ]; then
+ echo "status=outdated";
+ ExitCustom 1
+ else
+ echo "status=up-to-date"
+ ExitClean
+ fi
else
- ${ECHOCMD} "${RED}Error: ${WHITE}Unknown parameter $1.${NORMAL} Aborting.."
- ExitFatal
+ ${ECHOCMD} "${RED}Error: ${WHITE}Unknown parameter $1.${NORMAL} Aborting.."
+ ExitFatal
fi
+ExitClean
+
QUIET=1
# The End