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:
2025-12-27 21:18:02 +01:00
parent fdc3aed778
commit b82899d11a
2 changed files with 20 additions and 18 deletions

View File

@@ -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. encounter any issues or require changes.
The latest versions, documentation and bugtracker available on my 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 Copyright (c) 2016 - 2025 Frederik Lindenaar. free for distribution under the
License, see [below](#license) GNU License, see [below](#license)
sync-router sync-router

View File

@@ -10,9 +10,9 @@
# repository, update startup-config file accordingly on router # repository, update startup-config file accordingly on router
# - commit changes to the git repository # - 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 # 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 # terms of version 3 of the GNU General Public License as published by the Free
@@ -28,9 +28,15 @@
### Configuration ### ### Configuration ###
router=`basename \`dirname $0 | pwd\`` # name of router - based on directory router=`basename \`dirname $0 | pwd\`` # name of router - based on directory
dhcpfiles=dhcp-\* # list/pattern of dhcp lease files 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 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 ### ### Implementation ###
echo updating with $router echo updating with $router
@@ -54,7 +60,7 @@ router_file_download() {
filesrc=$filestore filesrc=$filestore
fi fi
echo downloading $tofile from router $filesrc echo downloading $tofile from router $filesrc
if scp -q $router:$filesrc:$fromfile $tofile; then if $SCP $router:$filesrc:$fromfile $tofile; then
git add $tofile git add $tofile
else else
fail "download of $tofile failed" fail "download of $tofile failed"
@@ -68,13 +74,9 @@ router_file_download() {
router_file_upload() { router_file_upload() {
fromfile=${1?ERROR: at least one filename is required to copy to router} fromfile=${1?ERROR: at least one filename is required to copy to router}
tofile=${2:-$fromfile} tofile=${2:-$fromfile}
if [ "$tofile" == startup-config ]; then
filedst=nvram
else
filedst=$filestore filedst=$filestore
fi
echo uploading new/updated $tofile to router $filedst 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 if [ "$fromfile" != "$tofile" ]; then
mv $fromfile $tofile mv $fromfile $tofile
git add $tofile git add $tofile
@@ -112,7 +114,7 @@ do
router_file_remove $filename router_file_remove $filename
router_file_upload $newfilename router_file_upload $newfilename
;; ;;
A |M|MM) A|M|MM)
echo updating and uploading modified file $filename echo updating and uploading modified file $filename
head -2 $filename | while read tag value head -2 $filename | while read tag value
do do
@@ -166,7 +168,7 @@ do
D) D)
router_file_remove $filename router_file_remove $filename
;; ;;
A |M) A|M)
router_file_upload $filename router_file_upload $filename
;; ;;
*) *)