Commit 418e65bb684d78ad5eb196c16c8f0ff154020f14
1 parent
b41699d8
renamed fileto to filestore (makes more sense)
resolved issue with determining upon upload whether we're dealing with the startup-config, this is now based on the destination file name (which is correct), fixes #5
Showing
1 changed file
with
9 additions
and
7 deletions
sync-router
100644 → 100755
... | ... | @@ -29,7 +29,7 @@ |
29 | 29 | router=`basename \`dirname $0 | pwd\`` # name of router - based on directory |
30 | 30 | dhcpfiles=dhcp-\* # list/pattern of dhcp lease files |
31 | 31 | imagefiles=c??00-universalk9-mz.SPA.\* # list/pattern of IOS image files |
32 | -fileto=flash # location of dhcp/IOS files on cisco | |
32 | +filestore=flash # location of dhcp/IOS files on cisco | |
33 | 33 | |
34 | 34 | ### Implementation ### |
35 | 35 | echo updating with $router |
... | ... | @@ -41,9 +41,10 @@ echo updating with $router |
41 | 41 | router_file_download() { |
42 | 42 | fromfile=${1?ERROR: at least one filename is required to copy from router} |
43 | 43 | tofile=${2:-$fromfile} |
44 | - filesrc=$fileto | |
45 | 44 | if [ "$fromfile" == startup-config ]; then |
46 | 45 | filesrc=nvram |
46 | + else | |
47 | + filesrc=$filestore | |
47 | 48 | fi |
48 | 49 | echo downloading $tofile from router $filesrc |
49 | 50 | scp -q $router:$filesrc:$fromfile $tofile |
... | ... | @@ -57,9 +58,10 @@ router_file_download() { |
57 | 58 | router_file_upload() { |
58 | 59 | fromfile=${1?ERROR: at least one filename is required to copy to router} |
59 | 60 | tofile=${2:-$fromfile} |
60 | - filedst=$fileto | |
61 | - if [ "$fromfile" == startup-config ]; then | |
61 | + if [ "$tofile" == startup-config ]; then | |
62 | 62 | filedst=nvram |
63 | + else | |
64 | + filedst=$filestore | |
63 | 65 | fi |
64 | 66 | echo uploading new/updated $tofile to router $filedst |
65 | 67 | scp -q $fromfile $router:$filedst:$tofile |
... | ... | @@ -74,7 +76,7 @@ router_file_upload() { |
74 | 76 | router_file_remove() { |
75 | 77 | delfile=${1?ERROR: need a filename to remove from router} |
76 | 78 | echo removing $delfile as it is no longer in the repository |
77 | - ssh -q $router "delete /force $fileto:$delfile" | |
79 | + ssh -q $router "delete /force $filestore:$delfile" | |
78 | 80 | } |
79 | 81 | |
80 | 82 | |
... | ... | @@ -161,9 +163,9 @@ done |
161 | 163 | |
162 | 164 | # Update the boot images in the startup-config file if we're updating any images |
163 | 165 | if git status -s "$imagefiles" | egrep -q ^[MADR]; then |
164 | - fgrep -n "boot system $fileto" startup-config | cut -d: -f1 > .startup-config.$$.lines | |
166 | + fgrep -n "boot system $filestore" startup-config | cut -d: -f1 > .startup-config.$$.lines | |
165 | 167 | head -$[ `head -1 .startup-config.$$.lines` -1 ] startup-config > .startup-config.$$ |
166 | - git ls-files $imagefiles | sort -r | sed "s/^/boot system $fileto /g" >> .startup-config.$$ | |
168 | + git ls-files $imagefiles | sort -r | sed "s/^/boot system $filestore /g" >> .startup-config.$$ | |
167 | 169 | tail +$[ `tail -1 .startup-config.$$.lines` +1 ] startup-config >> .startup-config.$$ |
168 | 170 | rm .startup-config.$$.lines |
169 | 171 | router_file_upload .startup-config.$$ startup-config |
... | ... |