Browse Source

Merge pull request #4 from ms264556/dev

fix acme.sh PR shfmt failure
pull/4832/head
kchiem 1 month ago
committed by GitHub
parent
commit
412e14a41c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 27
      deploy/ruckus.sh

27
deploy/ruckus.sh

@ -1,7 +1,7 @@
#!/usr/bin/env sh #!/usr/bin/env sh
# Here is a script to deploy cert to Ruckus ZoneDirector / Unleashed. # Here is a script to deploy cert to Ruckus ZoneDirector / Unleashed.
#
#
# Public domain, 2024, Tony Rielly <https://github.com/ms264556> # Public domain, 2024, Tony Rielly <https://github.com/ms264556>
# #
# ```sh # ```sh
@ -65,7 +65,6 @@ ruckus_deploy() {
_debug RUCKUS_USER "$RUCKUS_USER" _debug RUCKUS_USER "$RUCKUS_USER"
_secure_debug RUCKUS_PASS "$RUCKUS_PASS" _secure_debug RUCKUS_PASS "$RUCKUS_PASS"
export HTTPS_INSECURE=1
export ACME_HTTP_NO_REDIRECTS=1 export ACME_HTTP_NO_REDIRECTS=1
_info "Discovering the login URL" _info "Discovering the login URL"
@ -84,20 +83,20 @@ ruckus_deploy() {
_err "Connection failed: couldn't find login page." _err "Connection failed: couldn't find login page."
return 1 return 1
fi fi
_base_url=$(dirname "$_login_url") _base_url=$(dirname "$_login_url")
_login_page=$(basename "$_login_url") _login_page=$(basename "$_login_url")
if [ "$_login_page" = "index.html" ]; then
if [ "$_login_page" = "index.html" ]; then
_err "Connection temporarily unavailable: Unleashed Rebuilding." _err "Connection temporarily unavailable: Unleashed Rebuilding."
return 1 return 1
fi fi
if [ "$_login_page" = "wizard.jsp" ]; then
if [ "$_login_page" = "wizard.jsp" ]; then
_err "Connection failed: Setup Wizard not complete." _err "Connection failed: Setup Wizard not complete."
return 1 return 1
fi fi
_info "Login" _info "Login"
_username_encoded="$(printf "%s" "$RUCKUS_USER" | _url_encode)" _username_encoded="$(printf "%s" "$RUCKUS_USER" | _url_encode)"
_password_encoded="$(printf "%s" "$RUCKUS_PASS" | _url_encode)" _password_encoded="$(printf "%s" "$RUCKUS_PASS" | _url_encode)"
@ -109,7 +108,7 @@ ruckus_deploy() {
_err "Login failed: incorrect credentials." _err "Login failed: incorrect credentials."
return 1 return 1
fi fi
_info "Collect Session Cookie" _info "Collect Session Cookie"
_H1="Cookie: $(_response_cookie)" _H1="Cookie: $(_response_cookie)"
export _H1 export _H1
@ -119,27 +118,27 @@ ruckus_deploy() {
_info "Uploading certificate" _info "Uploading certificate"
_post_upload "uploadcert" "$_cfullchain" _post_upload "uploadcert" "$_cfullchain"
_info "Uploading private key" _info "Uploading private key"
_post_upload "uploadprivatekey" "$_ckey" _post_upload "uploadprivatekey" "$_ckey"
_info "Replacing certificate" _info "Replacing certificate"
_replace_cert_ajax='<ajax-request action="docmd" comp="system" updater="rid.0.5" xcmd="replace-cert" checkAbility="6" timeout="-1"><xcmd cmd="replace-cert" cn="'$RUCKUS_HOST'"/></ajax-request>' _replace_cert_ajax='<ajax-request action="docmd" comp="system" updater="rid.0.5" xcmd="replace-cert" checkAbility="6" timeout="-1"><xcmd cmd="replace-cert" cn="'$RUCKUS_HOST'"/></ajax-request>'
_post "$_replace_cert_ajax" "$_base_url/_cmdstat.jsp" >/dev/null _post "$_replace_cert_ajax" "$_base_url/_cmdstat.jsp" >/dev/null
_info "Rebooting" _info "Rebooting"
_cert_reboot_ajax='<ajax-request action="docmd" comp="worker" updater="rid.0.5" xcmd="cert-reboot" checkAbility="6"><xcmd cmd="cert-reboot" action="undefined"/></ajax-request>' _cert_reboot_ajax='<ajax-request action="docmd" comp="worker" updater="rid.0.5" xcmd="cert-reboot" checkAbility="6"><xcmd cmd="cert-reboot" action="undefined"/></ajax-request>'
_post "$_cert_reboot_ajax" "$_base_url/_cmdstat.jsp" >/dev/null _post "$_cert_reboot_ajax" "$_base_url/_cmdstat.jsp" >/dev/null
return 0 return 0
} }
_response_code() { _response_code() {
< "$HTTP_HEADER" _egrep_o "^HTTP[^ ]* .*$" | cut -d " " -f 2-100 | tr -d "\f\n" | _egrep_o "^[0-9]*"
_egrep_o <"$HTTP_HEADER" "^HTTP[^ ]* .*$" | cut -d " " -f 2-100 | tr -d "\f\n" | _egrep_o "^[0-9]*"
} }
_response_header() { _response_header() {
< "$HTTP_HEADER" grep -i "^$1:" | cut -d ':' -f 2- | tr -d "\r\n\t "
grep <"$HTTP_HEADER" -i "^$1:" | cut -d ':' -f 2- | tr -d "\r\n\t "
} }
_response_cookie() { _response_cookie() {
@ -149,9 +148,9 @@ _response_cookie() {
_post_upload() { _post_upload() {
_post_action="$1" _post_action="$1"
_post_file="$2" _post_file="$2"
_post_boundary="----FormBoundary$(date "+%s%N")" _post_boundary="----FormBoundary$(date "+%s%N")"
_post_data="$({ _post_data="$({
printf -- "--%s\r\n" "$_post_boundary" printf -- "--%s\r\n" "$_post_boundary"
printf -- "Content-Disposition: form-data; name=\"u\"; filename=\"%s\"\r\n" "$_post_action" printf -- "Content-Disposition: form-data; name=\"u\"; filename=\"%s\"\r\n" "$_post_action"

Loading…
Cancel
Save