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
4fcddd18
Commit
4fcddd18
authored
Mar 31, 2024
by
asauerwein
Browse files
add template option
parent
6e14a073
Changes
1
Hide whitespace changes
Inline
Side-by-side
deploy/panos.sh
View file @
4fcddd18
...
@@ -12,6 +12,9 @@
...
@@ -12,6 +12,9 @@
# export PANOS_USER="" #User *MUST* have Commit and Import Permissions in XML API for Admin Role
# export PANOS_USER="" #User *MUST* have Commit and Import Permissions in XML API for Admin Role
# export PANOS_PASS=""
# export PANOS_PASS=""
#
#
# OPTIONAL
# export PANOS_TEMPLATE="" #Template Name of panorama managed devices
#
# The script will automatically generate a new API key if
# The script will automatically generate a new API key if
# no key is found, or if a saved key has expired or is invalid.
# no key is found, or if a saved key has expired or is invalid.
...
@@ -77,7 +80,10 @@ deployer() {
...
@@ -77,7 +80,10 @@ deployer() {
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
certificate-name
\"\r\n\r\n
$_cdomain
"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
certificate-name
\"\r\n\r\n
$_cdomain
"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
key
\"\r\n\r\n
$_panos_key
"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
key
\"\r\n\r\n
$_panos_key
"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
format
\"\r\n\r\n
pem"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
format
\"\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
"
)
"
if
[
"
$_panos_template
"
]
;
then
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
target-tpl
\"\r\n\r\n
$_panos_template
"
fi
fi
fi
if
[
"
$type
"
=
'key'
]
;
then
if
[
"
$type
"
=
'key'
]
;
then
panos_url
=
"
${
panos_url
}
?type=import"
panos_url
=
"
${
panos_url
}
?type=import"
...
@@ -87,6 +93,9 @@ deployer() {
...
@@ -87,6 +93,9 @@ deployer() {
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
format
\"\r\n\r\n
pem"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
format
\"\r\n\r\n
pem"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
passphrase
\"\r\n\r\n
123456"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
passphrase
\"\r\n\r\n
123456"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
file
\"
; filename=
\"
$(
basename
"
$_cdomain
.key"
)
\"
${
nl
}
Content-Type: application/octet-stream
${
nl
}${
nl
}
$(
cat
"
$_ckey
"
)
"
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
file
\"
; filename=
\"
$(
basename
"
$_cdomain
.key"
)
\"
${
nl
}
Content-Type: application/octet-stream
${
nl
}${
nl
}
$(
cat
"
$_ckey
"
)
"
if
[
"
$_panos_template
"
]
;
then
content
=
"
$content
${
nl
}
--
$delim
${
nl
}
Content-Disposition: form-data; name=
\"
target-tpl
\"\r\n\r\n
$_panos_template
"
fi
fi
fi
#Close multipart
#Close multipart
content
=
"
$content
${
nl
}
--
$delim
--
${
nl
}${
nl
}
"
content
=
"
$content
${
nl
}
--
$delim
--
${
nl
}${
nl
}
"
...
@@ -173,10 +182,20 @@ panos_deploy() {
...
@@ -173,10 +182,20 @@ panos_deploy() {
unset
_panos_key
unset
_panos_key
fi
fi
# PANOS_TEMPLATE
if
[
"
$PANOS_TEMPLATE
"
]
;
then
_debug
"Detected ENV variable PANOS_TEMPLATE. Saving to file."
_savedeployconf PANOS_TEMPLATE
"
$PANOS_TEMPLATE
"
1
else
_debug
"Attempting to load variable PANOS_TEMPLATE from file."
_getdeployconf PANOS_TEMPLATE
fi
#Store variables
#Store variables
_panos_host
=
$PANOS_HOST
_panos_host
=
$PANOS_HOST
_panos_user
=
$PANOS_USER
_panos_user
=
$PANOS_USER
_panos_pass
=
$PANOS_PASS
_panos_pass
=
$PANOS_PASS
_panos_template
=
$PANOS_TEMPLATE
#Test API Key if found. If the key is invalid, the variable _panos_key will be unset.
#Test API Key if found. If the key is invalid, the variable _panos_key will be unset.
if
[
"
$_panos_host
"
]
&&
[
"
$_panos_key
"
]
;
then
if
[
"
$_panos_host
"
]
&&
[
"
$_panos_key
"
]
;
then
...
...
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