diff options
Diffstat (limited to 'src/usr/local/sbin/pfSense-upgrade')
-rwxr-xr-x | src/usr/local/sbin/pfSense-upgrade | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/src/usr/local/sbin/pfSense-upgrade b/src/usr/local/sbin/pfSense-upgrade index 65a0e04..11f970d 100755 --- a/src/usr/local/sbin/pfSense-upgrade +++ b/src/usr/local/sbin/pfSense-upgrade @@ -176,8 +176,9 @@ pkg_with_pb() { fi pkg ${_event_pipe} $@ + local _pkg_result=$? nc_pid="" - return $? + return ${_pkg_result} } fetch_upgrade_packages() { @@ -618,10 +619,21 @@ pkg_install() { local _msg="Installing" fi - _exec "pkg_with_pb ${_cmd} ${_pkg_name}" "${_msg} ${_pkg_name}" + _exec "pkg_with_pb ${_cmd}${dry_run:+ }${dry_run} ${_pkg_name}" "${_msg} ${_pkg_name}" _exec "pkg clean" "Cleaning up cache" mute ignore_result } +# Reinstall every pfSense-pkg-* package +pkg_reinstall_all() { + for _pkg in $(pkg query -e '%a == 0' %n); do + case ${_pkg} in "${pkg_prefix}"* ) + _echo "Reinstalling ${_pkg}" + pkg_install ${_pkg} 1 + ;; + esac + done +} + pkg_delete() { local _pkg_name="${1}" @@ -635,16 +647,16 @@ pkg_delete() { _exit 1 fi - _exec "pkg_with_pb delete ${_pkg_name}" "Removing ${_pkg_name}" + _exec "pkg_with_pb delete${dry_run:+ }${dry_run} ${_pkg_name}" "Removing ${_pkg_name}" _exec "pkg autoremove" "Removing stale packages" mute ignore_result } -# Reinstall every pfSense-pkg-* package -pkg_reinstall_all() { +# Delete every pfSense-pkg-* package +pkg_delete_all() { for _pkg in $(pkg query -e '%a == 0' %n); do case ${_pkg} in "${pkg_prefix}"* ) - _echo "Reinstalling ${_pkg}" - pkg_install ${_pkg} 1 + _echo "Removing ${_pkg}" + pkg_delete ${_pkg} ;; esac done @@ -762,7 +774,7 @@ while getopts 46b:cdfi:hp:l:nr:Ruy opt; do fi ;; n) - dry_run=1 + dry_run="-n" ;; p) progress_socket="${OPTARG}" @@ -817,6 +829,10 @@ if [ -z "${booting}" -o "${boot_stage}" != "2" ]; then /etc/rc.conf_mount_rw fi +if [ -n "${booting}" ]; then + export REPO_AUTOUPDATE=false +fi + echo $$ > ${pid_file} trap _exit 1 2 15 EXIT @@ -849,7 +865,11 @@ case "${action}" in fi ;; delete) - pkg_delete ${action_pkg} + if [ ${action_pkg} == "ALL_PACKAGES" ] && [ -n ${force} ]; then + pkg_delete_all + else + pkg_delete ${action_pkg} + fi ;; *) _echo "ERROR: Invalid action!" |