From 2ef7169ed59e1d25253aa3d5ca5001ac7ddabeb7 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Fri, 16 Jun 2017 22:18:28 +0200 Subject: [PATCH] Add dryrun option --- addon/lib/rmupdate.tcl | 8 ++++++-- addon/www/index.html | 8 +++++++- addon/www/rest.cgi | 11 ++++++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/addon/lib/rmupdate.tcl b/addon/lib/rmupdate.tcl index 5c1e515..ea30144 100644 --- a/addon/lib/rmupdate.tcl +++ b/addon/lib/rmupdate.tcl @@ -208,9 +208,13 @@ proc ::rmupdate::check_sizes {image} { write_log "Sizes of filesystems checked successfully." } -proc ::rmupdate::update_filesystems {image} { +proc ::rmupdate::update_filesystems {image {dryrun 0}} { variable mnt_new variable mnt_cur + set extra_args "" + if {$dryrun != 0} { + set extra_args "--dry-run" + } write_log "Updating filesystems." @@ -224,7 +228,7 @@ proc ::rmupdate::update_filesystems {image} { mount_system_partition $partition $mnt_cur write_log "Rsyncing filesystem of partition ${partition}." - set data [exec rsync --progress --archive --delete "${mnt_new}/" "${mnt_cur}"] + set data [exec rsync ${extra_args} --progress --archive --delete "${mnt_new}/" "${mnt_cur}"] write_log "Rsync finished." umount $mnt_new diff --git a/addon/www/index.html b/addon/www/index.html index a19981b..3fe3e1e 100644 --- a/addon/www/index.html +++ b/addon/www/index.html @@ -112,9 +112,10 @@ along with this program. If not, see . installation_running = version; $('[data-install-version="' + installation_running + '"]').addClass('loading'); var reboot = $('#reboot-after-install').is(':checked'); + var dryrun = $('#dryrun').is(':checked'); display_message('info', 'Installing firmware ' + version + '.', 6000000); clear_message(); - rest("POST", "/start_install_firmware", JSON.stringify({"version":version, "reboot":reboot}), + rest("POST", "/start_install_firmware", JSON.stringify({"version":version, "reboot":reboot, "dryrun":dryrun}), function(data) { $('[data-install-version="' + installation_running + '"]').removeClass('loading'); installation_running = ""; @@ -228,6 +229,11 @@ along with this program. If not, see . +
+ + +
+
diff --git a/addon/www/rest.cgi b/addon/www/rest.cgi index 0e653c5..f89ed66 100644 --- a/addon/www/rest.cgi +++ b/addon/www/rest.cgi @@ -50,6 +50,7 @@ proc process {} { } elseif {[lindex $path 1] == "start_install_firmware"} { regexp {\"version\"\s*:\s*\"([\d\.]+)\"} $data match version regexp {\"reboot\"\s*:\s*(true|false)} $data match reboot + regexp {\"dryrun\"\s*:\s*(true|false)} $data match dryrun if { [info exists version] && $version != "" } { if { ![info exists reboot] } { set reboot "true" @@ -59,7 +60,15 @@ proc process {} { } else { set reboot 0 } - return "\"[rmupdate::install_firmware_version $version $reboot]\"" + if { ![info exists reboot] } { + set dryrun "false" + } + if {$dryrun == "true"} { + set dryrun 1 + } else { + set dryrun 0 + } + return "\"[rmupdate::install_firmware_version $version $reboot $dryrun]\"" } else { error "Invalid version: ${data}" }