Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
5dcb4176
Commit
5dcb4176
authored
Feb 11, 2020
by
Paul Nguyen
Browse files
ShellCheck fixes
parent
71bc993e
Changes
1
Show whitespace changes
Inline
Side-by-side
deploy/panos.sh
View file @
5dcb4176
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
# This function is to parse the XML
# This function is to parse the XML
parse_response
()
{
parse_response
()
{
type
=
$2
type
=
$2
if
[
$type
=
"
keygen
"
]
;
then
if
[
"
$type
"
=
'
keygen
'
]
;
then
status
=
$(
echo
"
$1
"
|
sed
's/^.*\(['
\'
']\)\([a-z]*\)'
\'
'.*/\2/g'
)
status
=
$(
echo
"
$1
"
|
sed
's/^.*\(['
\'
']\)\([a-z]*\)'
\'
'.*/\2/g'
)
if
[
"
$status
"
=
"success"
]
;
then
if
[
"
$status
"
=
"success"
]
;
then
panos_key
=
$(
echo
"
$1
"
|
sed
's/^.*\(<key>\)\(.*\)<\/key>.*/\2/g'
)
panos_key
=
$(
echo
"
$1
"
|
sed
's/^.*\(<key>\)\(.*\)<\/key>.*/\2/g'
)
...
@@ -35,20 +35,20 @@ deployer() {
...
@@ -35,20 +35,20 @@ deployer() {
_debug
"**** Deploying
$type
*****"
_debug
"**** Deploying
$type
*****"
panos_url
=
"https://
$_panos_host
/api/"
panos_url
=
"https://
$_panos_host
/api/"
if
[
$type
=
"
keygen
"
]
;
then
if
[
"
$type
"
=
'
keygen
'
]
;
then
_H1
=
"Content-Type: application/x-www-form-urlencoded"
_H1
=
"Content-Type: application/x-www-form-urlencoded"
content
=
"type=keygen&user=
$_panos_user
&password=
$_panos_pass
"
content
=
"type=keygen&user=
$_panos_user
&password=
$_panos_pass
"
# content="$content${nl}--$delim${nl}Content-Disposition: form-data; type=\"keygen\"; user=\"$_panos_user\"; password=\"$_panos_pass\"${nl}Content-Type: application/octet-stream${nl}${nl}"
# content="$content${nl}--$delim${nl}Content-Disposition: form-data; type=\"keygen\"; user=\"$_panos_user\"; password=\"$_panos_pass\"${nl}Content-Type: application/octet-stream${nl}${nl}"
fi
fi
if
[
$type
=
"
cert
"
]
||
[
$type
=
"
key
"
]
;
then
if
[
"
$type
"
=
'
cert
'
]
||
[
"
$type
"
=
'
key
'
]
;
then
#Generate DEIM
#Generate DEIM
delim
=
"-----MultipartDelimiter
$(
date
"+%s%N"
)
"
delim
=
"-----MultipartDelimiter
$(
date
"+%s%N"
)
"
nl
=
"
\0
15
\0
12"
nl
=
"
\0
15
\0
12"
#Set Header
#Set Header
export
_H1
=
"Content-Type: multipart/form-data; boundary=
$delim
"
export
_H1
=
"Content-Type: multipart/form-data; boundary=
$delim
"
if
[
$type
=
"
cert
"
]
;
then
if
[
"
$type
"
=
'
cert
'
]
;
then
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
type
\"\r\n\r\n\r\n
import"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
type
\"\r\n\r\n\r\n
import"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
category
\"\r\n\r\n\r\n
certificate"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
category
\"\r\n\r\n\r\n
certificate"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
certificate-name
\"\r\n\r\n\r\n
$_cdomain
"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
certificate-name
\"\r\n\r\n\r\n
$_cdomain
"
...
@@ -56,7 +56,7 @@ deployer() {
...
@@ -56,7 +56,7 @@ deployer() {
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
format
\"\r\n\r\n\r\n
pem"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
format
\"\r\n\r\n\r\n
pem"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
file
\"
; filename=
\"
$(
basename
"
$_cfullchain
"
)
\"
${
nl
}
Content-Type: application/octet-stream
${
nl
}${
nl
}
$(
cat
"
$_cfullchain
"
)
"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
file
\"
; filename=
\"
$(
basename
"
$_cfullchain
"
)
\"
${
nl
}
Content-Type: application/octet-stream
${
nl
}${
nl
}
$(
cat
"
$_cfullchain
"
)
"
fi
fi
if
[
$type
=
"
key
"
]
;
then
if
[
"
$type
"
=
'
key
'
]
;
then
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
type
\"\r\n\r\n\r\n
import"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
type
\"\r\n\r\n\r\n
import"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
category
\"\r\n\r\n\r\n
private-key"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
category
\"\r\n\r\n\r\n
private-key"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
certificate-name
\"\r\n\r\n\r\n
$_cdomain
"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
certificate-name
\"\r\n\r\n\r\n
$_cdomain
"
...
@@ -71,7 +71,7 @@ deployer() {
...
@@ -71,7 +71,7 @@ deployer() {
content
=
$(
printf
%b
"
$content
"
)
content
=
$(
printf
%b
"
$content
"
)
fi
fi
if
[
$type
=
"
commit
"
]
;
then
if
[
"
$type
"
=
'
commit
'
]
;
then
export
_H1
=
"Content-Type: application/x-www-form-urlencoded"
export
_H1
=
"Content-Type: application/x-www-form-urlencoded"
cmd
=
$(
printf
"%s"
"<commit><partial><
$_panos_user
></
$_panos_user
></partial></commit>"
| _url_encode
)
cmd
=
$(
printf
"%s"
"<commit><partial><
$_panos_user
></
$_panos_user
></partial></commit>"
| _url_encode
)
content
=
"type=commit&key=
$_panos_key
&cmd=
$cmd
"
content
=
"type=commit&key=
$_panos_key
&cmd=
$cmd
"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment