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.
|
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
|
||||||
|
|||||||
20
sync-router
20
sync-router
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user