mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-29 10:10:19 +00:00
upgrades: Run distribution upgrade at around 06:00 everyday
- Instead of an arbitrary time decided by when FreedomBox service as started. Tests: - Add a log message before return statement. Set the system clock to 02:00 and start service in debug mode. Wait for 3 minutes. The timer is triggered but nothings happens. - Set the system clock to 06:10 and start service in debug mode. Wait for 3 minutes and a distribution upgrade check is performed and a message is printed. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
e039f9f061
commit
fecccd20a8
@ -43,6 +43,8 @@ BACKPORTS_REQUESTED_KEY = 'upgrades_backports_requested'
|
|||||||
|
|
||||||
DIST_UPGRADE_ENABLED_KEY = 'upgrades_dist_upgrade_enabled'
|
DIST_UPGRADE_ENABLED_KEY = 'upgrades_dist_upgrade_enabled'
|
||||||
|
|
||||||
|
DIST_UPGRADE_RUN_HOUR = 6 # 06:00 (morning)
|
||||||
|
|
||||||
PKG_HOLD_DIAG_CHECK_ID = 'upgrades-package-holds'
|
PKG_HOLD_DIAG_CHECK_ID = 'upgrades-package-holds'
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -100,9 +102,9 @@ class UpgradesApp(app_module.App):
|
|||||||
# selected by user.
|
# selected by user.
|
||||||
glib.schedule(24 * 3600, setup_repositories)
|
glib.schedule(24 * 3600, setup_repositories)
|
||||||
|
|
||||||
# Check every day if new stable release becomes available, then perform
|
# Check every day if new stable release becomes available and if we
|
||||||
# dist-upgrade if updates are enabled
|
# waited enough, then perform dist-upgrade if updates are enabled.
|
||||||
glib.schedule(24 * 3600, check_dist_upgrade)
|
glib.schedule(3600, check_dist_upgrade)
|
||||||
|
|
||||||
def _show_new_release_notification(self):
|
def _show_new_release_notification(self):
|
||||||
"""When upgraded to new release, show a notification."""
|
"""When upgraded to new release, show a notification."""
|
||||||
@ -214,6 +216,12 @@ def setup_repositories(_):
|
|||||||
|
|
||||||
def check_dist_upgrade(_):
|
def check_dist_upgrade(_):
|
||||||
"""Check for upgrade to new stable release."""
|
"""Check for upgrade to new stable release."""
|
||||||
|
# Run once a day at a desired hour even when triggered every hour. There is
|
||||||
|
# a small chance that this won't run in a given day.
|
||||||
|
now = datetime.datetime.now() # Local timezone
|
||||||
|
if now.hour != DIST_UPGRADE_RUN_HOUR:
|
||||||
|
return
|
||||||
|
|
||||||
if is_dist_upgrade_enabled():
|
if is_dist_upgrade_enabled():
|
||||||
status = distupgrade.get_status()
|
status = distupgrade.get_status()
|
||||||
starting = status['next_action'] in ('continue', 'ready')
|
starting = status['next_action'] in ('continue', 'ready')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user