diff options
author | Renato Botelho <renato@netgate.com> | 2015-09-25 08:35:35 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2015-09-25 08:35:35 -0300 |
commit | 9346911f717bc7a89e36bb5dc5b3f72a226245b3 (patch) | |
tree | 544d2fa2a8e306d07f00b8decdd456727fafd776 /src/usr/local/sbin | |
parent | 7d26baf38a6fdbdddf256821d207d9c7ea57e556 (diff) | |
download | pfsense-9346911f717bc7a89e36bb5dc5b3f72a226245b3.zip pfsense-9346911f717bc7a89e36bb5dc5b3f72a226245b3.tar.gz |
Update repository metadata hourly
Diffstat (limited to 'src/usr/local/sbin')
-rwxr-xr-x | src/usr/local/sbin/pfSense-upgrade | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/usr/local/sbin/pfSense-upgrade b/src/usr/local/sbin/pfSense-upgrade index 892d5e7..75cff49 100755 --- a/src/usr/local/sbin/pfSense-upgrade +++ b/src/usr/local/sbin/pfSense-upgrade @@ -47,6 +47,7 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. pid_file="/var/run/$(basename $0).pid" +last_update_file="/var/run/$(basename $0)-last-update" logfile=/cf/conf/upgrade_log.txt # pkg should not ask for confirmations @@ -252,7 +253,26 @@ upgrade_second_step() { rm -f ${firmwarelock} } +update() { + _exec "pkg update" "Updating repositories" mute + date +%s > ${last_update_file} +} + upgrade() { + local _run_update=1 + if [ -f ${last_update_file} ]; then + local _last_update=$(head -n 1 ${last_update_file}) + if echo "${_last_update}" | grep -E -q '^[0-9]+$'; then + local _now=$(date +%s) + # Only run update hourly, and if last update is in the future + [ ${_now} -gt ${_last_update} -a $((${_now} - ${_last_update})) -le $((60 * 60)) ] \ + && unset _run_update + fi + fi + + [ -n "${_run_update}" ] \ + && update + unset need_reboot if [ ! -f "${upgrade_in_progress}" ]; then if [ -f "${logfile}" ]; then @@ -285,7 +305,7 @@ case "${action}" in upgrade ;; run_update) - _exec "pkg update" "Updating repositories" mute + update ;; *) _echo "ERROR: Invalid action!" |