mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2026-10-23 06:01:53 +00:00
Compare commits
No files matched your search
+14
-7
@@ -1,14 +1,10 @@
|
|||||||
language: shell
|
language: shell
|
||||||
sudo: required
|
sudo: required
|
||||||
dist: trusty
|
|
||||||
|
|
||||||
os:
|
os:
|
||||||
- linux
|
- linux
|
||||||
- osx
|
- osx
|
||||||
|
|
||||||
services:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- SHFMT_URL=https://github.com/mvdan/sh/releases/download/v0.4.0/shfmt_v0.4.0_linux_amd64
|
- SHFMT_URL=https://github.com/mvdan/sh/releases/download/v0.4.0/shfmt_v0.4.0_linux_amd64
|
||||||
@@ -22,8 +18,19 @@ addons:
|
|||||||
|
|
||||||
install:
|
install:
|
||||||
- if [ "$TRAVIS_OS_NAME" = 'osx' ]; then
|
- if [ "$TRAVIS_OS_NAME" = 'osx' ]; then
|
||||||
brew update && brew install socat;
|
brew update && brew install openssl socat;
|
||||||
export PATH="/usr/local/opt/openssl@1.1/bin:$PATH" ;
|
brew info openssl;
|
||||||
|
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/;
|
||||||
|
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/;
|
||||||
|
ln -s /usr/local/Cellar/openssl/1.0.2j/bin/openssl /usr/local/openssl;
|
||||||
|
_old_path="$PATH";
|
||||||
|
echo "PATH=$PATH";
|
||||||
|
export PATH="";
|
||||||
|
export ACME_OPENSSL_BIN="/usr/local/openssl";
|
||||||
|
openssl version 2>&1 || true;
|
||||||
|
$ACME_OPENSSL_BIN version 2>&1 || true;
|
||||||
|
export PATH="$_old_path";
|
||||||
|
else sudo apt-get install socat;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
script:
|
script:
|
||||||
@@ -37,7 +44,7 @@ script:
|
|||||||
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then shellcheck -e SC2181 **/*.sh && echo "shellcheck OK" ; fi
|
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then shellcheck -e SC2181 **/*.sh && echo "shellcheck OK" ; fi
|
||||||
- cd ..
|
- cd ..
|
||||||
- git clone https://github.com/Neilpang/acmetest.git && cp -r acme.sh acmetest/ && cd acmetest
|
- git clone https://github.com/Neilpang/acmetest.git && cp -r acme.sh acmetest/ && cd acmetest
|
||||||
- if [ "$TRAVIS_OS_NAME" = "linux" -a "$NGROK_TOKEN" ]; then sudo TEST_LOCAL="$TEST_LOCAL" NGROK_TOKEN="$NGROK_TOKEN" ./rundocker.sh testplat ubuntu:latest ; fi
|
- if [ "$TRAVIS_OS_NAME" = "linux" -a "$NGROK_TOKEN" ]; then sudo TEST_LOCAL="$TEST_LOCAL" NGROK_TOKEN="$NGROK_TOKEN" ./letest.sh ; fi
|
||||||
- if [ "$TRAVIS_OS_NAME" = "osx" -a "$NGROK_TOKEN" ]; then sudo TEST_LOCAL="$TEST_LOCAL" NGROK_TOKEN="$NGROK_TOKEN" ACME_OPENSSL_BIN="$ACME_OPENSSL_BIN" ./letest.sh ; fi
|
- if [ "$TRAVIS_OS_NAME" = "osx" -a "$NGROK_TOKEN" ]; then sudo TEST_LOCAL="$TEST_LOCAL" NGROK_TOKEN="$NGROK_TOKEN" ACME_OPENSSL_BIN="$ACME_OPENSSL_BIN" ./letest.sh ; fi
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,10 +1,10 @@
|
|||||||
FROM alpine:3.6
|
FROM alpine
|
||||||
|
|
||||||
RUN apk update -f \
|
RUN apk update -f \
|
||||||
&& apk --no-cache add -f \
|
&& apk --no-cache add -f \
|
||||||
openssl \
|
openssl \
|
||||||
curl \
|
curl \
|
||||||
socat \
|
netcat-openbsd \
|
||||||
&& rm -rf /var/cache/apk/*
|
&& rm -rf /var/cache/apk/*
|
||||||
|
|
||||||
ENV LE_CONFIG_HOME /acme.sh
|
ENV LE_CONFIG_HOME /acme.sh
|
||||||
@@ -16,7 +16,7 @@ ADD ./ /install_acme.sh/
|
|||||||
RUN cd /install_acme.sh && ([ -f /install_acme.sh/acme.sh ] && /install_acme.sh/acme.sh --install || curl https://get.acme.sh | sh) && rm -rf /install_acme.sh/
|
RUN cd /install_acme.sh && ([ -f /install_acme.sh/acme.sh ] && /install_acme.sh/acme.sh --install || curl https://get.acme.sh | sh) && rm -rf /install_acme.sh/
|
||||||
|
|
||||||
|
|
||||||
RUN ln -s /root/.acme.sh/acme.sh /usr/local/bin/acme.sh && crontab -l | grep acme.sh | sed 's#> /dev/null##' | crontab -
|
RUN ln -s /root/.acme.sh/acme.sh /usr/local/bin/acme.sh && crontab -l | sed 's#> /dev/null##' | crontab -
|
||||||
|
|
||||||
RUN for verb in help \
|
RUN for verb in help \
|
||||||
version \
|
version \
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
VER=2.7.5
|
VER=2.7.4
|
||||||
|
|
||||||
PROJECT_NAME="acme.sh"
|
PROJECT_NAME="acme.sh"
|
||||||
|
|
||||||
@@ -463,7 +463,8 @@ if _exists xargs && [ "$(printf %s '\\x41' | xargs printf)" = 'A' ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
_h2b() {
|
_h2b() {
|
||||||
if _exists xxd && xxd -r -p 2>/dev/null; then
|
if _exists xxd; then
|
||||||
|
xxd -r -p
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -1813,13 +1814,7 @@ _send_signed_request() {
|
|||||||
|
|
||||||
_CACHED_NONCE="$(echo "$responseHeaders" | grep "Replay-Nonce:" | _head_n 1 | tr -d "\r\n " | cut -d ':' -f 2)"
|
_CACHED_NONCE="$(echo "$responseHeaders" | grep "Replay-Nonce:" | _head_n 1 | tr -d "\r\n " | cut -d ':' -f 2)"
|
||||||
|
|
||||||
_body="$response"
|
if _contains "$response" "JWS has invalid anti-replay nonce"; then
|
||||||
if [ "$needbase64" ]; then
|
|
||||||
_body="$(echo "$_body" | _dbase64)"
|
|
||||||
_debug2 _body "$_body"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if _contains "$_body" "JWS has invalid anti-replay nonce"; then
|
|
||||||
_info "It seems the CA server is busy now, let's wait and retry."
|
_info "It seems the CA server is busy now, let's wait and retry."
|
||||||
_request_retry_times=$(_math "$_request_retry_times" + 1)
|
_request_retry_times=$(_math "$_request_retry_times" + 1)
|
||||||
_sleep 5
|
_sleep 5
|
||||||
@@ -1986,7 +1981,7 @@ _startserver() {
|
|||||||
|
|
||||||
_debug "_NC" "$_NC"
|
_debug "_NC" "$_NC"
|
||||||
#todo listen address
|
#todo listen address
|
||||||
$_NC TCP-LISTEN:$Le_HTTPPort,crlf,reuseaddr,fork SYSTEM:"sleep 0.5; echo HTTP/1.1 200 OK; echo ; echo $content; echo;" &
|
socat TCP-LISTEN:$Le_HTTPPort,crlf,reuseaddr,fork SYSTEM:"echo HTTP/1.1 200 OK'; echo ; echo $content; echo;" &
|
||||||
serverproc="$!"
|
serverproc="$!"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2053,12 +2048,7 @@ _starttlsserver() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
__S_OPENSSL="${ACME_OPENSSL_BIN:-openssl} s_server -www -cert $TLS_CERT -key $TLS_KEY "
|
__S_OPENSSL="socat"
|
||||||
if [ "$opaddr" ]; then
|
|
||||||
__S_OPENSSL="$__S_OPENSSL -accept $opaddr:$port"
|
|
||||||
else
|
|
||||||
__S_OPENSSL="$__S_OPENSSL -accept $port"
|
|
||||||
fi
|
|
||||||
|
|
||||||
_debug Le_Listen_V4 "$Le_Listen_V4"
|
_debug Le_Listen_V4 "$Le_Listen_V4"
|
||||||
_debug Le_Listen_V6 "$Le_Listen_V6"
|
_debug Le_Listen_V6 "$Le_Listen_V6"
|
||||||
@@ -2069,12 +2059,9 @@ _starttlsserver() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
_debug "$__S_OPENSSL"
|
_debug "$__S_OPENSSL"
|
||||||
if [ "$DEBUG" ] && [ "$DEBUG" -ge "2" ]; then
|
|
||||||
$__S_OPENSSL -tlsextdebug &
|
|
||||||
else
|
|
||||||
$__S_OPENSSL >/dev/null 2>&1 &
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
#todo listen address
|
||||||
|
$__S_OPENSSL openssl-listen:$port,cert=$TLS_CERT,key=$TLS_KEY,verify=0,reuseaddr,fork SYSTEM:"echo HTTP/1.1 200 OK'; echo ; echo $content; echo;" &
|
||||||
serverproc="$!"
|
serverproc="$!"
|
||||||
sleep 1
|
sleep 1
|
||||||
_debug serverproc "$serverproc"
|
_debug serverproc "$serverproc"
|
||||||
@@ -2248,7 +2235,6 @@ _initpath() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_debug2 ACME_DIRECTORY "$ACME_DIRECTORY"
|
|
||||||
_ACME_SERVER_HOST="$(echo "$ACME_DIRECTORY" | cut -d : -f 2 | tr -s / | cut -d / -f 2)"
|
_ACME_SERVER_HOST="$(echo "$ACME_DIRECTORY" | cut -d : -f 2 | tr -s / | cut -d / -f 2)"
|
||||||
_debug2 "_ACME_SERVER_HOST" "$_ACME_SERVER_HOST"
|
_debug2 "_ACME_SERVER_HOST" "$_ACME_SERVER_HOST"
|
||||||
|
|
||||||
@@ -3134,7 +3120,7 @@ _regAccount() {
|
|||||||
fi
|
fi
|
||||||
if [ "$code" = '202' ]; then
|
if [ "$code" = '202' ]; then
|
||||||
_info "Update account tos info success."
|
_info "Update account tos info success."
|
||||||
echo "$response" >"$ACCOUNT_JSON_PATH"
|
|
||||||
CA_KEY_HASH="$(__calcAccountKeyHash)"
|
CA_KEY_HASH="$(__calcAccountKeyHash)"
|
||||||
_debug "Calc CA_KEY_HASH" "$CA_KEY_HASH"
|
_debug "Calc CA_KEY_HASH" "$CA_KEY_HASH"
|
||||||
_savecaconf CA_KEY_HASH "$CA_KEY_HASH"
|
_savecaconf CA_KEY_HASH "$CA_KEY_HASH"
|
||||||
@@ -3473,7 +3459,7 @@ issue() {
|
|||||||
token="$(printf "%s\n" "$entry" | _egrep_o '"token":"[^"]*' | cut -d : -f 2 | tr -d '"')"
|
token="$(printf "%s\n" "$entry" | _egrep_o '"token":"[^"]*' | cut -d : -f 2 | tr -d '"')"
|
||||||
_debug token "$token"
|
_debug token "$token"
|
||||||
|
|
||||||
uri="$(printf "%s\n" "$entry" | _egrep_o '"uri":"[^"]*' | cut -d '"' -f 4)"
|
uri="$(printf "%s\n" "$entry" | _egrep_o '"uri":"[^"]*' | cut -d : -f 2,3 | tr -d '"')"
|
||||||
_debug uri "$uri"
|
_debug uri "$uri"
|
||||||
|
|
||||||
keyauthorization="$token.$thumbprint"
|
keyauthorization="$token.$thumbprint"
|
||||||
@@ -3948,10 +3934,7 @@ issue() {
|
|||||||
Le_NextRenewTime=$(_math "$Le_NextRenewTime" - 86400)
|
Le_NextRenewTime=$(_math "$Le_NextRenewTime" - 86400)
|
||||||
_savedomainconf "Le_NextRenewTime" "$Le_NextRenewTime"
|
_savedomainconf "Le_NextRenewTime" "$Le_NextRenewTime"
|
||||||
|
|
||||||
if ! _on_issue_success "$_post_hook" "$_renew_hook"; then
|
_on_issue_success "$_post_hook" "$_renew_hook"
|
||||||
_err "Call hook error."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$_real_cert$_real_key$_real_ca$_reload_cmd$_real_fullchain" ]; then
|
if [ "$_real_cert$_real_key$_real_ca$_reload_cmd$_real_fullchain" ]; then
|
||||||
_savedomainconf "Le_RealCertPath" "$_real_cert"
|
_savedomainconf "Le_RealCertPath" "$_real_cert"
|
||||||
@@ -4835,11 +4818,9 @@ install() {
|
|||||||
_debug "Skip install cron job"
|
_debug "Skip install cron job"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$IN_CRON" != "1" ]; then
|
if ! _precheck "$_nocron"; then
|
||||||
if ! _precheck "$_nocron"; then
|
_err "Pre-check failed, can not install."
|
||||||
_err "Pre-check failed, can not install."
|
return 1
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$_c_home" ] && [ "$LE_CONFIG_HOME" != "$LE_WORKING_DIR" ]; then
|
if [ -z "$_c_home" ] && [ "$LE_CONFIG_HOME" != "$LE_WORKING_DIR" ]; then
|
||||||
@@ -4892,9 +4873,7 @@ install() {
|
|||||||
|
|
||||||
_info "Installed to $LE_WORKING_DIR/$PROJECT_ENTRY"
|
_info "Installed to $LE_WORKING_DIR/$PROJECT_ENTRY"
|
||||||
|
|
||||||
if [ "$IN_CRON" != "1" ]; then
|
_installalias "$_c_home"
|
||||||
_installalias "$_c_home"
|
|
||||||
fi
|
|
||||||
|
|
||||||
for subf in $_SUB_FOLDERS; do
|
for subf in $_SUB_FOLDERS; do
|
||||||
if [ -d "$subf" ]; then
|
if [ -d "$subf" ]; then
|
||||||
@@ -4984,7 +4963,7 @@ _uninstallalias() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cron() {
|
cron() {
|
||||||
export IN_CRON=1
|
IN_CRON=1
|
||||||
_initpath
|
_initpath
|
||||||
_info "$(__green "===Starting cron===")"
|
_info "$(__green "===Starting cron===")"
|
||||||
if [ "$AUTO_UPGRADE" = "1" ]; then
|
if [ "$AUTO_UPGRADE" = "1" ]; then
|
||||||
|
|||||||
+9
-27
@@ -4,9 +4,7 @@ Before you can deploy your cert, you must [issue the cert first](https://github.
|
|||||||
|
|
||||||
Here are the scripts to deploy the certs/key to the server/services.
|
Here are the scripts to deploy the certs/key to the server/services.
|
||||||
|
|
||||||
## 1. Deploy the certs to your cpanel host
|
## 1. Deploy the certs to your cpanel host.
|
||||||
|
|
||||||
If you want to deploy using cpanel UAPI see 7.
|
|
||||||
|
|
||||||
(cpanel deploy hook is not finished yet, this is just an example.)
|
(cpanel deploy hook is not finished yet, this is just an example.)
|
||||||
|
|
||||||
@@ -20,7 +18,7 @@ export DEPLOY_CPANEL_PASSWORD=PASSWORD
|
|||||||
acme.sh --deploy -d example.com --deploy-hook cpanel
|
acme.sh --deploy -d example.com --deploy-hook cpanel
|
||||||
```
|
```
|
||||||
|
|
||||||
## 2. Deploy ssl cert on kong proxy engine based on api
|
## 2. Deploy ssl cert on kong proxy engine based on api.
|
||||||
|
|
||||||
Before you can deploy your cert, you must [issue the cert first](https://github.com/Neilpang/acme.sh/wiki/How-to-issue-a-cert).
|
Before you can deploy your cert, you must [issue the cert first](https://github.com/Neilpang/acme.sh/wiki/How-to-issue-a-cert).
|
||||||
Currently supports Kong-v0.10.x.
|
Currently supports Kong-v0.10.x.
|
||||||
@@ -29,11 +27,11 @@ Currently supports Kong-v0.10.x.
|
|||||||
acme.sh --deploy -d ftp.example.com --deploy-hook kong
|
acme.sh --deploy -d ftp.example.com --deploy-hook kong
|
||||||
```
|
```
|
||||||
|
|
||||||
## 3. Deploy the cert to remote server through SSH access
|
## 3. Deploy the cert to remote server through SSH access.
|
||||||
|
|
||||||
(TODO)
|
(TODO)
|
||||||
|
|
||||||
## 4. Deploy the cert to local vsftpd server
|
## 4. Deploy the cert to local vsftpd server.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
acme.sh --deploy -d ftp.example.com --deploy-hook vsftpd
|
acme.sh --deploy -d ftp.example.com --deploy-hook vsftpd
|
||||||
@@ -55,7 +53,7 @@ export DEPLOY_VSFTPD_RELOAD="/etc/init.d/vsftpd restart"
|
|||||||
acme.sh --deploy -d ftp.example.com --deploy-hook vsftpd
|
acme.sh --deploy -d ftp.example.com --deploy-hook vsftpd
|
||||||
```
|
```
|
||||||
|
|
||||||
## 5. Deploy the cert to local exim4 server
|
## 5. Deploy the cert to local exim4 server.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
acme.sh --deploy -d ftp.example.com --deploy-hook exim4
|
acme.sh --deploy -d ftp.example.com --deploy-hook exim4
|
||||||
@@ -83,36 +81,20 @@ acme.sh --deploy -d ftp.example.com --deploy-hook exim4
|
|||||||
acme.sh --deploy -d ftp.example.com --deploy-hook keychain
|
acme.sh --deploy -d ftp.example.com --deploy-hook keychain
|
||||||
```
|
```
|
||||||
|
|
||||||
## 7. Deploy to cpanel host using UAPI
|
## 7. Deploy to cpanel host.
|
||||||
|
|
||||||
This hook is using UAPI and works in cPanel & WHM version 56 or newer.
|
|
||||||
```
|
```
|
||||||
acme.sh --deploy -d example.com --deploy-hook cpanel_uapi
|
acme.sh --deploy -d example.com --deploy-hook cpanel_uapi
|
||||||
```
|
```
|
||||||
DEPLOY_CPANEL_USER is required only if you run the script as root and it should contain cpanel username.
|
|
||||||
|
If you are login as root, please specify the username to deploy cert to:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
export DEPLOY_CPANEL_USER=username
|
export DEPLOY_CPANEL_USER=username
|
||||||
acme.sh --deploy -d example.com --deploy-hook cpanel_uapi
|
acme.sh --deploy -d example.com --deploy-hook cpanel_uapi
|
||||||
```
|
```
|
||||||
Please note, that the cpanel_uapi hook will deploy only the first domain when your certificate will automatically renew. Therefore you should issue a separete certificate for each domain.
|
|
||||||
|
|
||||||
## 8. Deploy the cert to your FRITZ!Box router
|
|
||||||
|
|
||||||
You must specify the credentials that have administrative privileges on the FRITZ!Box in order to deploy the certificate, plus the URL of your FRITZ!Box, through the following environment variables:
|
|
||||||
```sh
|
|
||||||
$ export DEPLOY_FRITZBOX_USERNAME=my_username
|
|
||||||
$ export DEPLOY_FRITZBOX_PASSWORD=the_password
|
|
||||||
$ export DEPLOY_FRITZBOX_URL=https://fritzbox.example.com
|
|
||||||
```
|
|
||||||
|
|
||||||
After the first deployment, these values will be stored in your $HOME/.acme.sh/account.conf. You may now deploy the certificate like this:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
acme.sh --deploy -d fritzbox.example.com --deploy-hook fritzbox
|
|
||||||
```
|
|
||||||
|
|
||||||
## 9. Deploy the cert to strongswan
|
|
||||||
|
|
||||||
```sh
|
|
||||||
acme.sh --deploy -d ftp.example.com --deploy-hook strongswan
|
|
||||||
```
|
|
||||||
@@ -51,8 +51,8 @@ cpanel_uapi_deploy() {
|
|||||||
else
|
else
|
||||||
_response=$(uapi SSL install_ssl domain="$_cdomain" cert="$_cert" key="$_key")
|
_response=$(uapi SSL install_ssl domain="$_cdomain" cert="$_cert" key="$_key")
|
||||||
fi
|
fi
|
||||||
error_response="status: 0"
|
|
||||||
if test "${_response#*$error_response}" != "$_response"; then
|
if [ $? -ne 0 ]; then
|
||||||
_err "Error in deploying certificate:"
|
_err "Error in deploying certificate:"
|
||||||
_err "$_response"
|
_err "$_response"
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@@ -1,108 +0,0 @@
|
|||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
#Here is a script to deploy cert to an AVM FRITZ!Box router.
|
|
||||||
|
|
||||||
#returns 0 means success, otherwise error.
|
|
||||||
|
|
||||||
#DEPLOY_FRITZBOX_USERNAME="username"
|
|
||||||
#DEPLOY_FRITZBOX_PASSWORD="password"
|
|
||||||
#DEPLOY_FRITZBOX_URL="https://fritz.box"
|
|
||||||
|
|
||||||
# Kudos to wikrie at Github for his FRITZ!Box update script:
|
|
||||||
# https://gist.github.com/wikrie/f1d5747a714e0a34d0582981f7cb4cfb
|
|
||||||
|
|
||||||
######## Public functions #####################
|
|
||||||
|
|
||||||
#domain keyfile certfile cafile fullchain
|
|
||||||
fritzbox_deploy() {
|
|
||||||
_cdomain="$1"
|
|
||||||
_ckey="$2"
|
|
||||||
_ccert="$3"
|
|
||||||
_cca="$4"
|
|
||||||
_cfullchain="$5"
|
|
||||||
|
|
||||||
_debug _cdomain "$_cdomain"
|
|
||||||
_debug _ckey "$_ckey"
|
|
||||||
_debug _ccert "$_ccert"
|
|
||||||
_debug _cca "$_cca"
|
|
||||||
_debug _cfullchain "$_cfullchain"
|
|
||||||
|
|
||||||
if ! _exists iconv; then
|
|
||||||
_err "iconv not found"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
_fritzbox_username="${DEPLOY_FRITZBOX_USERNAME}"
|
|
||||||
_fritzbox_password="${DEPLOY_FRITZBOX_PASSWORD}"
|
|
||||||
_fritzbox_url="${DEPLOY_FRITZBOX_URL}"
|
|
||||||
|
|
||||||
_debug _fritzbox_url "$_fritzbox_url"
|
|
||||||
_debug _fritzbox_username "$_fritzbox_username"
|
|
||||||
_secure_debug _fritzbox_password "$_fritzbox_password"
|
|
||||||
if [ -z "$_fritzbox_username" ]; then
|
|
||||||
_err "FRITZ!Box username is not found, please define DEPLOY_FRITZBOX_USERNAME."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [ -z "$_fritzbox_password" ]; then
|
|
||||||
_err "FRITZ!Box password is not found, please define DEPLOY_FRITZBOX_PASSWORD."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [ -z "$_fritzbox_url" ]; then
|
|
||||||
_err "FRITZ!Box url is not found, please define DEPLOY_FRITZBOX_URL."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
_saveaccountconf DEPLOY_FRITZBOX_USERNAME "${_fritzbox_username}"
|
|
||||||
_saveaccountconf DEPLOY_FRITZBOX_PASSWORD "${_fritzbox_password}"
|
|
||||||
_saveaccountconf DEPLOY_FRITZBOX_URL "${_fritzbox_url}"
|
|
||||||
|
|
||||||
# Do not check for a valid SSL certificate, because initially the cert is not valid, so it could not install the LE generated certificate
|
|
||||||
export HTTPS_INSECURE=1
|
|
||||||
|
|
||||||
_info "Log in to the FRITZ!Box"
|
|
||||||
_fritzbox_challenge="$(_get "${_fritzbox_url}/login_sid.lua" | sed -e 's/^.*<Challenge>//' -e 's/<\/Challenge>.*$//')"
|
|
||||||
_fritzbox_hash="$(printf "%s-%s" "${_fritzbox_challenge}" "${_fritzbox_password}" | iconv -f ASCII -t UTF16LE | md5sum | awk '{print $1}')"
|
|
||||||
_fritzbox_sid="$(_get "${_fritzbox_url}/login_sid.lua?sid=0000000000000000&username=${_fritzbox_username}&response=${_fritzbox_challenge}-${_fritzbox_hash}" | sed -e 's/^.*<SID>//' -e 's/<\/SID>.*$//')"
|
|
||||||
|
|
||||||
if [ -z "${_fritzbox_sid}" ] || [ "${_fritzbox_sid}" = "0000000000000000" ]; then
|
|
||||||
_err "Logging in to the FRITZ!Box failed. Please check username, password and URL."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
_info "Generate form POST request"
|
|
||||||
_post_request="$(_mktemp)"
|
|
||||||
_post_boundary="---------------------------$(date +%Y%m%d%H%M%S)"
|
|
||||||
# _CERTPASSWORD_ is unset because Let's Encrypt certificates don't have a password. But if they ever do, here's the place to use it!
|
|
||||||
_CERTPASSWORD_=
|
|
||||||
{
|
|
||||||
printf -- "--"
|
|
||||||
printf -- "%s\r\n" "${_post_boundary}"
|
|
||||||
printf "Content-Disposition: form-data; name=\"sid\"\r\n\r\n%s\r\n" "${_fritzbox_sid}"
|
|
||||||
printf -- "--"
|
|
||||||
printf -- "%s\r\n" "${_post_boundary}"
|
|
||||||
printf "Content-Disposition: form-data; name=\"BoxCertPassword\"\r\n\r\n%s\r\n" "${_CERTPASSWORD_}"
|
|
||||||
printf -- "--"
|
|
||||||
printf -- "%s\r\n" "${_post_boundary}"
|
|
||||||
printf "Content-Disposition: form-data; name=\"BoxCertImportFile\"; filename=\"BoxCert.pem\"\r\n"
|
|
||||||
printf "Content-Type: application/octet-stream\r\n\r\n"
|
|
||||||
cat "${_ckey}" "${_cfullchain}"
|
|
||||||
printf "\r\n"
|
|
||||||
printf -- "--"
|
|
||||||
printf -- "%s--" "${_post_boundary}"
|
|
||||||
} >>"${_post_request}"
|
|
||||||
|
|
||||||
_info "Upload certificate to the FRITZ!Box"
|
|
||||||
|
|
||||||
export _H1="Content-type: multipart/form-data boundary=${_post_boundary}"
|
|
||||||
_post "$(cat "${_post_request}")" "${_fritzbox_url}/cgi-bin/firmwarecfg" | grep SSL
|
|
||||||
|
|
||||||
retval=$?
|
|
||||||
if [ $retval = 0 ]; then
|
|
||||||
_info "Upload successful"
|
|
||||||
else
|
|
||||||
_err "Upload failed"
|
|
||||||
fi
|
|
||||||
rm "${_post_request}"
|
|
||||||
|
|
||||||
return $retval
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
#Here is a sample custom api script.
|
|
||||||
#This file name is "myapi.sh"
|
|
||||||
#So, here must be a method myapi_deploy()
|
|
||||||
#Which will be called by acme.sh to deploy the cert
|
|
||||||
#returns 0 means success, otherwise error.
|
|
||||||
|
|
||||||
######## Public functions #####################
|
|
||||||
|
|
||||||
#domain keyfile certfile cafile fullchain
|
|
||||||
strongswan_deploy() {
|
|
||||||
_cdomain="$1"
|
|
||||||
_ckey="$2"
|
|
||||||
_ccert="$3"
|
|
||||||
_cca="$4"
|
|
||||||
_cfullchain="$5"
|
|
||||||
|
|
||||||
_debug _cdomain "$_cdomain"
|
|
||||||
_debug _ckey "$_ckey"
|
|
||||||
_debug _ccert "$_ccert"
|
|
||||||
_debug _cca "$_cca"
|
|
||||||
_debug _cfullchain "$_cfullchain"
|
|
||||||
|
|
||||||
cat "$_ckey" >"/etc/ipsec.d/private/$(basename "$_ckey")"
|
|
||||||
cat "$_ccert" >"/etc/ipsec.d/certs/$(basename "$_ccert")"
|
|
||||||
cat "$_cca" >"/etc/ipsec.d/cacerts/$(basename "$_cca")"
|
|
||||||
cat "$_cfullchain" >"/etc/ipsec.d/cacerts/$(basename "$_cfullchain")"
|
|
||||||
|
|
||||||
ipsec reload
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -420,7 +420,6 @@ Ok, let's issue a cert now:
|
|||||||
```
|
```
|
||||||
acme.sh --issue --dns dns_cloudns -d example.com -d www.example.com
|
acme.sh --issue --dns dns_cloudns -d example.com -d www.example.com
|
||||||
```
|
```
|
||||||
The `CLOUDNS_AUTH_ID` and `CLOUDNS_AUTH_PASSWORD` will be saved in `~/.acme.sh/account.conf` and will be reused when needed.
|
|
||||||
|
|
||||||
## 22. Use Infoblox API
|
## 22. Use Infoblox API
|
||||||
|
|
||||||
@@ -618,7 +617,6 @@ acme.sh --issue --dns dns_myapi -d example.com -d www.example.com
|
|||||||
|
|
||||||
For more details, please check our sample script: [dns_myapi.sh](dns_myapi.sh)
|
For more details, please check our sample script: [dns_myapi.sh](dns_myapi.sh)
|
||||||
|
|
||||||
See: https://github.com/Neilpang/acme.sh/wiki/DNS-API-Dev-Guide
|
|
||||||
|
|
||||||
# Use lexicon DNS API
|
# Use lexicon DNS API
|
||||||
|
|
||||||
|
|||||||
+9
-10
@@ -87,7 +87,6 @@ _get_root() {
|
|||||||
_debug "response" "$response"
|
_debug "response" "$response"
|
||||||
while true; do
|
while true; do
|
||||||
h=$(printf "%s" "$domain" | cut -d . -f $i-100)
|
h=$(printf "%s" "$domain" | cut -d . -f $i-100)
|
||||||
_debug2 "Checking domain: $h"
|
|
||||||
if [ -z "$h" ]; then
|
if [ -z "$h" ]; then
|
||||||
if _contains "$response" "<IsTruncated>true</IsTruncated>" && _contains "$response" "<NextMarker>"; then
|
if _contains "$response" "<IsTruncated>true</IsTruncated>" && _contains "$response" "<NextMarker>"; then
|
||||||
_debug "IsTruncated"
|
_debug "IsTruncated"
|
||||||
@@ -103,23 +102,23 @@ _get_root() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
#not valid
|
#not valid
|
||||||
_err "Invalid domain"
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if _contains "$response" "<Name>$h.</Name>"; then
|
if _contains "$response" "<Name>$h.</Name>"; then
|
||||||
hostedzone="$(echo "$response" | sed 's/<HostedZone>/#&/g' | tr '#' '\n' | _egrep_o "<HostedZone><Id>[^<]*<.Id><Name>$h.<.Name>.*<PrivateZone>false<.PrivateZone>.*<.HostedZone>")"
|
hostedzone="$(echo "$response" | sed 's/<HostedZone>/#&/g' | tr '#' '\n' | _egrep_o "<HostedZone><Id>[^<]*<.Id><Name>$h.<.Name>.*<PrivateZone>false<.PrivateZone>.*<.HostedZone>")"
|
||||||
_debug hostedzone "$hostedzone"
|
_debug hostedzone "$hostedzone"
|
||||||
if [ "$hostedzone" ]; then
|
if [ -z "$hostedzone" ]; then
|
||||||
_domain_id=$(printf "%s\n" "$hostedzone" | _egrep_o "<Id>.*<.Id>" | head -n 1 | _egrep_o ">.*<" | tr -d "<>")
|
_err "Error, can not get hostedzone."
|
||||||
if [ "$_domain_id" ]; then
|
|
||||||
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
|
|
||||||
_domain=$h
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
_err "Can not find domain id: $h"
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
_domain_id=$(printf "%s\n" "$hostedzone" | _egrep_o "<Id>.*<.Id>" | head -n 1 | _egrep_o ">.*<" | tr -d "<>")
|
||||||
|
if [ "$_domain_id" ]; then
|
||||||
|
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
|
||||||
|
_domain=$h
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
p=$i
|
p=$i
|
||||||
i=$(_math "$i" + 1)
|
i=$(_math "$i" + 1)
|
||||||
|
|||||||
@@ -96,16 +96,6 @@ _dns_cloudns_init_check() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CLOUDNS_AUTH_ID="${CLOUDNS_AUTH_ID:-$(_readaccountconf_mutable CLOUDNS_AUTH_ID)}"
|
|
||||||
CLOUDNS_AUTH_PASSWORD="${CLOUDNS_AUTH_PASSWORD:-$(_readaccountconf_mutable CLOUDNS_AUTH_PASSWORD)}"
|
|
||||||
if [ -z "$CLOUDNS_AUTH_ID" ] || [ -z "$CLOUDNS_AUTH_PASSWORD" ]; then
|
|
||||||
CLOUDNS_AUTH_ID=""
|
|
||||||
CLOUDNS_AUTH_PASSWORD=""
|
|
||||||
_err "You don't specify cloudns api id and password yet."
|
|
||||||
_err "Please create you id and password and try again."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$CLOUDNS_AUTH_ID" ]; then
|
if [ -z "$CLOUDNS_AUTH_ID" ]; then
|
||||||
_err "CLOUDNS_AUTH_ID is not configured"
|
_err "CLOUDNS_AUTH_ID is not configured"
|
||||||
return 1
|
return 1
|
||||||
@@ -123,10 +113,6 @@ _dns_cloudns_init_check() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#save the api id and password to the account conf file.
|
|
||||||
_saveaccountconf_mutable CLOUDNS_AUTH_ID "$CLOUDNS_AUTH_ID"
|
|
||||||
_saveaccountconf_mutable CLOUDNS_AUTH_PASSWORD "$CLOUDNS_AUTH_PASSWORD"
|
|
||||||
|
|
||||||
CLOUDNS_INIT_CHECK_COMPLETED=1
|
CLOUDNS_INIT_CHECK_COMPLETED=1
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
+45
-32
@@ -53,8 +53,6 @@ dns_freedns_add() {
|
|||||||
i="$(_math "$i" - 1)"
|
i="$(_math "$i" - 1)"
|
||||||
sub_domain="$(echo "$fulldomain" | cut -d. -f -"$i")"
|
sub_domain="$(echo "$fulldomain" | cut -d. -f -"$i")"
|
||||||
|
|
||||||
_debug top_domain "$top_domain"
|
|
||||||
_debug sub_domain "$sub_domain"
|
|
||||||
# Sometimes FreeDNS does not return the subdomain page but rather
|
# Sometimes FreeDNS does not return the subdomain page but rather
|
||||||
# returns a page regarding becoming a premium member. This usually
|
# returns a page regarding becoming a premium member. This usually
|
||||||
# happens after a period of inactivity. Immediately trying again
|
# happens after a period of inactivity. Immediately trying again
|
||||||
@@ -63,6 +61,7 @@ dns_freedns_add() {
|
|||||||
attempts=2
|
attempts=2
|
||||||
while [ "$attempts" -gt "0" ]; do
|
while [ "$attempts" -gt "0" ]; do
|
||||||
attempts="$(_math "$attempts" - 1)"
|
attempts="$(_math "$attempts" - 1)"
|
||||||
|
|
||||||
htmlpage="$(_freedns_retrieve_subdomain_page "$FREEDNS_COOKIE")"
|
htmlpage="$(_freedns_retrieve_subdomain_page "$FREEDNS_COOKIE")"
|
||||||
if [ "$?" != "0" ]; then
|
if [ "$?" != "0" ]; then
|
||||||
if [ "$using_cached_cookies" = "true" ]; then
|
if [ "$using_cached_cookies" = "true" ]; then
|
||||||
@@ -71,11 +70,19 @@ dns_freedns_add() {
|
|||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
_debug2 htmlpage "$htmlpage"
|
|
||||||
|
|
||||||
subdomain_csv="$(echo "$htmlpage" | tr -d "\n\r" | _egrep_o '<form .*</form>' | sed 's/<tr>/@<tr>/g' | tr '@' '\n' | grep edit.php | grep "$top_domain")"
|
|
||||||
_debug2 subdomain_csv "$subdomain_csv"
|
|
||||||
|
|
||||||
|
# Now convert the tables in the HTML to CSV. This litte gem from
|
||||||
|
# http://stackoverflow.com/questions/1403087/how-can-i-convert-an-html-table-to-csv
|
||||||
|
subdomain_csv="$(echo "$htmlpage" \
|
||||||
|
| grep -i -e '</\?TABLE\|</\?TD\|</\?TR\|</\?TH' \
|
||||||
|
| sed 's/^[\ \t]*//g' \
|
||||||
|
| tr -d '\n' \
|
||||||
|
| sed 's/<\/TR[^>]*>/\n/Ig' \
|
||||||
|
| sed 's/<\/\?\(TABLE\|TR\)[^>]*>//Ig' \
|
||||||
|
| sed 's/^<T[DH][^>]*>\|<\/\?T[DH][^>]*>$//Ig' \
|
||||||
|
| sed 's/<\/T[DH][^>]*><T[DH][^>]*>/,/Ig' \
|
||||||
|
| grep 'edit.php?' \
|
||||||
|
| grep "$top_domain")"
|
||||||
# The above beauty ends with striping out rows that do not have an
|
# The above beauty ends with striping out rows that do not have an
|
||||||
# href to edit.php and do not have the top domain we are looking for.
|
# href to edit.php and do not have the top domain we are looking for.
|
||||||
# So all we should be left with is CSV of table of subdomains we are
|
# So all we should be left with is CSV of table of subdomains we are
|
||||||
@@ -83,32 +90,30 @@ dns_freedns_add() {
|
|||||||
|
|
||||||
# Now we have to read through this table and extract the data we need
|
# Now we have to read through this table and extract the data we need
|
||||||
lines="$(echo "$subdomain_csv" | wc -l)"
|
lines="$(echo "$subdomain_csv" | wc -l)"
|
||||||
|
nl='
|
||||||
|
'
|
||||||
i=0
|
i=0
|
||||||
found=0
|
found=0
|
||||||
while [ "$i" -lt "$lines" ]; do
|
while [ "$i" -lt "$lines" ]; do
|
||||||
i="$(_math "$i" + 1)"
|
i="$(_math "$i" + 1)"
|
||||||
line="$(echo "$subdomain_csv" | sed -n "${i}p")"
|
line="$(echo "$subdomain_csv" | cut -d "$nl" -f "$i")"
|
||||||
_debug2 line "$line"
|
tmp="$(echo "$line" | cut -d ',' -f 1)"
|
||||||
if [ $found = 0 ] && _contains "$line" "<td>$top_domain</td>"; then
|
if [ $found = 0 ] && _startswith "$tmp" "<td>$top_domain"; then
|
||||||
# this line will contain DNSdomainid for the top_domain
|
# this line will contain DNSdomainid for the top_domain
|
||||||
DNSdomainid="$(echo "$line" | _egrep_o "edit_domain_id *= *.*>" | cut -d = -f 2 | cut -d '>' -f 1)"
|
DNSdomainid="$(echo "$line" | cut -d ',' -f 2 | sed 's/^.*domain_id=//;s/>.*//')"
|
||||||
_debug2 DNSdomainid "$DNSdomainid"
|
|
||||||
found=1
|
found=1
|
||||||
else
|
else
|
||||||
# lines contain DNS records for all subdomains
|
# lines contain DNS records for all subdomains
|
||||||
DNSname="$(echo "$line" | _egrep_o 'edit.php.*</a>' | cut -d '>' -f 2 | cut -d '<' -f 1)"
|
DNSname="$(echo "$line" | cut -d ',' -f 2 | sed 's/^[^>]*>//;s/<\/a>.*//')"
|
||||||
_debug2 DNSname "$DNSname"
|
DNStype="$(echo "$line" | cut -d ',' -f 3)"
|
||||||
DNStype="$(echo "$line" | sed 's/<td/@<td/g' | tr '@' '\n' | sed -n '4p' | cut -d '>' -f 2 | cut -d '<' -f 1)"
|
|
||||||
_debug2 DNStype "$DNStype"
|
|
||||||
if [ "$DNSname" = "$fulldomain" ] && [ "$DNStype" = "TXT" ]; then
|
if [ "$DNSname" = "$fulldomain" ] && [ "$DNStype" = "TXT" ]; then
|
||||||
DNSdataid="$(echo "$line" | _egrep_o 'data_id=.*' | cut -d = -f 2 | cut -d '>' -f 1)"
|
DNSdataid="$(echo "$line" | cut -d ',' -f 2 | sed 's/^.*data_id=//;s/>.*//')"
|
||||||
# Now get current value for the TXT record. This method may
|
# Now get current value for the TXT record. This method may
|
||||||
# not produce accurate results as the value field is truncated
|
# not produce accurate results as the value field is truncated
|
||||||
# on this webpage. To get full value we would need to load
|
# on this webpage. To get full value we would need to load
|
||||||
# another page. However we don't really need this so long as
|
# another page. However we don't really need this so long as
|
||||||
# there is only one TXT record for the acme challenge subdomain.
|
# there is only one TXT record for the acme challenge subdomain.
|
||||||
DNSvalue="$(echo "$line" | sed 's/<td/@<td/g' | tr '@' '\n' | sed -n '5p' | cut -d '>' -f 2 | cut -d '<' -f 1)"
|
DNSvalue="$(echo "$line" | cut -d ',' -f 4 | sed 's/^[^"]*"//;s/".*//;s/<\/td>.*//')"
|
||||||
_debug2 DNSvalue "$DNSvalue"
|
|
||||||
if [ $found != 0 ]; then
|
if [ $found != 0 ]; then
|
||||||
break
|
break
|
||||||
# we are breaking out of the loop at the first match of DNS name
|
# we are breaking out of the loop at the first match of DNS name
|
||||||
@@ -164,7 +169,8 @@ dns_freedns_add() {
|
|||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
# Delete the old TXT record (with the wrong value)
|
# Delete the old TXT record (with the wrong value)
|
||||||
if _freedns_delete_txt_record "$FREEDNS_COOKIE" "$DNSdataid"; then
|
_freedns_delete_txt_record "$FREEDNS_COOKIE" "$DNSdataid"
|
||||||
|
if [ "$?" = "0" ]; then
|
||||||
# And add in new TXT record with the value provided
|
# And add in new TXT record with the value provided
|
||||||
_freedns_add_txt_record "$FREEDNS_COOKIE" "$DNSdomainid" "$sub_domain" "$txtvalue"
|
_freedns_add_txt_record "$FREEDNS_COOKIE" "$DNSdomainid" "$sub_domain" "$txtvalue"
|
||||||
fi
|
fi
|
||||||
@@ -204,9 +210,18 @@ dns_freedns_rm() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
subdomain_csv="$(echo "$htmlpage" | tr -d "\n\r" | _egrep_o '<form .*</form>' | sed 's/<tr>/@<tr>/g' | tr '@' '\n' | grep edit.php | grep "$fulldomain")"
|
# Now convert the tables in the HTML to CSV. This litte gem from
|
||||||
_debug2 subdomain_csv "$subdomain_csv"
|
# http://stackoverflow.com/questions/1403087/how-can-i-convert-an-html-table-to-csv
|
||||||
|
subdomain_csv="$(echo "$htmlpage" \
|
||||||
|
| grep -i -e '</\?TABLE\|</\?TD\|</\?TR\|</\?TH' \
|
||||||
|
| sed 's/^[\ \t]*//g' \
|
||||||
|
| tr -d '\n' \
|
||||||
|
| sed 's/<\/TR[^>]*>/\n/Ig' \
|
||||||
|
| sed 's/<\/\?\(TABLE\|TR\)[^>]*>//Ig' \
|
||||||
|
| sed 's/^<T[DH][^>]*>\|<\/\?T[DH][^>]*>$//Ig' \
|
||||||
|
| sed 's/<\/T[DH][^>]*><T[DH][^>]*>/,/Ig' \
|
||||||
|
| grep 'edit.php?' \
|
||||||
|
| grep "$fulldomain")"
|
||||||
# The above beauty ends with striping out rows that do not have an
|
# The above beauty ends with striping out rows that do not have an
|
||||||
# href to edit.php and do not have the domain name we are looking for.
|
# href to edit.php and do not have the domain name we are looking for.
|
||||||
# So all we should be left with is CSV of table of subdomains we are
|
# So all we should be left with is CSV of table of subdomains we are
|
||||||
@@ -214,21 +229,19 @@ dns_freedns_rm() {
|
|||||||
|
|
||||||
# Now we have to read through this table and extract the data we need
|
# Now we have to read through this table and extract the data we need
|
||||||
lines="$(echo "$subdomain_csv" | wc -l)"
|
lines="$(echo "$subdomain_csv" | wc -l)"
|
||||||
|
nl='
|
||||||
|
'
|
||||||
i=0
|
i=0
|
||||||
found=0
|
found=0
|
||||||
while [ "$i" -lt "$lines" ]; do
|
while [ "$i" -lt "$lines" ]; do
|
||||||
i="$(_math "$i" + 1)"
|
i="$(_math "$i" + 1)"
|
||||||
line="$(echo "$subdomain_csv" | sed -n "${i}p")"
|
line="$(echo "$subdomain_csv" | cut -d "$nl" -f "$i")"
|
||||||
_debug2 line "$line"
|
DNSname="$(echo "$line" | cut -d ',' -f 2 | sed 's/^[^>]*>//;s/<\/a>.*//')"
|
||||||
DNSname="$(echo "$line" | _egrep_o 'edit.php.*</a>' | cut -d '>' -f 2 | cut -d '<' -f 1)"
|
DNStype="$(echo "$line" | cut -d ',' -f 3)"
|
||||||
_debug2 DNSname "$DNSname"
|
|
||||||
DNStype="$(echo "$line" | sed 's/<td/@<td/g' | tr '@' '\n' | sed -n '4p' | cut -d '>' -f 2 | cut -d '<' -f 1)"
|
|
||||||
_debug2 DNStype "$DNStype"
|
|
||||||
if [ "$DNSname" = "$fulldomain" ] && [ "$DNStype" = "TXT" ]; then
|
if [ "$DNSname" = "$fulldomain" ] && [ "$DNStype" = "TXT" ]; then
|
||||||
DNSdataid="$(echo "$line" | _egrep_o 'data_id=.*' | cut -d = -f 2 | cut -d '>' -f 1)"
|
DNSdataid="$(echo "$line" | cut -d ',' -f 2 | sed 's/^.*data_id=//;s/>.*//')"
|
||||||
_debug2 DNSdataid "$DNSdataid"
|
DNSvalue="$(echo "$line" | cut -d ',' -f 4 | sed 's/^[^"]*"//;s/".*//;s/<\/td>.*//')"
|
||||||
DNSvalue="$(echo "$line" | sed 's/<td/@<td/g' | tr '@' '\n' | sed -n '5p' | cut -d '>' -f 2 | cut -d '<' -f 1)"
|
_debug "DNSvalue: $DNSvalue"
|
||||||
_debug2 DNSvalue "$DNSvalue"
|
|
||||||
# if [ "$DNSvalue" = "$txtvalue" ]; then
|
# if [ "$DNSvalue" = "$txtvalue" ]; then
|
||||||
# Testing value match fails. Website is truncating the value
|
# Testing value match fails. Website is truncating the value
|
||||||
# field. So for now we will assume that there is only one TXT
|
# field. So for now we will assume that there is only one TXT
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
######## Public functions #####################
|
######## Public functions #####################
|
||||||
|
|
||||||
GANDI_LIVEDNS_API="https://dns.api.gandi.net/api/v5"
|
GANDI_LIVEDNS_API="https://dns.beta.gandi.net/api/v5"
|
||||||
|
|
||||||
#Usage: dns_gandi_livedns_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
|
#Usage: dns_gandi_livedns_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
|
||||||
dns_gandi_livedns_add() {
|
dns_gandi_livedns_add() {
|
||||||
|
|||||||