diff options
-rwxr-xr-x | etc/bash_completion.d/vyatta-cfg | 4 | ||||
-rwxr-xr-x | scripts/vyatta-load-config.pl | 7 | ||||
-rwxr-xr-x | scripts/vyatta-save-config.pl | 5 |
3 files changed, 11 insertions, 5 deletions
diff --git a/etc/bash_completion.d/vyatta-cfg b/etc/bash_completion.d/vyatta-cfg index 0e4b7f8..e6c1842 100755 --- a/etc/bash_completion.d/vyatta-cfg +++ b/etc/bash_completion.d/vyatta-cfg @@ -195,6 +195,7 @@ vyatta_loadsave_complete() echo -e " <Enter>\t\t\t\tLoad from system config file" echo -e " <file>\t\t\t\tLoad from file on local machine" echo -e " scp://<user>:<passwd>@<host>/<file>\tLoad from file on remote machine" + echo -e " sftp://<user>:<passwd>@<host>/<file>\tLoad from file on remote machine" echo -e " ftp://<user>:<passwd>@<host>/<file>\tLoad from file on remote machine" echo -e " http://<host>/<file>\t\t\tLoad from file on remote machine" echo -e " tftp://<host>/<file>\t\t\tLoad from file on remote machine" @@ -202,6 +203,7 @@ vyatta_loadsave_complete() echo -e " <Enter>\t\t\t\tMerge from system config file" echo -e " <file>\t\t\t\tMerge from file on local machine" echo -e " scp://<user>:<passwd>@<host>/<file>\tMerge from file on remote machine" + echo -e " sftp://<user>:<passwd>@<host>/<file>\tMerge from file on remote machine" echo -e " ftp://<user>:<passwd>@<host>/<file>\tMerge from file on remote machine" echo -e " http://<host>/<file>\t\t\tMerge from file on remote machine" echo -e " tftp://<host>/<file>\t\t\tMerge from file on remote machine" @@ -209,6 +211,7 @@ vyatta_loadsave_complete() echo -e " <Enter>\t\t\t\tSave to system config file" echo -e " <file>\t\t\t\tSave to file on local machine" echo -e " scp://<user>:<passwd>@<host>/<file>\tSave to file on remote machine" + echo -e " sftp://<user>:<passwd>@<host>/<file>\tSave to file on remote machine" echo -e " ftp://<user>:<passwd>@<host>/<file>\tSave to file on remote machine" echo -e " tftp://<host>/<file>\t\t\tSave to file on remote machine" fi @@ -258,6 +261,7 @@ vyatta_loadkey_complete() echo "Possible completions:" echo -e " <file>\t\t\t\tLoad from file on local machine" echo -e " scp://<user>@<host>/<file>\tLoad from file on remote machine" + echo -e " sftp://<user>@<host>/<file>\tLoad from file on remote machine" echo -e " ftp://<user>@<host>/<file>\tLoad from file on remote machine" echo -e " http://<host>/<file>\t\t\tLoad from file on remote machine" echo -e " tftp://<host>/<file>\t\t\tLoad from file on remote machine" diff --git a/scripts/vyatta-load-config.pl b/scripts/vyatta-load-config.pl index dc9ad6e..f6dfba3 100755 --- a/scripts/vyatta-load-config.pl +++ b/scripts/vyatta-load-config.pl @@ -78,7 +78,8 @@ if ( $load_file =~ /^[^\/]\w+:\// ) { unless( $proto eq 'tftp' || $proto eq 'ftp' || $proto eq 'http' || - $proto eq 'scp' ) { + $proto eq 'scp' || + $proto eq 'sftp' ) { die "Invalid url protocol [$proto]\n"; } } else { @@ -127,8 +128,8 @@ elsif ( $mode eq 'url' ) { } } my $rc = system("curl -# -o $url_tmp_file $load_file"); - if ($proto eq 'scp' && ($rc >> 8) == 51){ - $load_file =~ m/scp:\/\/(.*?)\//; + if ($proto =~ /^(scp|sftp)$/ && ($rc >> 8) == 51){ + $load_file =~ m/(scp|sftp):\/\/(.*?)\//; my $host = $1; if ($host =~ m/.*@(.*)/) { $host = $1; diff --git a/scripts/vyatta-save-config.pl b/scripts/vyatta-save-config.pl index 96dd4b1..439e873 100755 --- a/scripts/vyatta-save-config.pl +++ b/scripts/vyatta-save-config.pl @@ -60,6 +60,7 @@ if ($save_file =~ /^[^\/]\w+:\//) { if ($proto eq 'tftp') { } elsif ($proto eq 'ftp') { } elsif ($proto eq 'scp') { + } elsif ($proto eq 'sftp') { } else { print "Invalid url protocol [$proto]\n"; exit 1; @@ -123,8 +124,8 @@ close $save; if ($mode eq 'url') { my $rc = 0; - if ($proto eq 'scp'){ - $save_file =~ m/scp:\/\/(.*?)\//; + if ($proto =~ /^(scp|sftp)$/){ + $save_file =~ m/(scp|sftp):\/\/(.*?)\//; my $host = $1; my $user = getpwuid($<); if ($host =~ m/(.*)@(.*)/) { |