From b82899d11a1551c153c040ca221339770b63529f Mon Sep 17 00:00:00 2001 From: Frederik Lindenaar Date: Sat, 27 Dec 2025 21:18:02 +0100 Subject: [PATCH] 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) --- README.md | 6 +++--- sync-router | 32 +++++++++++++++++--------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 0f5f058..31948fe 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/sync-router b/sync-router index f1dce27..ef02045 100755 --- a/sync-router +++ b/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 @@ -26,10 +26,16 @@ # this program. If not, visit to download it. ### 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 -filestore=flash # location of dhcp/IOS files on cisco +router=`basename \`dirname $0 | pwd\`` # name of router - based on directory +dhcpfiles=dhcp-\* # list/pattern of dhcp lease 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 + filedst=$filestore 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 ;; *)