migrated repository to my new Gitea instance
updated version and copyright updated pattern for Cisco IOS images to support a wider range of image files updated SCP SCP command deal with OpenSSH 9 change to new sftp engine ensure date returns US English date formats stop forcing upload of startup-config to nvram (honor config variable)
This commit is contained in:
@@ -6,10 +6,10 @@ benefit from these as well. Use them freely and please let me know is you
|
||||
encounter any issues or require changes.
|
||||
|
||||
The latest versions, documentation and bugtracker available on my
|
||||
[GitLab instance](https://gitlab.lindenaar.net/scripts/cisco)
|
||||
[Gitea instance](https://gitea.lindenaar.net/scripts/cisco)
|
||||
|
||||
Copyright (c) 2016 Frederik Lindenaar. free for distribution under the GNU
|
||||
License, see [below](#license)
|
||||
Copyright (c) 2016 - 2025 Frederik Lindenaar. free for distribution under the
|
||||
GNU License, see [below](#license)
|
||||
|
||||
|
||||
sync-router
|
||||
|
||||
24
sync-router
24
sync-router
@@ -10,9 +10,9 @@
|
||||
# repository, update startup-config file accordingly on router
|
||||
# - commit changes to the git repository
|
||||
#
|
||||
# Version 1.2, latest version at: https://gitlab.lindenaar.net/scripts/cisco
|
||||
# Version 1.3, latest version at: https://gitea.lindenaar.net/scripts/cisco
|
||||
#
|
||||
# Copyright (c) 2016 Frederik Lindenaar
|
||||
# Copyright (c) 2016 - 2025 Frederik Lindenaar
|
||||
#
|
||||
# This script is free software: you can redistribute and/or modify it under the
|
||||
# terms of version 3 of the GNU General Public License as published by the Free
|
||||
@@ -28,9 +28,15 @@
|
||||
### Configuration ###
|
||||
router=`basename \`dirname $0 | pwd\`` # name of router - based on directory
|
||||
dhcpfiles=dhcp-\* # list/pattern of dhcp lease files
|
||||
imagefiles=c\*-mz.\*.bin # list/pattern of IOS image files
|
||||
imagefiles=c[0-9][0-9][0-9]\*-\*.bin # list/pattern of IOS image files
|
||||
filestore=flash # location of dhcp/IOS files on cisco
|
||||
|
||||
### Configure SCP command due to OpenSSH 9 change
|
||||
SCP='scp -OTq'
|
||||
|
||||
### Ensure date returns US English date formats
|
||||
export LANG=en_US.UTF-8
|
||||
|
||||
### Implementation ###
|
||||
echo updating with $router
|
||||
|
||||
@@ -54,7 +60,7 @@ router_file_download() {
|
||||
filesrc=$filestore
|
||||
fi
|
||||
echo downloading $tofile from router $filesrc
|
||||
if scp -q $router:$filesrc:$fromfile $tofile; then
|
||||
if $SCP $router:$filesrc:$fromfile $tofile; then
|
||||
git add $tofile
|
||||
else
|
||||
fail "download of $tofile failed"
|
||||
@@ -68,13 +74,9 @@ router_file_download() {
|
||||
router_file_upload() {
|
||||
fromfile=${1?ERROR: at least one filename is required to copy to router}
|
||||
tofile=${2:-$fromfile}
|
||||
if [ "$tofile" == startup-config ]; then
|
||||
filedst=nvram
|
||||
else
|
||||
filedst=$filestore
|
||||
fi
|
||||
echo uploading new/updated $tofile to router $filedst
|
||||
if scp -q $fromfile $router:$filedst:$tofile; then
|
||||
if $SCP $fromfile $router:$filedst:$tofile; then
|
||||
if [ "$fromfile" != "$tofile" ]; then
|
||||
mv $fromfile $tofile
|
||||
git add $tofile
|
||||
@@ -112,7 +114,7 @@ do
|
||||
router_file_remove $filename
|
||||
router_file_upload $newfilename
|
||||
;;
|
||||
A |M|MM)
|
||||
A|M|MM)
|
||||
echo updating and uploading modified file $filename
|
||||
head -2 $filename | while read tag value
|
||||
do
|
||||
@@ -166,7 +168,7 @@ do
|
||||
D)
|
||||
router_file_remove $filename
|
||||
;;
|
||||
A |M)
|
||||
A|M)
|
||||
router_file_upload $filename
|
||||
;;
|
||||
*)
|
||||
|
||||
Reference in New Issue
Block a user