Merge branch 'dev' into dev
This commit is contained in:
commit
4890887d11
74
.github/workflows/LetsEncrypt.yml
vendored
Normal file
74
.github/workflows/LetsEncrypt.yml
vendored
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
name: LetsEncrypt
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '*'
|
||||||
|
paths:
|
||||||
|
- '**.sh'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
paths:
|
||||||
|
- '**.sh'
|
||||||
|
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Ubuntu:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
NGROK_TOKEN : ${{ secrets.NGROK_TOKEN }}
|
||||||
|
TEST_LOCAL: 1
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Install tools
|
||||||
|
run: sudo apt-get install -y socat
|
||||||
|
- name: Clone acmetest
|
||||||
|
run: cd .. && git clone https://github.com/acmesh-official/acmetest.git && cp -r acme.sh acmetest/
|
||||||
|
- name: Run acmetest
|
||||||
|
run: cd ../acmetest && sudo TEST_LOCAL="$TEST_LOCAL" NGROK_TOKEN="$NGROK_TOKEN" ./letest.sh
|
||||||
|
|
||||||
|
MacOS:
|
||||||
|
runs-on: macos-latest
|
||||||
|
needs: Ubuntu
|
||||||
|
env:
|
||||||
|
NGROK_TOKEN : ${{ secrets.NGROK_TOKEN }}
|
||||||
|
TEST_LOCAL: 1
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Install tools
|
||||||
|
run: brew update && brew install socat;
|
||||||
|
- name: Clone acmetest
|
||||||
|
run: cd .. && git clone https://github.com/acmesh-official/acmetest.git && cp -r acme.sh acmetest/
|
||||||
|
- name: Run acmetest
|
||||||
|
run: cd ../acmetest && sudo TEST_LOCAL="$TEST_LOCAL" NGROK_TOKEN="$NGROK_TOKEN" ./letest.sh
|
||||||
|
|
||||||
|
Windows:
|
||||||
|
runs-on: windows-latest
|
||||||
|
needs: MacOS
|
||||||
|
env:
|
||||||
|
NGROK_TOKEN : ${{ secrets.NGROK_TOKEN }}
|
||||||
|
TEST_LOCAL: 1
|
||||||
|
#The 80 port is used by Windows server, we have to use a custom port, ngrok will also use this port.
|
||||||
|
Le_HTTPPort: 8888
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Install cygwin base packages with chocolatey
|
||||||
|
run: |
|
||||||
|
choco config get cacheLocation
|
||||||
|
choco install --no-progress cygwin
|
||||||
|
shell: cmd
|
||||||
|
- name: Install cygwin additional packages
|
||||||
|
run: |
|
||||||
|
C:\tools\cygwin\cygwinsetup.exe -qgnNdO -R C:/tools/cygwin -s http://mirrors.kernel.org/sourceware/cygwin/ -P socat,curl,cron,unzip,git
|
||||||
|
shell: cmd
|
||||||
|
- name: Set ENV
|
||||||
|
run: |
|
||||||
|
echo '::set-env name=PATH::C:\tools\cygwin\bin;C:\tools\cygwin\usr\bin'
|
||||||
|
- name: Clone acmetest
|
||||||
|
shell: cmd
|
||||||
|
run: cd .. && git clone https://github.com/acmesh-official/acmetest.git && cp -r acme.sh acmetest/ && sed -i 's/\r//g' acmetest/acme.sh/acme.sh
|
||||||
|
- name: Run acmetest
|
||||||
|
shell: cmd
|
||||||
|
run: cd ../acmetest && bash.exe -c ./letest.sh
|
||||||
|
|
||||||
|
|
||||||
37
.github/workflows/PebbleStrict.yml
vendored
Normal file
37
.github/workflows/PebbleStrict.yml
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
name: PebbleStrict
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '*'
|
||||||
|
paths:
|
||||||
|
- '**.sh'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
paths:
|
||||||
|
- '**.sh'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
PebbleStrict:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
TestingDomain: example.com
|
||||||
|
TestingAltDomains: www.example.com
|
||||||
|
ACME_DIRECTORY: https://localhost:14000/dir
|
||||||
|
HTTPS_INSECURE: 1
|
||||||
|
Le_HTTPPort: 5002
|
||||||
|
TEST_LOCAL: 1
|
||||||
|
TEST_CA: "Pebble Intermediate CA"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Install tools
|
||||||
|
run: sudo apt-get install -y socat
|
||||||
|
- name: Run Pebble
|
||||||
|
run: cd .. && curl https://raw.githubusercontent.com/letsencrypt/pebble/master/docker-compose.yml >docker-compose.yml && docker-compose up -d
|
||||||
|
- name: Set up Pebble
|
||||||
|
run: curl --request POST --data '{"ip":"10.30.50.1"}' http://localhost:8055/set-default-ipv4
|
||||||
|
- name: Clone acmetest
|
||||||
|
run: cd .. && git clone https://github.com/acmesh-official/acmetest.git && cp -r acme.sh acmetest/
|
||||||
|
- name: Run acmetest
|
||||||
|
run: cd ../acmetest && ./letest.sh
|
||||||
40
.github/workflows/dockerhub.yml
vendored
40
.github/workflows/dockerhub.yml
vendored
@ -2,15 +2,45 @@
|
|||||||
name: Build DockerHub
|
name: Build DockerHub
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master, dev ]
|
branches:
|
||||||
|
- '*'
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: trigger
|
- name: checkout code
|
||||||
run: curl -X POST https://hub.docker.com/api/build/v1/source/1813a660-2ee5-4583-a238-dd54e9a6ebac/trigger/c8cd9f1f-f269-45bc-9750-a08327257f62/call/
|
uses: actions/checkout@v2
|
||||||
|
- name: install buildx
|
||||||
|
id: buildx
|
||||||
|
uses: crazy-max/ghaction-docker-buildx@v3
|
||||||
|
with:
|
||||||
|
buildx-version: latest
|
||||||
|
qemu-version: latest
|
||||||
|
- name: login to docker hub
|
||||||
|
run: |
|
||||||
|
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
||||||
|
- name: build and push the image
|
||||||
|
run: |
|
||||||
|
DOCKER_IMAGE=neilpang/acme.sh
|
||||||
|
|
||||||
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||||
|
DOCKER_IMAGE_TAG=${GITHUB_REF#refs/tags/}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $GITHUB_REF == refs/heads/* ]]; then
|
||||||
|
DOCKER_IMAGE_TAG=${GITHUB_REF#refs/heads/}
|
||||||
|
|
||||||
|
if [[ $DOCKER_IMAGE_TAG == master ]]; then
|
||||||
|
DOCKER_IMAGE_TAG=latest
|
||||||
|
AUTO_UPGRADE=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker buildx build \
|
||||||
|
--tag ${DOCKER_IMAGE}:${DOCKER_IMAGE_TAG} \
|
||||||
|
--output "type=image,push=true" \
|
||||||
|
--build-arg AUTO_UPGRADE=${AUTO_UPGRADE} \
|
||||||
|
--platform linux/arm64/v8,linux/amd64,linux/arm/v6,linux/arm/v7,linux/386 .
|
||||||
|
|||||||
26
.github/workflows/shellcheck.yml
vendored
Normal file
26
.github/workflows/shellcheck.yml
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
name: Shellcheck
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '*'
|
||||||
|
paths:
|
||||||
|
- '**.sh'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
paths:
|
||||||
|
- '**.sh'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
formatCheck:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Install Shellcheck
|
||||||
|
run: sudo apt-get install -y shellcheck
|
||||||
|
- name: DoShellcheck
|
||||||
|
run: shellcheck -V && shellcheck -e SC2181 **/*.sh && echo "shellcheck OK"
|
||||||
|
- name: Install shfmt
|
||||||
|
run: curl -sSL https://github.com/mvdan/sh/releases/download/v3.1.2/shfmt_v3.1.2_linux_amd64 -o ~/shfmt && chmod +x ~/shfmt
|
||||||
|
- name: shfmt
|
||||||
|
run: ~/shfmt -l -w -i 2 . ; git diff --exit-code && echo "shfmt OK"
|
||||||
37
.travis.yml
37
.travis.yml
@ -1,37 +0,0 @@
|
|||||||
language: shell
|
|
||||||
dist: bionic
|
|
||||||
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
- osx
|
|
||||||
|
|
||||||
services:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
env:
|
|
||||||
global:
|
|
||||||
- SHFMT_URL=https://github.com/mvdan/sh/releases/download/v0.4.0/shfmt_v0.4.0_linux_amd64
|
|
||||||
|
|
||||||
|
|
||||||
install:
|
|
||||||
- if [ "$TRAVIS_OS_NAME" = 'osx' ]; then
|
|
||||||
brew update && brew install socat;
|
|
||||||
export PATH="/usr/local/opt/openssl@1.1/bin:$PATH" ;
|
|
||||||
fi
|
|
||||||
|
|
||||||
script:
|
|
||||||
- echo "NGROK_TOKEN=$(echo "$NGROK_TOKEN" | wc -c)"
|
|
||||||
- command -V openssl && openssl version
|
|
||||||
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then curl -sSL $SHFMT_URL -o ~/shfmt && chmod +x ~/shfmt && ~/shfmt -l -w -i 2 . ; fi
|
|
||||||
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then git diff --exit-code && echo "shfmt OK" ; fi
|
|
||||||
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then shellcheck -V ; fi
|
|
||||||
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then shellcheck -e SC2181 **/*.sh && echo "shellcheck OK" ; fi
|
|
||||||
- cd ..
|
|
||||||
- git clone --depth 1 https://github.com/acmesh-official/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" = "osx" -a "$NGROK_TOKEN" ]; then sudo TEST_LOCAL="$TEST_LOCAL" NGROK_TOKEN="$NGROK_TOKEN" ACME_OPENSSL_BIN="$ACME_OPENSSL_BIN" ./letest.sh ; fi
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
fast_finish: true
|
|
||||||
|
|
||||||
|
|
||||||
@ -15,7 +15,9 @@ RUN apk update -f \
|
|||||||
|
|
||||||
ENV LE_CONFIG_HOME /acme.sh
|
ENV LE_CONFIG_HOME /acme.sh
|
||||||
|
|
||||||
ENV AUTO_UPGRADE 1
|
ARG AUTO_UPGRADE=1
|
||||||
|
|
||||||
|
ENV AUTO_UPGRADE $AUTO_UPGRADE
|
||||||
|
|
||||||
#Install
|
#Install
|
||||||
ADD ./ /install_acme.sh/
|
ADD ./ /install_acme.sh/
|
||||||
@ -52,6 +54,7 @@ RUN for verb in help \
|
|||||||
deactivate \
|
deactivate \
|
||||||
deactivate-account \
|
deactivate-account \
|
||||||
set-notify \
|
set-notify \
|
||||||
|
set-default-ca \
|
||||||
; do \
|
; do \
|
||||||
printf -- "%b" "#!/usr/bin/env sh\n/root/.acme.sh/acme.sh --${verb} --config-home /acme.sh \"\$@\"" >/usr/local/bin/--${verb} && chmod +x /usr/local/bin/--${verb} \
|
printf -- "%b" "#!/usr/bin/env sh\n/root/.acme.sh/acme.sh --${verb} --config-home /acme.sh \"\$@\"" >/usr/local/bin/--${verb} && chmod +x /usr/local/bin/--${verb} \
|
||||||
; done
|
; done
|
||||||
|
|||||||
21
README.md
21
README.md
@ -1,12 +1,15 @@
|
|||||||
# An ACME Shell script: acme.sh [](https://travis-ci.org/acmesh-official/acme.sh)
|
# An ACME Shell script: acme.sh
|
||||||
|
|
||||||
<a href="https://opencollective.com/acmesh" alt="Financial Contributors on Open Collective"><img src="https://opencollective.com/acmesh/all/badge.svg?label=financial+contributors" /></a> [](https://gitter.im/acme-sh/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
acme.sh is being sponsored by the following tool; please help to support us by taking a look and signing up to a free trial
|
<a href="https://opencollective.com/acmesh" alt="Financial Contributors on Open Collective"><img src="https://opencollective.com/acmesh/all/badge.svg?label=financial+contributors" /></a>
|
||||||
|
[](https://gitter.im/acme-sh/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
[](https://hub.docker.com/r/neilpang/acme.sh "Click to view the image on Docker Hub")
|
||||||
<a href="https://tracking.gitads.io/?repo=acme.sh"> <img src="https://images.gitads.io/acme.sh" alt="GitAds"/> </a>
|
[](https://hub.docker.com/r/neilpang/acme.sh "Click to view the image on Docker Hub")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -16,7 +19,6 @@ acme.sh is being sponsored by the following tool; please help to support us by t
|
|||||||
- Support ACME v2 wildcard certs
|
- Support ACME v2 wildcard certs
|
||||||
- Simple, powerful and very easy to use. You only need 3 minutes to learn it.
|
- Simple, powerful and very easy to use. You only need 3 minutes to learn it.
|
||||||
- Bash, dash and sh compatible.
|
- Bash, dash and sh compatible.
|
||||||
- Simplest shell script for Let's Encrypt free certificate client.
|
|
||||||
- Purely written in Shell with no dependencies on python or the official Let's Encrypt client.
|
- Purely written in Shell with no dependencies on python or the official Let's Encrypt client.
|
||||||
- Just one script to issue, renew and install your certificates automatically.
|
- Just one script to issue, renew and install your certificates automatically.
|
||||||
- DOES NOT require `root/sudoer` access.
|
- DOES NOT require `root/sudoer` access.
|
||||||
@ -74,7 +76,7 @@ Twitter: [@neilpangxa](https://twitter.com/neilpangxa)
|
|||||||
|17|-----| OpenWRT: Tested and working. See [wiki page](https://github.com/acmesh-official/acme.sh/wiki/How-to-run-on-OpenWRT)
|
|17|-----| OpenWRT: Tested and working. See [wiki page](https://github.com/acmesh-official/acme.sh/wiki/How-to-run-on-OpenWRT)
|
||||||
|18|[](https://github.com/acmesh-official/acmetest#here-are-the-latest-status)|SunOS/Solaris
|
|18|[](https://github.com/acmesh-official/acmetest#here-are-the-latest-status)|SunOS/Solaris
|
||||||
|19|[](https://github.com/acmesh-official/acmetest#here-are-the-latest-status)|Gentoo Linux
|
|19|[](https://github.com/acmesh-official/acmetest#here-are-the-latest-status)|Gentoo Linux
|
||||||
|20|[](https://travis-ci.org/acmesh-official/acme.sh)|Mac OSX
|
|20|[](https://github.com/acmesh-official/acme.sh/actions?query=workflow%3ALetsEncrypt)|Mac OSX
|
||||||
|21|[](https://github.com/acmesh-official/acmetest#here-are-the-latest-status)|ClearLinux
|
|21|[](https://github.com/acmesh-official/acmetest#here-are-the-latest-status)|ClearLinux
|
||||||
|
|
||||||
For all build statuses, check our [weekly build project](https://github.com/acmesh-official/acmetest):
|
For all build statuses, check our [weekly build project](https://github.com/acmesh-official/acmetest):
|
||||||
@ -84,6 +86,7 @@ https://github.com/acmesh-official/acmetest
|
|||||||
# Supported CA
|
# Supported CA
|
||||||
|
|
||||||
- Letsencrypt.org CA(default)
|
- Letsencrypt.org CA(default)
|
||||||
|
- [ZeroSSL.com CA](https://github.com/acmesh-official/acme.sh/wiki/ZeroSSL.com-CA)
|
||||||
- [BuyPass.com CA](https://github.com/acmesh-official/acme.sh/wiki/BuyPass.com-CA)
|
- [BuyPass.com CA](https://github.com/acmesh-official/acme.sh/wiki/BuyPass.com-CA)
|
||||||
- [Pebble strict Mode](https://github.com/letsencrypt/pebble)
|
- [Pebble strict Mode](https://github.com/letsencrypt/pebble)
|
||||||
|
|
||||||
@ -309,7 +312,7 @@ https://github.com/acmesh-official/acme.sh/wiki/dnsapi
|
|||||||
|
|
||||||
See: https://github.com/acmesh-official/acme.sh/wiki/dns-manual-mode first.
|
See: https://github.com/acmesh-official/acme.sh/wiki/dns-manual-mode first.
|
||||||
|
|
||||||
If your dns provider doesn't support any api access, you can add the txt record by your hand.
|
If your dns provider doesn't support any api access, you can add the txt record by hand.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
acme.sh --issue --dns -d example.com -d www.example.com -d cp.example.com
|
acme.sh --issue --dns -d example.com -d www.example.com -d cp.example.com
|
||||||
|
|||||||
@ -69,8 +69,8 @@ exim4_deploy() {
|
|||||||
cp "$_exim4_conf" "$_backup_conf"
|
cp "$_exim4_conf" "$_backup_conf"
|
||||||
|
|
||||||
_info "Modify exim4 conf: $_exim4_conf"
|
_info "Modify exim4 conf: $_exim4_conf"
|
||||||
if _setopt "$_exim4_conf" "tls_certificate" "=" "$_real_fullchain" \
|
if _setopt "$_exim4_conf" "tls_certificate" "=" "$_real_fullchain" &&
|
||||||
&& _setopt "$_exim4_conf" "tls_privatekey" "=" "$_real_key"; then
|
_setopt "$_exim4_conf" "tls_privatekey" "=" "$_real_key"; then
|
||||||
_info "Set config success!"
|
_info "Set config success!"
|
||||||
else
|
else
|
||||||
_err "Config exim4 server error, please report bug to us."
|
_err "Config exim4 server error, please report bug to us."
|
||||||
|
|||||||
@ -195,8 +195,8 @@ then rm -rf \"\$fn\"; echo \"Backup \$fn deleted as older than 180 days\"; fi; d
|
|||||||
fi
|
fi
|
||||||
if [ -n "$Le_Deploy_ssh_cafile" ]; then
|
if [ -n "$Le_Deploy_ssh_cafile" ]; then
|
||||||
_pipe=">"
|
_pipe=">"
|
||||||
if [ "$Le_Deploy_ssh_cafile" = "$Le_Deploy_ssh_keyfile" ] \
|
if [ "$Le_Deploy_ssh_cafile" = "$Le_Deploy_ssh_keyfile" ] ||
|
||||||
|| [ "$Le_Deploy_ssh_cafile" = "$Le_Deploy_ssh_certfile" ]; then
|
[ "$Le_Deploy_ssh_cafile" = "$Le_Deploy_ssh_certfile" ]; then
|
||||||
# if filename is same as previous file then append.
|
# if filename is same as previous file then append.
|
||||||
_pipe=">>"
|
_pipe=">>"
|
||||||
elif [ "$Le_Deploy_ssh_backup" = "yes" ]; then
|
elif [ "$Le_Deploy_ssh_backup" = "yes" ]; then
|
||||||
@ -222,9 +222,9 @@ then rm -rf \"\$fn\"; echo \"Backup \$fn deleted as older than 180 days\"; fi; d
|
|||||||
fi
|
fi
|
||||||
if [ -n "$Le_Deploy_ssh_fullchain" ]; then
|
if [ -n "$Le_Deploy_ssh_fullchain" ]; then
|
||||||
_pipe=">"
|
_pipe=">"
|
||||||
if [ "$Le_Deploy_ssh_fullchain" = "$Le_Deploy_ssh_keyfile" ] \
|
if [ "$Le_Deploy_ssh_fullchain" = "$Le_Deploy_ssh_keyfile" ] ||
|
||||||
|| [ "$Le_Deploy_ssh_fullchain" = "$Le_Deploy_ssh_certfile" ] \
|
[ "$Le_Deploy_ssh_fullchain" = "$Le_Deploy_ssh_certfile" ] ||
|
||||||
|| [ "$Le_Deploy_ssh_fullchain" = "$Le_Deploy_ssh_cafile" ]; then
|
[ "$Le_Deploy_ssh_fullchain" = "$Le_Deploy_ssh_cafile" ]; then
|
||||||
# if filename is same as previous file then append.
|
# if filename is same as previous file then append.
|
||||||
_pipe=">>"
|
_pipe=">>"
|
||||||
elif [ "$Le_Deploy_ssh_backup" = "yes" ]; then
|
elif [ "$Le_Deploy_ssh_backup" = "yes" ]; then
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
######## Public functions #####################
|
######## Public functions #####################
|
||||||
|
|
||||||
_syno_get_cookie_data() {
|
_syno_get_cookie_data() {
|
||||||
grep "\W$1=" | grep "^Set-Cookie:" | _tail_n 1 | _egrep_o "$1=[^;]*;" | tr -d ';'
|
grep -i "\W$1=" | grep -i "^Set-Cookie:" | _tail_n 1 | _egrep_o "$1=[^;]*;" | tr -d ';'
|
||||||
}
|
}
|
||||||
|
|
||||||
#domain keyfile certfile cafile fullchain
|
#domain keyfile certfile cafile fullchain
|
||||||
@ -79,7 +79,7 @@ synology_dsm_deploy() {
|
|||||||
encoded_password="$(printf "%s" "$SYNO_Password" | _url_encode)"
|
encoded_password="$(printf "%s" "$SYNO_Password" | _url_encode)"
|
||||||
encoded_did="$(printf "%s" "$SYNO_DID" | _url_encode)"
|
encoded_did="$(printf "%s" "$SYNO_DID" | _url_encode)"
|
||||||
response=$(_get "$_base_url/webman/login.cgi?username=$encoded_username&passwd=$encoded_password&enable_syno_token=yes&device_id=$encoded_did" 1)
|
response=$(_get "$_base_url/webman/login.cgi?username=$encoded_username&passwd=$encoded_password&enable_syno_token=yes&device_id=$encoded_did" 1)
|
||||||
token=$(echo "$response" | grep "X-SYNO-TOKEN:" | sed -n 's/^X-SYNO-TOKEN: \(.*\)$/\1/p' | tr -d "\r\n")
|
token=$(echo "$response" | grep -i "X-SYNO-TOKEN:" | sed -n 's/^X-SYNO-TOKEN: \(.*\)$/\1/pI' | tr -d "\r\n")
|
||||||
_debug3 response "$response"
|
_debug3 response "$response"
|
||||||
_debug token "$token"
|
_debug token "$token"
|
||||||
|
|
||||||
|
|||||||
@ -65,9 +65,9 @@ vsftpd_deploy() {
|
|||||||
cp "$_vsftpd_conf" "$_backup_conf"
|
cp "$_vsftpd_conf" "$_backup_conf"
|
||||||
|
|
||||||
_info "Modify vsftpd conf: $_vsftpd_conf"
|
_info "Modify vsftpd conf: $_vsftpd_conf"
|
||||||
if _setopt "$_vsftpd_conf" "rsa_cert_file" "=" "$_real_fullchain" \
|
if _setopt "$_vsftpd_conf" "rsa_cert_file" "=" "$_real_fullchain" &&
|
||||||
&& _setopt "$_vsftpd_conf" "rsa_private_key_file" "=" "$_real_key" \
|
_setopt "$_vsftpd_conf" "rsa_private_key_file" "=" "$_real_key" &&
|
||||||
&& _setopt "$_vsftpd_conf" "ssl_enable" "=" "YES"; then
|
_setopt "$_vsftpd_conf" "ssl_enable" "=" "YES"; then
|
||||||
_info "Set config success!"
|
_info "Set config success!"
|
||||||
else
|
else
|
||||||
_err "Config vsftpd server error, please report bug to us."
|
_err "Config vsftpd server error, please report bug to us."
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
#So, here must be a method dns_1984hosting_add()
|
#So, here must be a method dns_1984hosting_add()
|
||||||
#Which will be called by acme.sh to add the txt record to your api system.
|
#Which will be called by acme.sh to add the txt record to your api system.
|
||||||
#returns 0 means success, otherwise error.
|
#returns 0 means success, otherwise error.
|
||||||
#
|
|
||||||
#Author: Adrian Fedoreanu
|
#Author: Adrian Fedoreanu
|
||||||
#Report Bugs here: https://github.com/acmesh-official/acme.sh
|
#Report Bugs here: https://github.com/acmesh-official/acme.sh
|
||||||
# or here... https://github.com/acmesh-official/acme.sh/issues/2851
|
# or here... https://github.com/acmesh-official/acme.sh/issues/2851
|
||||||
@ -100,7 +100,7 @@ _1984hosting_add_txt_record() {
|
|||||||
elif _contains "$response" "<html>"; then
|
elif _contains "$response" "<html>"; then
|
||||||
_err "1984Hosting failed to add TXT record for $subdomain. Check $HTTP_HEADER file"
|
_err "1984Hosting failed to add TXT record for $subdomain. Check $HTTP_HEADER file"
|
||||||
return 1
|
return 1
|
||||||
elif [ "$response" = '{"auth": false, "ok": false}' ]; then
|
elif _contains "$response" '"auth": false'; then
|
||||||
_err "1984Hosting failed to add TXT record for $subdomain. Invalid or expired cookie"
|
_err "1984Hosting failed to add TXT record for $subdomain. Invalid or expired cookie"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -167,7 +167,7 @@ _1984hosting_login() {
|
|||||||
response="$(echo "$response" | _normalizeJson)"
|
response="$(echo "$response" | _normalizeJson)"
|
||||||
_debug2 response "$response"
|
_debug2 response "$response"
|
||||||
|
|
||||||
if [ "$response" = '{"loggedin": true, "ok": true}' ]; then
|
if _contains "$response" '"loggedin": true'; then
|
||||||
One984HOSTING_COOKIE="$(grep -i '^set-cookie:' "$HTTP_HEADER" | _tail_n 1 | _egrep_o 'sessionid=[^;]*;' | tr -d ';')"
|
One984HOSTING_COOKIE="$(grep -i '^set-cookie:' "$HTTP_HEADER" | _tail_n 1 | _egrep_o 'sessionid=[^;]*;' | tr -d ';')"
|
||||||
export One984HOSTING_COOKIE
|
export One984HOSTING_COOKIE
|
||||||
_saveaccountconf_mutable One984HOSTING_COOKIE "$One984HOSTING_COOKIE"
|
_saveaccountconf_mutable One984HOSTING_COOKIE "$One984HOSTING_COOKIE"
|
||||||
@ -196,7 +196,7 @@ _check_cookie() {
|
|||||||
|
|
||||||
_authget "https://management.1984hosting.com/accounts/loginstatus/"
|
_authget "https://management.1984hosting.com/accounts/loginstatus/"
|
||||||
response="$(echo "$_response" | _normalizeJson)"
|
response="$(echo "$_response" | _normalizeJson)"
|
||||||
if [ "$_response" = '{"ok": true}' ]; then
|
if _contains "$response" '"ok": true'; then
|
||||||
_debug "Cached cookie still valid"
|
_debug "Cached cookie still valid"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
ARVAN_API_URL="https://napi.arvancloud.com/cdn/4.0/domains"
|
ARVAN_API_URL="https://napi.arvancloud.com/cdn/4.0/domains"
|
||||||
|
|
||||||
#Author: Ehsan Aliakbar
|
#Author: Ehsan Aliakbar
|
||||||
#Report Bugs here: https://github.com/Neilpang/acme.sh
|
#Report Bugs here: https://github.com/Neilpang/acme.sh
|
||||||
#
|
#
|
||||||
######## Public functions #####################
|
######## Public functions #####################
|
||||||
|
|
||||||
|
|||||||
@ -222,21 +222,21 @@ _use_instance_role() {
|
|||||||
|
|
||||||
_use_metadata() {
|
_use_metadata() {
|
||||||
_aws_creds="$(
|
_aws_creds="$(
|
||||||
_get "$1" "" 1 \
|
_get "$1" "" 1 |
|
||||||
| _normalizeJson \
|
_normalizeJson |
|
||||||
| tr '{,}' '\n' \
|
tr '{,}' '\n' |
|
||||||
| while read -r _line; do
|
while read -r _line; do
|
||||||
_key="$(echo "${_line%%:*}" | tr -d '"')"
|
_key="$(echo "${_line%%:*}" | tr -d '"')"
|
||||||
_value="${_line#*:}"
|
_value="${_line#*:}"
|
||||||
_debug3 "_key" "$_key"
|
_debug3 "_key" "$_key"
|
||||||
_secure_debug3 "_value" "$_value"
|
_secure_debug3 "_value" "$_value"
|
||||||
case "$_key" in
|
case "$_key" in
|
||||||
AccessKeyId) echo "AWS_ACCESS_KEY_ID=$_value" ;;
|
AccessKeyId) echo "AWS_ACCESS_KEY_ID=$_value" ;;
|
||||||
SecretAccessKey) echo "AWS_SECRET_ACCESS_KEY=$_value" ;;
|
SecretAccessKey) echo "AWS_SECRET_ACCESS_KEY=$_value" ;;
|
||||||
Token) echo "AWS_SESSION_TOKEN=$_value" ;;
|
Token) echo "AWS_SESSION_TOKEN=$_value" ;;
|
||||||
esac
|
esac
|
||||||
done \
|
done |
|
||||||
| paste -sd' ' -
|
paste -sd' ' -
|
||||||
)"
|
)"
|
||||||
_secure_debug "_aws_creds" "$_aws_creds"
|
_secure_debug "_aws_creds" "$_aws_creds"
|
||||||
|
|
||||||
|
|||||||
@ -172,7 +172,7 @@ dns_azure_rm() {
|
|||||||
_azure_rest GET "$acmeRecordURI" "" "$accesstoken"
|
_azure_rest GET "$acmeRecordURI" "" "$accesstoken"
|
||||||
timestamp="$(_time)"
|
timestamp="$(_time)"
|
||||||
if [ "$_code" = "200" ]; then
|
if [ "$_code" = "200" ]; then
|
||||||
vlist="$(echo "$response" | _egrep_o "\"value\"\\s*:\\s*\\[\\s*\"[^\"]*\"\\s*]" | cut -d : -f 2 | tr -d "[]\"" | grep -v "$txtvalue")"
|
vlist="$(echo "$response" | _egrep_o "\"value\"\\s*:\\s*\\[\\s*\"[^\"]*\"\\s*]" | cut -d : -f 2 | tr -d "[]\"" | grep -v -- "$txtvalue")"
|
||||||
values=""
|
values=""
|
||||||
comma=""
|
comma=""
|
||||||
for v in $vlist; do
|
for v in $vlist; do
|
||||||
@ -220,7 +220,7 @@ _azure_rest() {
|
|||||||
export _H2="accept: application/json"
|
export _H2="accept: application/json"
|
||||||
export _H3="Content-Type: application/json"
|
export _H3="Content-Type: application/json"
|
||||||
# clear headers from previous request to avoid getting wrong http code on timeouts
|
# clear headers from previous request to avoid getting wrong http code on timeouts
|
||||||
:>"$HTTP_HEADER"
|
: >"$HTTP_HEADER"
|
||||||
_debug "$ep"
|
_debug "$ep"
|
||||||
if [ "$m" != "GET" ]; then
|
if [ "$m" != "GET" ]; then
|
||||||
_secure_debug2 "data $data"
|
_secure_debug2 "data $data"
|
||||||
|
|||||||
@ -115,9 +115,9 @@ dns_conoha_rm() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
record_id=$(printf "%s" "$response" | _egrep_o '{[^}]*}' \
|
record_id=$(printf "%s" "$response" | _egrep_o '{[^}]*}' |
|
||||||
| grep '"type":"TXT"' | grep "\"data\":\"$txtvalue\"" | _egrep_o "\"id\":\"[^\"]*\"" \
|
grep '"type":"TXT"' | grep "\"data\":\"$txtvalue\"" | _egrep_o "\"id\":\"[^\"]*\"" |
|
||||||
| _head_n 1 | cut -d : -f 2 | tr -d \")
|
_head_n 1 | cut -d : -f 2 | tr -d \")
|
||||||
if [ -z "$record_id" ]; then
|
if [ -z "$record_id" ]; then
|
||||||
_err "Can not get record id to remove."
|
_err "Can not get record id to remove."
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@ -18,23 +18,23 @@
|
|||||||
########
|
########
|
||||||
|
|
||||||
dns_cyon_add() {
|
dns_cyon_add() {
|
||||||
_cyon_load_credentials \
|
_cyon_load_credentials &&
|
||||||
&& _cyon_load_parameters "$@" \
|
_cyon_load_parameters "$@" &&
|
||||||
&& _cyon_print_header "add" \
|
_cyon_print_header "add" &&
|
||||||
&& _cyon_login \
|
_cyon_login &&
|
||||||
&& _cyon_change_domain_env \
|
_cyon_change_domain_env &&
|
||||||
&& _cyon_add_txt \
|
_cyon_add_txt &&
|
||||||
&& _cyon_logout
|
_cyon_logout
|
||||||
}
|
}
|
||||||
|
|
||||||
dns_cyon_rm() {
|
dns_cyon_rm() {
|
||||||
_cyon_load_credentials \
|
_cyon_load_credentials &&
|
||||||
&& _cyon_load_parameters "$@" \
|
_cyon_load_parameters "$@" &&
|
||||||
&& _cyon_print_header "delete" \
|
_cyon_print_header "delete" &&
|
||||||
&& _cyon_login \
|
_cyon_login &&
|
||||||
&& _cyon_change_domain_env \
|
_cyon_change_domain_env &&
|
||||||
&& _cyon_delete_txt \
|
_cyon_delete_txt &&
|
||||||
&& _cyon_logout
|
_cyon_logout
|
||||||
}
|
}
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
|
|||||||
@ -115,23 +115,23 @@ _da_api() {
|
|||||||
_debug response "$response"
|
_debug response "$response"
|
||||||
|
|
||||||
case "${cmd}" in
|
case "${cmd}" in
|
||||||
CMD_API_DNS_CONTROL)
|
CMD_API_DNS_CONTROL)
|
||||||
# Parse the result in general
|
# Parse the result in general
|
||||||
# error=0&text=Records Deleted&details=
|
# error=0&text=Records Deleted&details=
|
||||||
# error=1&text=Cannot View Dns Record&details=No domain provided
|
# error=1&text=Cannot View Dns Record&details=No domain provided
|
||||||
err_field="$(_getfield "$response" 1 '&')"
|
err_field="$(_getfield "$response" 1 '&')"
|
||||||
txt_field="$(_getfield "$response" 2 '&')"
|
txt_field="$(_getfield "$response" 2 '&')"
|
||||||
details_field="$(_getfield "$response" 3 '&')"
|
details_field="$(_getfield "$response" 3 '&')"
|
||||||
error="$(_getfield "$err_field" 2 '=')"
|
error="$(_getfield "$err_field" 2 '=')"
|
||||||
text="$(_getfield "$txt_field" 2 '=')"
|
text="$(_getfield "$txt_field" 2 '=')"
|
||||||
details="$(_getfield "$details_field" 2 '=')"
|
details="$(_getfield "$details_field" 2 '=')"
|
||||||
_debug "error: ${error}, text: ${text}, details: ${details}"
|
_debug "error: ${error}, text: ${text}, details: ${details}"
|
||||||
if [ "$error" != "0" ]; then
|
if [ "$error" != "0" ]; then
|
||||||
_err "error $response"
|
_err "error $response"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
CMD_API_SHOW_DOMAINS) ;;
|
CMD_API_SHOW_DOMAINS) ;;
|
||||||
esac
|
esac
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,14 +67,14 @@ _dns_do_list_rrs() {
|
|||||||
_err "getRRList origin ${_domain} failed"
|
_err "getRRList origin ${_domain} failed"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
_rr_list="$(echo "${response}" \
|
_rr_list="$(echo "${response}" |
|
||||||
| tr -d "\n\r\t" \
|
tr -d "\n\r\t" |
|
||||||
| sed -e 's/<item xsi:type="ns2:Map">/\n/g' \
|
sed -e 's/<item xsi:type="ns2:Map">/\n/g' |
|
||||||
| grep ">$(_regexcape "$fulldomain")</value>" \
|
grep ">$(_regexcape "$fulldomain")</value>" |
|
||||||
| sed -e 's/<\/item>/\n/g' \
|
sed -e 's/<\/item>/\n/g' |
|
||||||
| grep '>id</key><value' \
|
grep '>id</key><value' |
|
||||||
| _egrep_o '>[0-9]{1,16}<' \
|
_egrep_o '>[0-9]{1,16}<' |
|
||||||
| tr -d '><')"
|
tr -d '><')"
|
||||||
[ "${_rr_list}" ]
|
[ "${_rr_list}" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,10 +120,10 @@ _get_root() {
|
|||||||
i=1
|
i=1
|
||||||
|
|
||||||
_dns_do_soap getDomainList
|
_dns_do_soap getDomainList
|
||||||
_all_domains="$(echo "${response}" \
|
_all_domains="$(echo "${response}" |
|
||||||
| tr -d "\n\r\t " \
|
tr -d "\n\r\t " |
|
||||||
| _egrep_o 'domain</key><value[^>]+>[^<]+' \
|
_egrep_o 'domain</key><value[^>]+>[^<]+' |
|
||||||
| sed -e 's/^domain<\/key><value[^>]*>//g')"
|
sed -e 's/^domain<\/key><value[^>]*>//g')"
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
h=$(printf "%s" "$domain" | cut -d . -f $i-100)
|
h=$(printf "%s" "$domain" | cut -d . -f $i-100)
|
||||||
|
|||||||
@ -80,7 +80,7 @@ _generate_new_key() {
|
|||||||
_get_domain() {
|
_get_domain() {
|
||||||
_full_domain="$1"
|
_full_domain="$1"
|
||||||
_debug "getting domain for $_full_domain"
|
_debug "getting domain for $_full_domain"
|
||||||
if ! _contains "$_full_domain" 'dynv6.net' && ! _contains "$_full_domain" 'dns.army' && ! _contains "$_full_domain" 'dns.navy'; then
|
if ! _contains "$_full_domain" 'dynv6.net' && ! _contains "$_full_domain" 'dns.army' && ! _contains "$_full_domain" 'dns.navy' && ! _contains "$_full_domain" 'v6.rocks'; then
|
||||||
_err "The hosts does not seem to be a dynv6 host"
|
_err "The hosts does not seem to be a dynv6 host"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
#######################################################
|
#######################################################
|
||||||
#
|
#
|
||||||
# easyDNS REST API for acme.sh by Neilpang based on dns_cf.sh
|
# easyDNS REST API for acme.sh by Neilpang based on dns_cf.sh
|
||||||
#
|
#
|
||||||
# API Documentation: https://sandbox.rest.easydns.net:3001/
|
# API Documentation: https://sandbox.rest.easydns.net:3001/
|
||||||
#
|
#
|
||||||
# Author: wurzelpanzer [wurzelpanzer@maximolider.net]
|
# Author: wurzelpanzer [wurzelpanzer@maximolider.net]
|
||||||
|
|||||||
@ -303,10 +303,10 @@ _freedns_domain_id() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
domain_id="$(echo "$htmlpage" | tr -d " \t\r\n\v\f" | sed 's/<tr>/@<tr>/g' | tr '@' '\n' \
|
domain_id="$(echo "$htmlpage" | tr -d " \t\r\n\v\f" | sed 's/<tr>/@<tr>/g' | tr '@' '\n' |
|
||||||
| grep "<td>$search_domain</td>\|<td>$search_domain(.*)</td>" \
|
grep "<td>$search_domain</td>\|<td>$search_domain(.*)</td>" |
|
||||||
| sed -n 's/.*\(edit\.php?edit_domain_id=[0-9a-zA-Z]*\).*/\1/p' \
|
sed -n 's/.*\(edit\.php?edit_domain_id=[0-9a-zA-Z]*\).*/\1/p' |
|
||||||
| cut -d = -f 2)"
|
cut -d = -f 2)"
|
||||||
# The above beauty extracts domain ID from the html page...
|
# The above beauty extracts domain ID from the html page...
|
||||||
# strip out all blank space and new lines. Then insert newlines
|
# strip out all blank space and new lines. Then insert newlines
|
||||||
# before each table row <tr>
|
# before each table row <tr>
|
||||||
@ -349,11 +349,11 @@ _freedns_data_id() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
data_id="$(echo "$htmlpage" | tr -d " \t\r\n\v\f" | sed 's/<tr>/@<tr>/g' | tr '@' '\n' \
|
data_id="$(echo "$htmlpage" | tr -d " \t\r\n\v\f" | sed 's/<tr>/@<tr>/g' | tr '@' '\n' |
|
||||||
| grep "<td[a-zA-Z=#]*>$record_type</td>" \
|
grep "<td[a-zA-Z=#]*>$record_type</td>" |
|
||||||
| grep "<ahref.*>$search_domain</a>" \
|
grep "<ahref.*>$search_domain</a>" |
|
||||||
| sed -n 's/.*\(edit\.php?data_id=[0-9a-zA-Z]*\).*/\1/p' \
|
sed -n 's/.*\(edit\.php?data_id=[0-9a-zA-Z]*\).*/\1/p' |
|
||||||
| cut -d = -f 2)"
|
cut -d = -f 2)"
|
||||||
# The above beauty extracts data ID from the html page...
|
# The above beauty extracts data ID from the html page...
|
||||||
# strip out all blank space and new lines. Then insert newlines
|
# strip out all blank space and new lines. Then insert newlines
|
||||||
# before each table row <tr>
|
# before each table row <tr>
|
||||||
|
|||||||
@ -69,9 +69,9 @@ dns_gandi_livedns_rm() {
|
|||||||
|
|
||||||
_gandi_livedns_rest PUT \
|
_gandi_livedns_rest PUT \
|
||||||
"domains/$_domain/records/$_sub_domain/TXT" \
|
"domains/$_domain/records/$_sub_domain/TXT" \
|
||||||
"{\"rrset_ttl\": 300, \"rrset_values\": $_new_rrset_values}" \
|
"{\"rrset_ttl\": 300, \"rrset_values\": $_new_rrset_values}" &&
|
||||||
&& _contains "$response" '{"message": "DNS Record Created"}' \
|
_contains "$response" '{"message": "DNS Record Created"}' &&
|
||||||
&& _info "Removing record $(__green "success")"
|
_info "Removing record $(__green "success")"
|
||||||
}
|
}
|
||||||
|
|
||||||
#################### Private functions below ##################################
|
#################### Private functions below ##################################
|
||||||
@ -125,9 +125,9 @@ _dns_gandi_append_record() {
|
|||||||
fi
|
fi
|
||||||
_debug new_rrset_values "$_rrset_values"
|
_debug new_rrset_values "$_rrset_values"
|
||||||
_gandi_livedns_rest PUT "domains/$_domain/records/$sub_domain/TXT" \
|
_gandi_livedns_rest PUT "domains/$_domain/records/$sub_domain/TXT" \
|
||||||
"{\"rrset_ttl\": 300, \"rrset_values\": $_rrset_values}" \
|
"{\"rrset_ttl\": 300, \"rrset_values\": $_rrset_values}" &&
|
||||||
&& _contains "$response" '{"message": "DNS Record Created"}' \
|
_contains "$response" '{"message": "DNS Record Created"}' &&
|
||||||
&& _info "Adding record $(__green "success")"
|
_info "Adding record $(__green "success")"
|
||||||
}
|
}
|
||||||
|
|
||||||
_dns_gandi_existing_rrset_values() {
|
_dns_gandi_existing_rrset_values() {
|
||||||
@ -145,8 +145,8 @@ _dns_gandi_existing_rrset_values() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
_debug "Already has TXT record."
|
_debug "Already has TXT record."
|
||||||
_rrset_values=$(echo "$response" | _egrep_o 'rrset_values.*\[.*\]' \
|
_rrset_values=$(echo "$response" | _egrep_o 'rrset_values.*\[.*\]' |
|
||||||
| _egrep_o '\[".*\"]')
|
_egrep_o '\[".*\"]')
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -78,8 +78,8 @@ _dns_gcloud_execute_tr() {
|
|||||||
for i in $(seq 1 120); do
|
for i in $(seq 1 120); do
|
||||||
if gcloud dns record-sets changes list \
|
if gcloud dns record-sets changes list \
|
||||||
--zone="$managedZone" \
|
--zone="$managedZone" \
|
||||||
--filter='status != done' \
|
--filter='status != done' |
|
||||||
| grep -q '^.*'; then
|
grep -q '^.*'; then
|
||||||
_info "_dns_gcloud_execute_tr: waiting for transaction to be comitted ($i/120)..."
|
_info "_dns_gcloud_execute_tr: waiting for transaction to be comitted ($i/120)..."
|
||||||
sleep 5
|
sleep 5
|
||||||
else
|
else
|
||||||
@ -137,11 +137,11 @@ _dns_gcloud_find_zone() {
|
|||||||
# List domains and find the zone with the deepest sub-domain (in case of some levels of delegation)
|
# List domains and find the zone with the deepest sub-domain (in case of some levels of delegation)
|
||||||
if ! match=$(gcloud dns managed-zones list \
|
if ! match=$(gcloud dns managed-zones list \
|
||||||
--format="value(name, dnsName)" \
|
--format="value(name, dnsName)" \
|
||||||
--filter="$filter" \
|
--filter="$filter" |
|
||||||
| while read -r dnsName name; do
|
while read -r dnsName name; do
|
||||||
printf "%s\t%s\t%s\n" "$(echo "$name" | awk -F"." '{print NF-1}')" "$dnsName" "$name"
|
printf "%s\t%s\t%s\n" "$(echo "$name" | awk -F"." '{print NF-1}')" "$dnsName" "$name"
|
||||||
done \
|
done |
|
||||||
| sort -n -r | _head_n 1 | cut -f2,3 | grep '^.*'); then
|
sort -n -r | _head_n 1 | cut -f2,3 | grep '^.*'); then
|
||||||
_err "_dns_gcloud_find_zone: Can't find a matching managed zone! Perhaps wrong project or gcloud credentials?"
|
_err "_dns_gcloud_find_zone: Can't find a matching managed zone! Perhaps wrong project or gcloud credentials?"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -101,8 +101,8 @@ dns_he_rm() {
|
|||||||
body="$body&hosted_dns_editzone=1"
|
body="$body&hosted_dns_editzone=1"
|
||||||
body="$body&hosted_dns_delrecord=1"
|
body="$body&hosted_dns_delrecord=1"
|
||||||
body="$body&hosted_dns_delconfirm=delete"
|
body="$body&hosted_dns_delconfirm=delete"
|
||||||
_post "$body" "https://dns.he.net/" \
|
_post "$body" "https://dns.he.net/" |
|
||||||
| grep '<div id="dns_status" onClick="hideThis(this);">Successfully removed record.</div>' \
|
grep '<div id="dns_status" onClick="hideThis(this);">Successfully removed record.</div>' \
|
||||||
>/dev/null
|
>/dev/null
|
||||||
exit_code="$?"
|
exit_code="$?"
|
||||||
if [ "$exit_code" -eq 0 ]; then
|
if [ "$exit_code" -eq 0 ]; then
|
||||||
|
|||||||
@ -123,10 +123,10 @@ _find_record() {
|
|||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
_record_id=$(
|
_record_id=$(
|
||||||
echo "$response" \
|
echo "$response" |
|
||||||
| grep -o "{[^\{\}]*\"name\":\"$_record_name\"[^\}]*}" \
|
grep -o "{[^\{\}]*\"name\":\"$_record_name\"[^\}]*}" |
|
||||||
| grep "\"value\":\"$_record_value\"" \
|
grep "\"value\":\"$_record_value\"" |
|
||||||
| while read -r record; do
|
while read -r record; do
|
||||||
# test for type and
|
# test for type and
|
||||||
if [ -n "$(echo "$record" | _egrep_o '"type":"TXT"')" ]; then
|
if [ -n "$(echo "$record" | _egrep_o '"type":"TXT"')" ]; then
|
||||||
echo "$record" | _egrep_o '"id":"[^"]*"' | cut -d : -f 2 | tr -d \"
|
echo "$record" | _egrep_o '"id":"[^"]*"' | cut -d : -f 2 | tr -d \"
|
||||||
|
|||||||
@ -95,29 +95,29 @@ _ISPC_getZoneInfo() {
|
|||||||
server_id=$(echo "${curResult}" | _egrep_o "server_id.*" | cut -d ':' -f 2 | cut -d '"' -f 2)
|
server_id=$(echo "${curResult}" | _egrep_o "server_id.*" | cut -d ':' -f 2 | cut -d '"' -f 2)
|
||||||
_debug "Server ID: '${server_id}'"
|
_debug "Server ID: '${server_id}'"
|
||||||
case "${server_id}" in
|
case "${server_id}" in
|
||||||
'' | *[!0-9]*)
|
'' | *[!0-9]*)
|
||||||
_err "Server ID is not numeric."
|
_err "Server ID is not numeric."
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
*) _info "Retrieved Server ID" ;;
|
*) _info "Retrieved Server ID" ;;
|
||||||
esac
|
esac
|
||||||
zone=$(echo "${curResult}" | _egrep_o "\"id.*" | cut -d ':' -f 2 | cut -d '"' -f 2)
|
zone=$(echo "${curResult}" | _egrep_o "\"id.*" | cut -d ':' -f 2 | cut -d '"' -f 2)
|
||||||
_debug "Zone: '${zone}'"
|
_debug "Zone: '${zone}'"
|
||||||
case "${zone}" in
|
case "${zone}" in
|
||||||
'' | *[!0-9]*)
|
'' | *[!0-9]*)
|
||||||
_err "Zone ID is not numeric."
|
_err "Zone ID is not numeric."
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
*) _info "Retrieved Zone ID" ;;
|
*) _info "Retrieved Zone ID" ;;
|
||||||
esac
|
esac
|
||||||
client_id=$(echo "${curResult}" | _egrep_o "sys_userid.*" | cut -d ':' -f 2 | cut -d '"' -f 2)
|
client_id=$(echo "${curResult}" | _egrep_o "sys_userid.*" | cut -d ':' -f 2 | cut -d '"' -f 2)
|
||||||
_debug "Client ID: '${client_id}'"
|
_debug "Client ID: '${client_id}'"
|
||||||
case "${client_id}" in
|
case "${client_id}" in
|
||||||
'' | *[!0-9]*)
|
'' | *[!0-9]*)
|
||||||
_err "Client ID is not numeric."
|
_err "Client ID is not numeric."
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
*) _info "Retrieved Client ID." ;;
|
*) _info "Retrieved Client ID." ;;
|
||||||
esac
|
esac
|
||||||
zoneFound=""
|
zoneFound=""
|
||||||
zoneEnd=""
|
zoneEnd=""
|
||||||
@ -135,11 +135,11 @@ _ISPC_addTxt() {
|
|||||||
record_id=$(echo "${curResult}" | _egrep_o "\"response.*" | cut -d ':' -f 2 | cut -d '"' -f 2)
|
record_id=$(echo "${curResult}" | _egrep_o "\"response.*" | cut -d ':' -f 2 | cut -d '"' -f 2)
|
||||||
_debug "Record ID: '${record_id}'"
|
_debug "Record ID: '${record_id}'"
|
||||||
case "${record_id}" in
|
case "${record_id}" in
|
||||||
'' | *[!0-9]*)
|
'' | *[!0-9]*)
|
||||||
_err "Couldn't add ACME Challenge TXT record to zone."
|
_err "Couldn't add ACME Challenge TXT record to zone."
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
*) _info "Added ACME Challenge TXT record to zone." ;;
|
*) _info "Added ACME Challenge TXT record to zone." ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,24 +153,24 @@ _ISPC_rmTxt() {
|
|||||||
record_id=$(echo "${curResult}" | _egrep_o "\"id.*" | cut -d ':' -f 2 | cut -d '"' -f 2)
|
record_id=$(echo "${curResult}" | _egrep_o "\"id.*" | cut -d ':' -f 2 | cut -d '"' -f 2)
|
||||||
_debug "Record ID: '${record_id}'"
|
_debug "Record ID: '${record_id}'"
|
||||||
case "${record_id}" in
|
case "${record_id}" in
|
||||||
'' | *[!0-9]*)
|
'' | *[!0-9]*)
|
||||||
_err "Record ID is not numeric."
|
_err "Record ID is not numeric."
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
unset IFS
|
||||||
|
_info "Retrieved Record ID."
|
||||||
|
curData="{\"session_id\":\"${sessionID}\",\"primary_id\":\"${record_id}\",\"update_serial\":true}"
|
||||||
|
curResult="$(_post "${curData}" "${ISPC_Api}?dns_txt_delete")"
|
||||||
|
_debug "Calling _ISPC_rmTxt: '${curData}' '${ISPC_Api}?dns_txt_delete'"
|
||||||
|
_debug "Result of _ISPC_rmTxt: '$curResult'"
|
||||||
|
if _contains "${curResult}" '"code":"ok"'; then
|
||||||
|
_info "Removed ACME Challenge TXT record from zone."
|
||||||
|
else
|
||||||
|
_err "Couldn't remove ACME Challenge TXT record from zone."
|
||||||
return 1
|
return 1
|
||||||
;;
|
fi
|
||||||
*)
|
;;
|
||||||
unset IFS
|
|
||||||
_info "Retrieved Record ID."
|
|
||||||
curData="{\"session_id\":\"${sessionID}\",\"primary_id\":\"${record_id}\",\"update_serial\":true}"
|
|
||||||
curResult="$(_post "${curData}" "${ISPC_Api}?dns_txt_delete")"
|
|
||||||
_debug "Calling _ISPC_rmTxt: '${curData}' '${ISPC_Api}?dns_txt_delete'"
|
|
||||||
_debug "Result of _ISPC_rmTxt: '$curResult'"
|
|
||||||
if _contains "${curResult}" '"code":"ok"'; then
|
|
||||||
_info "Removed ACME Challenge TXT record from zone."
|
|
||||||
else
|
|
||||||
_err "Couldn't remove ACME Challenge TXT record from zone."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
@ -100,7 +100,7 @@ _get_root() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Try to remove a test record. With correct root domain, username and password this will return "OK: ..." regardless
|
# Try to remove a test record. With correct root domain, username and password this will return "OK: ..." regardless
|
||||||
# of record in question existing or not.
|
# of record in question existing or not.
|
||||||
if _joker_rest "username=$JOKER_USERNAME&password=$JOKER_PASSWORD&zone=$h&label=jokerTXTUpdateTest&type=TXT&value="; then
|
if _joker_rest "username=$JOKER_USERNAME&password=$JOKER_PASSWORD&zone=$h&label=jokerTXTUpdateTest&type=TXT&value="; then
|
||||||
if _startswith "$response" "OK"; then
|
if _startswith "$response" "OK"; then
|
||||||
_sub_domain="$(echo "$fulldomain" | sed "s/\\.$h\$//")"
|
_sub_domain="$(echo "$fulldomain" | sed "s/\\.$h\$//")"
|
||||||
|
|||||||
150
dnsapi/dns_kappernet.sh
Normal file
150
dnsapi/dns_kappernet.sh
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
# kapper.net domain api
|
||||||
|
# for further questions please contact: support@kapper.net
|
||||||
|
# please report issues here: https://github.com/acmesh-official/acme.sh/issues/2977
|
||||||
|
|
||||||
|
#KAPPERNETDNS_Key="yourKAPPERNETapikey"
|
||||||
|
#KAPPERNETDNS_Secret="yourKAPPERNETapisecret"
|
||||||
|
|
||||||
|
KAPPERNETDNS_Api="https://dnspanel.kapper.net/API/1.2?APIKey=$KAPPERNETDNS_Key&APISecret=$KAPPERNETDNS_Secret"
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# called with
|
||||||
|
# fullhostname: something.example.com
|
||||||
|
# txtvalue: someacmegenerated string
|
||||||
|
dns_kappernet_add() {
|
||||||
|
fullhostname=$1
|
||||||
|
txtvalue=$2
|
||||||
|
|
||||||
|
KAPPERNETDNS_Key="${KAPPERNETDNS_Key:-$(_readaccountconf_mutable KAPPERNETDNS_Key)}"
|
||||||
|
KAPPERNETDNS_Secret="${KAPPERNETDNS_Secret:-$(_readaccountconf_mutable KAPPERNETDNS_Secret)}"
|
||||||
|
|
||||||
|
if [ -z "$KAPPERNETDNS_Key" ] || [ -z "$KAPPERNETDNS_Secret" ]; then
|
||||||
|
KAPPERNETDNS_Key=""
|
||||||
|
KAPPERNETDNS_Secret=""
|
||||||
|
_err "Please specify your kapper.net api key and secret."
|
||||||
|
_err "If you have not received yours - send your mail to"
|
||||||
|
_err "support@kapper.net to get your key and secret."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#store the api key and email to the account conf file.
|
||||||
|
_saveaccountconf_mutable KAPPERNETDNS_Key "$KAPPERNETDNS_Key"
|
||||||
|
_saveaccountconf_mutable KAPPERNETDNS_Secret "$KAPPERNETDNS_Secret"
|
||||||
|
_debug "Checking Domain ..."
|
||||||
|
if ! _get_root "$fullhostname"; then
|
||||||
|
_err "invalid domain"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
_debug _sub_domain "SUBDOMAIN: $_sub_domain"
|
||||||
|
_debug _domain "DOMAIN: $_domain"
|
||||||
|
|
||||||
|
_info "Trying to add TXT DNS Record"
|
||||||
|
data="%7B%22name%22%3A%22$fullhostname%22%2C%22type%22%3A%22TXT%22%2C%22content%22%3A%22$txtvalue%22%2C%22ttl%22%3A%223600%22%2C%22prio%22%3A%22%22%7D"
|
||||||
|
if _kappernet_api GET "action=new&subject=$_domain&data=$data"; then
|
||||||
|
|
||||||
|
if _contains "$response" "{\"OK\":true"; then
|
||||||
|
_info "Waiting 120 seconds for DNS to spread the new record"
|
||||||
|
_sleep 120
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
_err "Error creating a TXT DNS Record: $fullhostname TXT $txtvalue"
|
||||||
|
_err "Error Message: $response"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
_err "Failed creating TXT Record"
|
||||||
|
}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# called with
|
||||||
|
# fullhostname: something.example.com
|
||||||
|
dns_kappernet_rm() {
|
||||||
|
fullhostname=$1
|
||||||
|
txtvalue=$2
|
||||||
|
|
||||||
|
KAPPERNETDNS_Key="${KAPPERNETDNS_Key:-$(_readaccountconf_mutable KAPPERNETDNS_Key)}"
|
||||||
|
KAPPERNETDNS_Secret="${KAPPERNETDNS_Secret:-$(_readaccountconf_mutable KAPPERNETDNS_Secret)}"
|
||||||
|
|
||||||
|
if [ -z "$KAPPERNETDNS_Key" ] || [ -z "$KAPPERNETDNS_Secret" ]; then
|
||||||
|
KAPPERNETDNS_Key=""
|
||||||
|
KAPPERNETDNS_Secret=""
|
||||||
|
_err "Please specify your kapper.net api key and secret."
|
||||||
|
_err "If you have not received yours - send your mail to"
|
||||||
|
_err "support@kapper.net to get your key and secret."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#store the api key and email to the account conf file.
|
||||||
|
_saveaccountconf_mutable KAPPERNETDNS_Key "$KAPPERNETDNS_Key"
|
||||||
|
_saveaccountconf_mutable KAPPERNETDNS_Secret "$KAPPERNETDNS_Secret"
|
||||||
|
|
||||||
|
_info "Trying to remove the TXT Record: $fullhostname containing $txtvalue"
|
||||||
|
data="%7B%22name%22%3A%22$fullhostname%22%2C%22type%22%3A%22TXT%22%2C%22content%22%3A%22$txtvalue%22%2C%22ttl%22%3A%223600%22%2C%22prio%22%3A%22%22%7D"
|
||||||
|
if _kappernet_api GET "action=del&subject=$fullhostname&data=$data"; then
|
||||||
|
if _contains "$response" "{\"OK\":true"; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
_err "Error deleting DNS Record: $fullhostname containing $txtvalue"
|
||||||
|
_err "Problem: $response"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
_err "Problem deleting TXT DNS record"
|
||||||
|
}
|
||||||
|
|
||||||
|
#################### Private functions below ##################################
|
||||||
|
# called with hostname
|
||||||
|
# e.g._acme-challenge.www.domain.com returns
|
||||||
|
# _sub_domain=_acme-challenge.www
|
||||||
|
# _domain=domain.com
|
||||||
|
_get_root() {
|
||||||
|
domain=$1
|
||||||
|
i=2
|
||||||
|
p=1
|
||||||
|
while true; do
|
||||||
|
h=$(printf "%s" "$domain" | cut -d . -f $i-100)
|
||||||
|
if [ -z "$h" ]; then
|
||||||
|
#not valid
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if ! _kappernet_api GET "action=list&subject=$h"; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if _contains "$response" '"OK":false'; then
|
||||||
|
_debug "$h not found"
|
||||||
|
else
|
||||||
|
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
|
||||||
|
_domain="$h"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
p="$i"
|
||||||
|
i=$(_math "$i" + 1)
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# calls the kapper.net DNS Panel API
|
||||||
|
# with
|
||||||
|
# method
|
||||||
|
# param
|
||||||
|
_kappernet_api() {
|
||||||
|
method=$1
|
||||||
|
param="$2"
|
||||||
|
|
||||||
|
_debug param "PARAMETER=$param"
|
||||||
|
url="$KAPPERNETDNS_Api&$param"
|
||||||
|
_debug url "URL=$url"
|
||||||
|
|
||||||
|
if [ "$method" = "GET" ]; then
|
||||||
|
response="$(_get "$url")"
|
||||||
|
else
|
||||||
|
_err "Unsupported method"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
_debug2 response "$response"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
162
dnsapi/dns_netlify.sh
Normal file
162
dnsapi/dns_netlify.sh
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
#NETLIFY_ACCESS_TOKEN="xxxx"
|
||||||
|
|
||||||
|
NETLIFY_HOST="api.netlify.com/api/v1/"
|
||||||
|
NETLIFY_URL="https://$NETLIFY_HOST"
|
||||||
|
|
||||||
|
######## Public functions #####################
|
||||||
|
|
||||||
|
#Usage: dns_myapi_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
|
||||||
|
dns_netlify_add() {
|
||||||
|
fulldomain=$1
|
||||||
|
txtvalue=$2
|
||||||
|
|
||||||
|
NETLIFY_ACCESS_TOKEN="${NETLIFY_ACCESS_TOKEN:-$(_readaccountconf_mutable NETLIFY_ACCESS_TOKEN)}"
|
||||||
|
|
||||||
|
if [ -z "$NETLIFY_ACCESS_TOKEN" ]; then
|
||||||
|
NETLIFY_ACCESS_TOKEN=""
|
||||||
|
_err "Please specify your Netlify Access Token and try again."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
_info "Using Netlify"
|
||||||
|
_debug fulldomain "$fulldomain"
|
||||||
|
_debug txtvalue "$txtvalue"
|
||||||
|
|
||||||
|
_saveaccountconf_mutable NETLIFY_ACCESS_TOKEN "$NETLIFY_ACCESS_TOKEN"
|
||||||
|
|
||||||
|
if ! _get_root "$fulldomain" "$accesstoken"; then
|
||||||
|
_err "invalid domain"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
_debug _domain_id "$_domain_id"
|
||||||
|
_debug _sub_domain "$_sub_domain"
|
||||||
|
_debug _domain "$_domain"
|
||||||
|
|
||||||
|
dnsRecordURI="dns_zones/$_domain_id/dns_records"
|
||||||
|
|
||||||
|
body="{\"type\":\"TXT\", \"hostname\":\"$_sub_domain\", \"value\":\"$txtvalue\", \"ttl\":\"10\"}"
|
||||||
|
|
||||||
|
_netlify_rest POST "$dnsRecordURI" "$body" "$NETLIFY_ACCESS_TOKEN"
|
||||||
|
_code="$(grep "^HTTP" "$HTTP_HEADER" | _tail_n 1 | cut -d " " -f 2 | tr -d "\\r\\n")"
|
||||||
|
if [ "$_code" = "200" ] || [ "$_code" = '201' ]; then
|
||||||
|
_info "validation value added"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
_err "error adding validation value ($_code)"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
_err "Not fully implemented!"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
#Usage: dns_myapi_rm _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
|
||||||
|
#Remove the txt record after validation.
|
||||||
|
dns_netlify_rm() {
|
||||||
|
_info "Using Netlify"
|
||||||
|
txtdomain="$1"
|
||||||
|
txt="$2"
|
||||||
|
_debug txtdomain "$txtdomain"
|
||||||
|
_debug txt "$txt"
|
||||||
|
|
||||||
|
_saveaccountconf_mutable NETLIFY_ACCESS_TOKEN "$NETLIFY_ACCESS_TOKEN"
|
||||||
|
|
||||||
|
if ! _get_root "$txtdomain" "$accesstoken"; then
|
||||||
|
_err "invalid domain"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
_debug _domain_id "$_domain_id"
|
||||||
|
_debug _sub_domain "$_sub_domain"
|
||||||
|
_debug _domain "$_domain"
|
||||||
|
|
||||||
|
dnsRecordURI="dns_zones/$_domain_id/dns_records"
|
||||||
|
|
||||||
|
_netlify_rest GET "$dnsRecordURI" "" "$NETLIFY_ACCESS_TOKEN"
|
||||||
|
|
||||||
|
_record_id=$(echo "$response" | _egrep_o "\"type\":\"TXT\",[^\}]*\"value\":\"$txt\"" | head -n 1 | _egrep_o "\"id\":\"[^\"\}]*\"" | cut -d : -f 2 | tr -d \")
|
||||||
|
_debug _record_id "$_record_id"
|
||||||
|
if [ "$_record_id" ]; then
|
||||||
|
_netlify_rest DELETE "$dnsRecordURI/$_record_id" "" "$NETLIFY_ACCESS_TOKEN"
|
||||||
|
_code="$(grep "^HTTP" "$HTTP_HEADER" | _tail_n 1 | cut -d " " -f 2 | tr -d "\\r\\n")"
|
||||||
|
if [ "$_code" = "200" ] || [ "$_code" = '204' ]; then
|
||||||
|
_info "validation value removed"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
_err "error removing validation value ($_code)"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
#################### Private functions below ##################################
|
||||||
|
|
||||||
|
_get_root() {
|
||||||
|
domain=$1
|
||||||
|
accesstoken=$2
|
||||||
|
i=1
|
||||||
|
p=1
|
||||||
|
|
||||||
|
_netlify_rest GET "dns_zones" "" "$accesstoken"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
h=$(printf "%s" "$domain" | cut -d . -f $i-100)
|
||||||
|
_debug2 "Checking domain: $h"
|
||||||
|
if [ -z "$h" ]; then
|
||||||
|
#not valid
|
||||||
|
_err "Invalid domain"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if _contains "$response" "\"name\":\"$h\"" >/dev/null; then
|
||||||
|
_domain_id=$(echo "$response" | _egrep_o "\"[^\"]*\",\"name\":\"$h" | cut -d , -f 1 | tr -d \")
|
||||||
|
if [ "$_domain_id" ]; then
|
||||||
|
if [ "$i" = 1 ]; then
|
||||||
|
#create the record at the domain apex (@) if only the domain name was provided as --domain-alias
|
||||||
|
_sub_domain="@"
|
||||||
|
else
|
||||||
|
_sub_domain=$(echo "$domain" | cut -d . -f 1-$p)
|
||||||
|
fi
|
||||||
|
_domain=$h
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
p=$i
|
||||||
|
i=$(_math "$i" + 1)
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
_netlify_rest() {
|
||||||
|
m=$1
|
||||||
|
ep="$2"
|
||||||
|
data="$3"
|
||||||
|
_debug "$ep"
|
||||||
|
|
||||||
|
token_trimmed=$(echo "$NETLIFY_ACCESS_TOKEN" | tr -d '"')
|
||||||
|
|
||||||
|
export _H1="Content-Type: application/json"
|
||||||
|
export _H2="Authorization: Bearer $token_trimmed"
|
||||||
|
|
||||||
|
: >"$HTTP_HEADER"
|
||||||
|
|
||||||
|
if [ "$m" != "GET" ]; then
|
||||||
|
_debug data "$data"
|
||||||
|
response="$(_post "$data" "$NETLIFY_URL$ep" "" "$m")"
|
||||||
|
else
|
||||||
|
response="$(_get "$NETLIFY_URL$ep")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$?" != "0" ]; then
|
||||||
|
_err "error $ep"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
_debug2 response "$response"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
@ -166,7 +166,7 @@ _get_root() {
|
|||||||
if _contains "$_all_domains" "^$h$"; then
|
if _contains "$_all_domains" "^$h$"; then
|
||||||
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
|
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
|
||||||
_domain=$h
|
_domain=$h
|
||||||
_service=$(printf "%s" "$response" | grep "idn-name=\"$_domain\"" | sed -r "s/.*service=\"(.*)\".*$/\1/")
|
_service=$(printf "%s" "$response" | grep -m 1 "idn-name=\"$_domain\"" | sed -r "s/.*service=\"(.*)\".*$/\1/")
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
p="$i"
|
p="$i"
|
||||||
|
|||||||
@ -6,10 +6,10 @@
|
|||||||
# Created: 2019-02-17
|
# Created: 2019-02-17
|
||||||
# Fixed by: @der-berni
|
# Fixed by: @der-berni
|
||||||
# Modified: 2020-04-07
|
# Modified: 2020-04-07
|
||||||
#
|
#
|
||||||
# Use ONECOM_KeepCnameProxy to keep the CNAME DNS record
|
# Use ONECOM_KeepCnameProxy to keep the CNAME DNS record
|
||||||
# export ONECOM_KeepCnameProxy="1"
|
# export ONECOM_KeepCnameProxy="1"
|
||||||
#
|
#
|
||||||
# export ONECOM_User="username"
|
# export ONECOM_User="username"
|
||||||
# export ONECOM_Password="password"
|
# export ONECOM_Password="password"
|
||||||
#
|
#
|
||||||
|
|||||||
@ -41,40 +41,40 @@ _ovh_get_api() {
|
|||||||
|
|
||||||
case "${_ogaep}" in
|
case "${_ogaep}" in
|
||||||
|
|
||||||
ovh-eu | ovheu)
|
ovh-eu | ovheu)
|
||||||
printf "%s" $OVH_EU
|
printf "%s" $OVH_EU
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
ovh-ca | ovhca)
|
ovh-ca | ovhca)
|
||||||
printf "%s" $OVH_CA
|
printf "%s" $OVH_CA
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
kimsufi-eu | kimsufieu)
|
kimsufi-eu | kimsufieu)
|
||||||
printf "%s" $KSF_EU
|
printf "%s" $KSF_EU
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
kimsufi-ca | kimsufica)
|
kimsufi-ca | kimsufica)
|
||||||
printf "%s" $KSF_CA
|
printf "%s" $KSF_CA
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
soyoustart-eu | soyoustarteu)
|
soyoustart-eu | soyoustarteu)
|
||||||
printf "%s" $SYS_EU
|
printf "%s" $SYS_EU
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
soyoustart-ca | soyoustartca)
|
soyoustart-ca | soyoustartca)
|
||||||
printf "%s" $SYS_CA
|
printf "%s" $SYS_CA
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
runabove-ca | runaboveca)
|
runabove-ca | runaboveca)
|
||||||
printf "%s" $RAV_CA
|
printf "%s" $RAV_CA
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
|
|
||||||
_err "Unknown parameter : $1"
|
_err "Unknown parameter : $1"
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -136,11 +136,12 @@ dns_pleskxml_rm() {
|
|||||||
|
|
||||||
# Reduce output to one line per DNS record, filtered for TXT records with a record ID only (which they should all have)
|
# Reduce output to one line per DNS record, filtered for TXT records with a record ID only (which they should all have)
|
||||||
# Also strip out spaces between tags, redundant <data> and </data> group tags and any <self-closing/> tags
|
# Also strip out spaces between tags, redundant <data> and </data> group tags and any <self-closing/> tags
|
||||||
reclist="$(_api_response_split "$pleskxml_prettyprint_result" 'result' '<status>ok</status>' \
|
reclist="$(
|
||||||
| sed 's# \{1,\}<\([a-zA-Z]\)#<\1#g;s#</\{0,1\}data>##g;s#<[a-z][^/<>]*/>##g' \
|
_api_response_split "$pleskxml_prettyprint_result" 'result' '<status>ok</status>' |
|
||||||
| grep "<site-id>${root_domain_id}</site-id>" \
|
sed 's# \{1,\}<\([a-zA-Z]\)#<\1#g;s#</\{0,1\}data>##g;s#<[a-z][^/<>]*/>##g' |
|
||||||
| grep '<id>[0-9]\{1,\}</id>' \
|
grep "<site-id>${root_domain_id}</site-id>" |
|
||||||
| grep '<type>TXT</type>'
|
grep '<id>[0-9]\{1,\}</id>' |
|
||||||
|
grep '<type>TXT</type>'
|
||||||
)"
|
)"
|
||||||
|
|
||||||
if [ -z "$reclist" ]; then
|
if [ -z "$reclist" ]; then
|
||||||
@ -151,10 +152,11 @@ dns_pleskxml_rm() {
|
|||||||
_debug "Got list of DNS TXT records for root domain '$root_domain_name':"
|
_debug "Got list of DNS TXT records for root domain '$root_domain_name':"
|
||||||
_debug "$reclist"
|
_debug "$reclist"
|
||||||
|
|
||||||
recid="$(_value "$reclist" \
|
recid="$(
|
||||||
| grep "<host>${fulldomain}.</host>" \
|
_value "$reclist" |
|
||||||
| grep "<value>${txtvalue}</value>" \
|
grep "<host>${fulldomain}.</host>" |
|
||||||
| sed 's/^.*<id>\([0-9]\{1,\}\)<\/id>.*$/\1/'
|
grep "<value>${txtvalue}</value>" |
|
||||||
|
sed 's/^.*<id>\([0-9]\{1,\}\)<\/id>.*$/\1/'
|
||||||
)"
|
)"
|
||||||
|
|
||||||
if ! _value "$recid" | grep '^[0-9]\{1,\}$' >/dev/null; then
|
if ! _value "$recid" | grep '^[0-9]\{1,\}$' >/dev/null; then
|
||||||
@ -220,11 +222,11 @@ _countdots() {
|
|||||||
# Last line could change to <sed -n '/.../p'> instead, with suitable escaping of ['"/$],
|
# Last line could change to <sed -n '/.../p'> instead, with suitable escaping of ['"/$],
|
||||||
# if future Plesk XML API changes ever require extended regex
|
# if future Plesk XML API changes ever require extended regex
|
||||||
_api_response_split() {
|
_api_response_split() {
|
||||||
printf '%s' "$1" \
|
printf '%s' "$1" |
|
||||||
| sed 's/^ +//;s/ +$//' \
|
sed 's/^ +//;s/ +$//' |
|
||||||
| tr -d '\n\r' \
|
tr -d '\n\r' |
|
||||||
| sed "s/<\/\{0,1\}$2>/${NEWLINE}/g" \
|
sed "s/<\/\{0,1\}$2>/${NEWLINE}/g" |
|
||||||
| grep "$3"
|
grep "$3"
|
||||||
}
|
}
|
||||||
|
|
||||||
#################### Private functions below (DNS functions) ##################################
|
#################### Private functions below (DNS functions) ##################################
|
||||||
@ -261,14 +263,15 @@ _call_api() {
|
|||||||
elif [ "$statuslines_count_okay" -ne "$statuslines_count_total" ]; then
|
elif [ "$statuslines_count_okay" -ne "$statuslines_count_total" ]; then
|
||||||
|
|
||||||
# We have some status lines that aren't "ok". Any available details are in API response fields "status" "errcode" and "errtext"
|
# We have some status lines that aren't "ok". Any available details are in API response fields "status" "errcode" and "errtext"
|
||||||
# Workaround for basic regex:
|
# Workaround for basic regex:
|
||||||
# - filter output to keep only lines like this: "SPACES<TAG>text</TAG>SPACES" (shouldn't be necessary with prettyprint but guarantees subsequent code is ok)
|
# - filter output to keep only lines like this: "SPACES<TAG>text</TAG>SPACES" (shouldn't be necessary with prettyprint but guarantees subsequent code is ok)
|
||||||
# - then edit the 3 "useful" error tokens individually and remove closing tags on all lines
|
# - then edit the 3 "useful" error tokens individually and remove closing tags on all lines
|
||||||
# - then filter again to remove all lines not edited (which will be the lines not starting A-Z)
|
# - then filter again to remove all lines not edited (which will be the lines not starting A-Z)
|
||||||
errtext="$(_value "$pleskxml_prettyprint_result" \
|
errtext="$(
|
||||||
| grep '^ *<[a-z]\{1,\}>[^<]*<\/[a-z]\{1,\}> *$' \
|
_value "$pleskxml_prettyprint_result" |
|
||||||
| sed 's/^ *<status>/Status: /;s/^ *<errcode>/Error code: /;s/^ *<errtext>/Error text: /;s/<\/.*$//' \
|
grep '^ *<[a-z]\{1,\}>[^<]*<\/[a-z]\{1,\}> *$' |
|
||||||
| grep '^[A-Z]'
|
sed 's/^ *<status>/Status: /;s/^ *<errcode>/Error code: /;s/^ *<errtext>/Error text: /;s/<\/.*$//' |
|
||||||
|
grep '^[A-Z]'
|
||||||
)"
|
)"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -33,8 +33,11 @@ dns_regru_add() {
|
|||||||
fi
|
fi
|
||||||
_debug _domain "$_domain"
|
_debug _domain "$_domain"
|
||||||
|
|
||||||
|
_subdomain=$(echo "$fulldomain" | sed -r "s/.$_domain//")
|
||||||
|
_debug _subdomain "$_subdomain"
|
||||||
|
|
||||||
_info "Adding TXT record to ${fulldomain}"
|
_info "Adding TXT record to ${fulldomain}"
|
||||||
_regru_rest POST "zone/add_txt" "input_data={%22username%22:%22${REGRU_API_Username}%22,%22password%22:%22${REGRU_API_Password}%22,%22domains%22:[{%22dname%22:%22${_domain}%22}],%22subdomain%22:%22_acme-challenge%22,%22text%22:%22${txtvalue}%22,%22output_content_type%22:%22plain%22}&input_format=json"
|
_regru_rest POST "zone/add_txt" "input_data={%22username%22:%22${REGRU_API_Username}%22,%22password%22:%22${REGRU_API_Password}%22,%22domains%22:[{%22dname%22:%22${_domain}%22}],%22subdomain%22:%22${_subdomain}%22,%22text%22:%22${txtvalue}%22,%22output_content_type%22:%22plain%22}&input_format=json"
|
||||||
|
|
||||||
if ! _contains "${response}" 'error'; then
|
if ! _contains "${response}" 'error'; then
|
||||||
return 0
|
return 0
|
||||||
@ -64,8 +67,11 @@ dns_regru_rm() {
|
|||||||
fi
|
fi
|
||||||
_debug _domain "$_domain"
|
_debug _domain "$_domain"
|
||||||
|
|
||||||
|
_subdomain=$(echo "$fulldomain" | sed -r "s/.$_domain//")
|
||||||
|
_debug _subdomain "$_subdomain"
|
||||||
|
|
||||||
_info "Deleting resource record $fulldomain"
|
_info "Deleting resource record $fulldomain"
|
||||||
_regru_rest POST "zone/remove_record" "input_data={%22username%22:%22${REGRU_API_Username}%22,%22password%22:%22${REGRU_API_Password}%22,%22domains%22:[{%22dname%22:%22${_domain}%22}],%22subdomain%22:%22_acme-challenge%22,%22content%22:%22${txtvalue}%22,%22record_type%22:%22TXT%22,%22output_content_type%22:%22plain%22}&input_format=json"
|
_regru_rest POST "zone/remove_record" "input_data={%22username%22:%22${REGRU_API_Username}%22,%22password%22:%22${REGRU_API_Password}%22,%22domains%22:[{%22dname%22:%22${_domain}%22}],%22subdomain%22:%22${_subdomain}%22,%22content%22:%22${txtvalue}%22,%22record_type%22:%22TXT%22,%22output_content_type%22:%22plain%22}&input_format=json"
|
||||||
|
|
||||||
if ! _contains "${response}" 'error'; then
|
if ! _contains "${response}" 'error'; then
|
||||||
return 0
|
return 0
|
||||||
@ -87,11 +93,11 @@ _get_root() {
|
|||||||
|
|
||||||
for ITEM in ${domains_list}; do
|
for ITEM in ${domains_list}; do
|
||||||
case "${domain}" in
|
case "${domain}" in
|
||||||
*${ITEM}*)
|
*${ITEM}*)
|
||||||
_domain=${ITEM}
|
_domain=${ITEM}
|
||||||
_debug _domain "${_domain}"
|
_debug _domain "${_domain}"
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
@ -98,24 +98,24 @@ _mail_cmnd() {
|
|||||||
_MAIL_ARGS=""
|
_MAIL_ARGS=""
|
||||||
|
|
||||||
case $(basename "$_MAIL_BIN") in
|
case $(basename "$_MAIL_BIN") in
|
||||||
sendmail)
|
sendmail)
|
||||||
if [ -n "$MAIL_FROM" ]; then
|
if [ -n "$MAIL_FROM" ]; then
|
||||||
_MAIL_ARGS="-f '$MAIL_FROM'"
|
_MAIL_ARGS="-f '$MAIL_FROM'"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
mutt | mail)
|
mutt | mail)
|
||||||
_MAIL_ARGS="-s '$_subject'"
|
_MAIL_ARGS="-s '$_subject'"
|
||||||
;;
|
;;
|
||||||
msmtp)
|
msmtp)
|
||||||
if [ -n "$MAIL_FROM" ]; then
|
if [ -n "$MAIL_FROM" ]; then
|
||||||
_MAIL_ARGS="-f '$MAIL_FROM'"
|
_MAIL_ARGS="-f '$MAIL_FROM'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$MAIL_MSMTP_ACCOUNT" ]; then
|
if [ -n "$MAIL_MSMTP_ACCOUNT" ]; then
|
||||||
_MAIL_ARGS="$_MAIL_ARGS -a '$MAIL_MSMTP_ACCOUNT'"
|
_MAIL_ARGS="$_MAIL_ARGS -a '$MAIL_MSMTP_ACCOUNT'"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*) ;;
|
*) ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo "'$_MAIL_BIN' $_MAIL_ARGS '$MAIL_TO'"
|
echo "'$_MAIL_BIN' $_MAIL_ARGS '$MAIL_TO'"
|
||||||
@ -123,16 +123,16 @@ _mail_cmnd() {
|
|||||||
|
|
||||||
_mail_body() {
|
_mail_body() {
|
||||||
case $(basename "$_MAIL_BIN") in
|
case $(basename "$_MAIL_BIN") in
|
||||||
sendmail | ssmtp | msmtp)
|
sendmail | ssmtp | msmtp)
|
||||||
if [ -n "$MAIL_FROM" ]; then
|
if [ -n "$MAIL_FROM" ]; then
|
||||||
echo "From: $MAIL_FROM"
|
echo "From: $MAIL_FROM"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "To: $MAIL_TO"
|
echo "To: $MAIL_TO"
|
||||||
echo "Subject: $subject"
|
echo "Subject: $subject"
|
||||||
echo "Content-Type: $contenttype"
|
echo "Content-Type: $contenttype"
|
||||||
echo
|
echo
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo "$_content"
|
echo "$_content"
|
||||||
|
|||||||
@ -52,15 +52,15 @@ teams_send() {
|
|||||||
_content=$(echo "$_content" | _json_encode)
|
_content=$(echo "$_content" | _json_encode)
|
||||||
|
|
||||||
case "$_statusCode" in
|
case "$_statusCode" in
|
||||||
0)
|
0)
|
||||||
_color="${TEAMS_SUCCESS_COLOR:-$_color_success}"
|
_color="${TEAMS_SUCCESS_COLOR:-$_color_success}"
|
||||||
;;
|
;;
|
||||||
1)
|
1)
|
||||||
_color="${TEAMS_ERROR_COLOR:-$_color_danger}"
|
_color="${TEAMS_ERROR_COLOR:-$_color_danger}"
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
_color="${TEAMS_SKIP_COLOR:-$_color_muted}"
|
_color="${TEAMS_SKIP_COLOR:-$_color_muted}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
_color=$(echo "$_color" | tr -cd 'a-fA-F0-9')
|
_color=$(echo "$_color" | tr -cd 'a-fA-F0-9')
|
||||||
|
|||||||
@ -71,13 +71,13 @@ _xmpp_bin() {
|
|||||||
|
|
||||||
_xmpp_cmnd() {
|
_xmpp_cmnd() {
|
||||||
case $(basename "$_XMPP_BIN") in
|
case $(basename "$_XMPP_BIN") in
|
||||||
sendxmpp)
|
sendxmpp)
|
||||||
echo "'$_XMPP_BIN' '$XMPP_TO' $XMPP_BIN_ARGS"
|
echo "'$_XMPP_BIN' '$XMPP_TO' $XMPP_BIN_ARGS"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
_err "Command $XMPP_BIN is not supported, use sendxmpp."
|
_err "Command $XMPP_BIN is not supported, use sendxmpp."
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user