Advertisement
Guest User

Untitled

a guest
Aug 31st, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1. #! /usr/bin/perl
  2. ##
  3. ## $Id: rancid-fe.in 3577 2016-12-27 20:23:23Z hank $
  4. ##
  5. ## rancid 3.7
  6. ## Copyright (c) 1997-2017 by Henry Kilmer and John Heasley
  7. ## All rights reserved.
  8. ##
  9. ## This code is derived from software contributed to and maintained by
  10. ## Henry Kilmer, John Heasley, Andrew Partan,
  11. ## Pete Whiting, Austin Schutz, and Andrew Fort.
  12. ##
  13. ## Redistribution and use in source and binary forms, with or without
  14. ## modification, are permitted provided that the following conditions
  15. ## are met:
  16. ## 1. Redistributions of source code must retain the above copyright
  17. ## notice, this list of conditions and the following disclaimer.
  18. ## 2. Redistributions in binary form must reproduce the above copyright
  19. ## notice, this list of conditions and the following disclaimer in the
  20. ## documentation and/or other materials provided with the distribution.
  21. ## 3. All advertising materials mentioning features or use of this software
  22. ## must display the following acknowledgement:
  23. ## This product includes software developed by Henry Kilmer and John
  24. ## Heasley and its contributors for RANCID.
  25. ## 4. Neither the name of RANCID nor the names of its
  26. ## contributors may be used to endorse or promote products derived from
  27. ## this software without specific prior written permission.
  28. ## 5. It is requested that non-binding fixes and modifications be contributed
  29. ## back to RANCID.
  30. ##
  31. ## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley AND CONTRIBUTORS
  32. ## ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  33. ## TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  34. ## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COMPANY OR CONTRIBUTORS
  35. ## BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  36. ## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  37. ## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  38. ## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  39. ## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  40. ## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  41. ## POSSIBILITY OF SUCH DAMAGE.
  42. ##
  43. ## It is the request of the authors, but not a condition of license, that
  44. ## parties packaging or redistributing RANCID NOT distribute altered versions
  45. ## of the etc/rancid.types.base file nor alter how this file is processed nor
  46. ## when in relation to etc/rancid.types.conf. The goal of this is to help
  47. ## suppress our support costs. If it becomes a problem, this could become a
  48. ## condition of license.
  49. #
  50. # rancid-FE - front-end to rancid/jrancid/etc. for use with par.
  51. #
  52. # usage: rancid-fe <router>;<vendor>
  53. #
  54.  
  55. require 5;
  56.  
  57. my($script);
  58. my($router, $devtype) = split('\;', $ARGV[0]);
  59. $devtype =~ tr/[A-Z]/[a-z]/;
  60. if (! length($devtype)) {
  61. printf(STDERR "unknown router manufacturer for $router: $devtype\n");
  62. exit(-1);
  63. }
  64. # XXX use rancid::loadtype() to parse these files.
  65. foreach $file ("/etc/rancid/rancid.types.base",
  66. "/etc/rancid/rancid.types.conf") {
  67. open(INPUT, "< $file") || die "Could not open $file: $!";
  68. while (<INPUT>) {
  69. chomp;
  70. my($type, $directive, $value) = split('\;');
  71. $type =~ tr/[A-Z]/[a-z]/;
  72. $directive =~ tr/[A-Z]/[a-z]/;
  73. if ($type eq $devtype && $directive eq "script") {
  74. $script = $value;
  75. close(INPUT);
  76. goto FOUND;
  77. }
  78. }
  79. close(INPUT);
  80. }
  81.  
  82. FOUND:
  83. if (! defined($script)) {
  84. printf(STDERR "unknown router manufacturer for $router: $devtype\n");
  85. exit(-1);
  86. } else {
  87. exec($script . " $router");
  88. }
  89.  
  90. printf(STDERR "exec($script) failed router manufacturer $devtype: $!\n");
  91. exit(-1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement