<!DOCTYPE html><html><head><title></title></head><body><div>The -r option to rancid-run/control_rancid currently accepts a single</div><div>device.  Passing -r more than once silently keeps only the last device,</div><div>because control_rancid overwrites $device on each occurrence of the flag.</div><div><br></div><div>This patch accumulates the device names and filters routers.up against</div><div>all of them, so several specific devices can be collected in one run</div><div>without collecting the whole group.  Devices in the same group are</div><div>collected and committed together; a group that contains none of the</div><div>requested devices is skipped, as before.  A single -r behaves exactly as</div><div>it does today, so existing usage and cron jobs are unaffected.</div><div><br></div><div>rancid-run already passes repeated -r flags through to control_rancid</div><div>untouched, so the change is confined to control_rancid; rancid-run needed</div><div>no code change.  Man pages and CHANGES are updated.</div><div><br></div><div>I've also opened this as a GitHub PR for convenience:</div><div>  <a href="https://github.com/haussli/rancid/pull/80">https://github.com/haussli/rancid/pull/80</a></div><div><br></div><div>Patch against current master (commit 7dc63e64) inline below and attached</div><div>as a git-am-able patch.</div><div><br></div><div>---</div><div>CHANGES               | 4 ++++</div><div>bin/control_rancid.in | 13 ++++++++-----</div><div>man/control_rancid.1  | 4 +++-</div><div>man/rancid-run.1      | 3 +++</div><div>4 files changed, 18 insertions(+), 6 deletions(-)</div><div><br></div><div>diff --git a/CHANGES b/CHANGES</div><div>index ..</div><div>--- a/CHANGES</div><div>+++ b/CHANGES</div><div>@@ -1,4 +1,8 @@</div><div>3.14.99</div><div>+     control_rancid, rancid-run: allow -r to be specified multiple times to</div><div>+     collect several devices in one run, committing per-group devices</div><div>+     together - Gary T. Giesen</div><div>+</div><div>      iosxr.pm: filter oscillating license timestamps - thezoggy@github with</div><div>      minor syntax adjustment</div><div><br></div><div>diff --git a/bin/control_rancid.in b/bin/control_rancid.in</div><div>index ..</div><div>--- a/bin/control_rancid.in</div><div>+++ b/bin/control_rancid.in</div><div>@@ -102,8 +102,8 @@ if [ $# -ge 1 ] ; then</div><div>          ;;</div><div>      -r)</div><div>          shift</div><div>-         # next arg is the device name</div><div>-         device="$1"</div><div>+         # next arg is a device name; -r may be given multiple times</div><div>+         device="${device:+$device }$1"</div><div>          shift</div><div>          ;;</div><div>      --)</div><div>@@ -549,12 +549,15 @@ if [ ! -s routers.up ] ; then</div><div>     exit;</div><div>fi</div><div><br></div><div>-# if a device (-r) was specified, see if that device is in this group</div><div>+# if device(s) (-r) were specified, see if those devices are in this group</div><div>if [ "X$device" != "X" ] ; then</div><div>     trap 'rm -fr $TMP $DIR/routers.single;' 1 2 15</div><div>     devlistfile="$DIR/routers.single"</div><div>-    grep -i "^$device\;" routers.up > $devlistfile</div><div>-    if [ $? -eq 1 ] ; then</div><div>+    : > $devlistfile</div><div>+    for dev in $device ; do</div><div>+     grep -i "^$dev\;" routers.up >> $devlistfile</div><div>+    done</div><div>+    if [ ! -s $devlistfile ] ; then</div><div>      exit;</div><div>     fi</div><div>else</div><div>diff --git a/man/control_rancid.1 b/man/control_rancid.1</div><div>index ..</div><div>--- a/man/control_rancid.1</div><div>+++ b/man/control_rancid.1</div><div>@@ -63,8 +63,10 @@ may be specified multiple times.</div><div>.\"</div><div>.TP</div><div>.B \-r device_name</div><div>-Specify the name, as it appears in the router.db, of a particular device</div><div>+Specify the name, as it appears in the router.db, of a particular device</div><div>to collect and generate diffs for.  The device must be marked "up".</div><div>+.B \-r</div><div>+may be specified multiple times to collect several devices in a single run.</div><div>.sp</div><div>The</div><div>.B \-r</div><div>diff --git a/man/rancid-run.1 b/man/rancid-run.1</div><div>index ..</div><div>--- a/man/rancid-run.1</div><div>+++ b/man/rancid-run.1</div><div>@@ -92,6 +92,9 @@ Run rancid for a single device,</div><div>should be name, as it appears in a group's router.db.  The device must be</div><div>marked "up".  If a group is not specified on the command-line, rancid will</div><div>be run against any group in which the device_name appears.</div><div>+.B \-r</div><div>+may be specified multiple times to collect several devices; those found in</div><div>+the same group are collected and committed together in that group's run.</div><div>.sp</div><div>The</div><div>.B \-r</div><div><br></div><div>Thanks,</div><div>Gary T. Giesen</div></body></html>