summaryrefslogtreecommitdiffstats
path: root/src/usr/local/sbin
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2015-11-05 15:28:31 -0200
committerRenato Botelho <renato@netgate.com>2015-11-05 15:28:39 -0200
commite8ef8dd8b24e5e934911288645f09a9b5955cd06 (patch)
tree5a24f0f5951acec06ffba678eeb3eb28da73e503 /src/usr/local/sbin
parent7e4b9edd77b690cf2bc27d98a68a9542fbbb31ae (diff)
downloadpfsense-e8ef8dd8b24e5e934911288645f09a9b5955cd06.zip
pfsense-e8ef8dd8b24e5e934911288645f09a9b5955cd06.tar.gz
Add a new option to pfSense-upgrade, -c, it'll return 0 if system firmware is up2date or -1 if there are updates available
Diffstat (limited to 'src/usr/local/sbin')
-rwxr-xr-xsrc/usr/local/sbin/pfSense-upgrade31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/usr/local/sbin/pfSense-upgrade b/src/usr/local/sbin/pfSense-upgrade
index a61018f..fbf6e59 100755
--- a/src/usr/local/sbin/pfSense-upgrade
+++ b/src/usr/local/sbin/pfSense-upgrade
@@ -51,6 +51,7 @@ usage() {
echo " -4 - Force IPv4"
echo " -6 - Force IPv6"
echo " -b - Platform is booting" >&2
+ echo " -c - Check if upgrade is necessary" >&2
echo " -d - Turn on debug" >&2
echo " -f - Force package installation" >&2
echo " -h - Show this usage help" >&2
@@ -408,6 +409,28 @@ pkg_upgrade() {
fi
}
+check_upgrade() {
+ # figure out main meta package name
+ if is_pkg_installed ${product}-vmware; then
+ local _meta_pkg="${product}-vmware"
+ elif is_pkg_installed ${product}; then
+ local _meta_pkg="${product}"
+ else
+ _echo "ERROR: It was not possible to identify which ${product} meta package is installed"
+ _exit 1
+ fi
+
+ pkg_update
+
+ if [ "$(compare_pkg_version ${_meta_pkg})" = "<" ]; then
+ _echo "A new ${product} version is available"
+ _exit -1
+ else
+ _echo "Your system is up to date"
+ _exit 0
+ fi
+}
+
setup_nanobsd_env() {
if [ "${platform}" != "nanobsd" ]; then
return;
@@ -604,7 +627,7 @@ unset action
unset action_pkg
unset force_ipv4
unset force_ipv6
-while getopts 46b:dfi:hp:l:r:uy opt; do
+while getopts 46b:cdfi:hp:l:r:uy opt; do
case ${opt} in
4)
if [ -n "${force_ipv6}" ]; then
@@ -624,6 +647,9 @@ while getopts 46b:dfi:hp:l:r:uy opt; do
booting=1
boot_stage="${OPTARG}"
;;
+ c)
+ action="check"
+ ;;
d)
stdout=''
;;
@@ -714,6 +740,9 @@ if [ -e "${progress_file}" ]; then
fi
case "${action}" in
+ check)
+ check_upgrade
+ ;;
upgrade)
pkg_upgrade
;;
OpenPOWER on IntegriCloud