summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim <kim.sidney@gmail.com>2017-11-08 09:11:17 +0100
committerGitHub <noreply@github.com>2017-11-08 09:11:17 +0100
commit2a925cdc203cab2d8b8a3bd08ab6380f399b8bc9 (patch)
treeb2cd48833948eee87d964e4bdabfe728d448378a
parentcfc3fb4bb9cd7011dc420660d381597b9f5928c2 (diff)
parent5142338108ef9971777c904a00777adfe47d734b (diff)
downloadvyatta-cfg-2a925cdc203cab2d8b8a3bd08ab6380f399b8bc9.tar.gz
vyatta-cfg-2a925cdc203cab2d8b8a3bd08ab6380f399b8bc9.zip
Merge pull request #9 from c-po/add-load-https-support
T281: Add https support to the load command
-rwxr-xr-xetc/bash_completion.d/vyatta-cfg1
-rwxr-xr-xscripts/vyatta-load-config.pl23
2 files changed, 12 insertions, 12 deletions
diff --git a/etc/bash_completion.d/vyatta-cfg b/etc/bash_completion.d/vyatta-cfg
index 22f9dd3..7e37e74 100755
--- a/etc/bash_completion.d/vyatta-cfg
+++ b/etc/bash_completion.d/vyatta-cfg
@@ -198,6 +198,7 @@ vyatta_loadsave_complete()
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 " https://<host>/<file>\t\t\tLoad from file on remote machine"
echo -e " tftp://<host>/<file>\t\t\tLoad from file on remote machine"
elif [ "$command" = "merge" ]; then
echo -e " <Enter>\t\t\t\tMerge from system config file"
diff --git a/scripts/vyatta-load-config.pl b/scripts/vyatta-load-config.pl
index 517b7ff..c52851c 100755
--- a/scripts/vyatta-load-config.pl
+++ b/scripts/vyatta-load-config.pl
@@ -75,11 +75,12 @@ if ( $load_file =~ /^[^\/]\w+:\// ) {
if ( $load_file =~ /^(\w+):\/\/\w/ ) {
$mode = 'url';
$proto = lc($1);
- unless( $proto eq 'tftp' ||
- $proto eq 'ftp' ||
- $proto eq 'http' ||
- $proto eq 'scp' ||
- $proto eq 'sftp' ) {
+ unless( $proto eq 'tftp' ||
+ $proto eq 'ftp' ||
+ $proto eq 'http' ||
+ $proto eq 'https' ||
+ $proto eq 'scp' ||
+ $proto eq 'sftp' ) {
die "Invalid url protocol [$proto]\n";
}
} else {
@@ -103,19 +104,17 @@ elsif ( $mode eq 'url' ) {
print "Package [curl] not installed\n";
exit 1;
}
- if ( $proto eq 'http' ) {
-
+ if ( $proto eq 'http' or $proto eq 'https' ) {
#
# error codes are send back in html, so 1st try a header
- # and look for "HTTP/1.1 200 OK"
+ # and look for "HTTP/1.1 200 OK" or "HTTP/1.1 301 Moved Permanently"
#
- my $rc = `curl -q -I $load_file 2>&1`;
+ my $rc = `curl -L -q -I $load_file 2>&1`;
if ( $rc =~ /HTTP\/\d+\.?\d\s+(\d+)\s+(.*)$/mi ) {
my $rc_code = $1;
my $rc_string = $2;
- if ( $rc_code == 200 ) {
-
- # good resonse
+ if ( $rc_code == 200 or $rc_code == 301 ) {
+ # good response
}
else {
print "http error: [$rc_code] $rc_string\n";