Add shfmt to format source code

This commit is contained in:
neilpang 2016-11-09 19:30:39 +08:00
parent b001840dee
commit 4c2a384159
12 changed files with 1451 additions and 1556 deletions

11
.travis.yml Normal file
View File

@ -0,0 +1,11 @@
language: bash
env:
global:
- SHFMT_URL=https://github.com/mvdan/sh/releases/download/v0.4.0/shfmt_v0.4.0_linux_amd64
script:
- curl -sSL $SHFMT_URL -o ~/shfmt
- chmod +x ~/shfmt
- ~/shfmt -l -w -i 2 .
- git diff --exit-code || echo "Run shfmt to fix the formatting issues"

122
acme.sh
View File

@ -84,7 +84,6 @@ __red() {
fi
}
_printargs() {
if [ -z "$2" ]; then
printf -- "[$(date)] $1"
@ -118,7 +117,6 @@ _dlg_versions() {
fi
}
_log() {
[ -z "$LOG_FILE" ] && return
_printargs "$@" >>$LOG_FILE
@ -129,7 +127,6 @@ _info() {
_printargs "$@"
}
_err() {
_log "$@"
printf -- "[$(date)] " >&2
@ -147,7 +144,6 @@ _usage() {
printf "\n" >&2
}
_debug() {
if [ -z "$LOG_LEVEL" ] || [ "$LOG_LEVEL" -ge "$LOG_LEVEL_1" ]; then
_log "$@"
@ -232,8 +228,7 @@ _getfield(){
fi
_ffi=$_findex
while [ "$_ffi" -gt "0" ]
do
while [ "$_ffi" -gt "0" ]; do
_fv="$(echo "$_str" | cut -d $_sep -f $_ffi)"
if [ "$_fv" ]; then
printf -- "%s" "$_fv"
@ -295,7 +290,6 @@ _h_char_2_dec() {
}
_URGLY_PRINTF=""
if [ "$(printf '\x41')" != 'A' ]; then
_URGLY_PRINTF=1
@ -314,14 +308,14 @@ _h2b() {
if [ -z "$_URGLY_PRINTF" ]; then
h="$(printf $hex | cut -c $i-$j)"
if [ -z "$h" ]; then
break;
break
fi
printf "\x$h"
else
ic="$(printf $hex | cut -c $i)"
jc="$(printf $hex | cut -c $j)"
if [ -z "$ic$jc" ]; then
break;
break
fi
ic="$(_h_char_2_dec "$ic")"
jc="$(_h_char_2_dec "$jc")"
@ -556,7 +550,6 @@ _createkey() {
fi
}
#domain
_is_idn() {
_is_idn_d="$1"
@ -703,7 +696,6 @@ _readKeyLengthFromCSR() {
fi
}
_ss() {
_port="$1"
@ -894,7 +886,7 @@ _stat() {
return
fi
return 1; #error, 'stat' not found
return 1 #error, 'stat' not found
}
#keyfile
@ -910,7 +902,6 @@ _calcjwk() {
return 0
fi
EC_SIGN=""
if grep "BEGIN RSA PRIVATE KEY" "$keyfile" >/dev/null 2>&1; then
_debug "RSA key"
@ -1074,7 +1065,6 @@ _inithttp() {
}
# body url [needbase64] [POST|PUT]
_post() {
body="$1"
@ -1140,7 +1130,6 @@ _post() {
return $_ret
}
# url getheader timeout
_get() {
_debug GET
@ -1266,7 +1255,6 @@ _send_signed_request() {
body="{\"header\": $JWK_HEADER, \"protected\": \"$protected64\", \"payload\": \"$payload64\", \"signature\": \"$sig\"}"
_debug3 body "$body"
response="$(_post "$body" $url "$needbase64")"
_CACHED_NONCE=""
if [ "$?" != "0" ]; then
@ -1288,7 +1276,6 @@ _send_signed_request() {
}
#setopt "file" "opt" "=" "value" [";"]
_setopt() {
__conf="$1"
@ -1326,7 +1313,6 @@ _setopt() {
_debug2 "$(grep -n "^$__opt$__sep" $__conf)"
}
#_save_conf file key value
#save to conf
_save_conf() {
@ -1365,7 +1351,6 @@ _read_conf() {
fi
}
#_savedomainconf key value
#save to domain.conf
_savedomainconf() {
@ -1439,7 +1424,6 @@ _startserver() {
fi
fi
_debug "_NC" "$_NC"
#for centos ncat
@ -1460,7 +1444,7 @@ _startserver() {
# while true ; do
if [ "$DEBUG" ]; then
if ! printf "HTTP/1.1 200 OK\r\n\r\n$content" | $_NC -p $Le_HTTPPort; then
printf "HTTP/1.1 200 OK\r\n\r\n$content" | $_NC $Le_HTTPPort ;
printf "HTTP/1.1 200 OK\r\n\r\n$content" | $_NC $Le_HTTPPort
fi
else
if ! printf "HTTP/1.1 200 OK\r\n\r\n$content" | $_NC -p $Le_HTTPPort >/dev/null 2>&1; then
@ -1507,8 +1491,7 @@ _sleep() {
_sleep_sec="$1"
if [ "$__INTERACTIVE" ]; then
_sleep_c="$_sleep_sec"
while [ "$_sleep_c" -ge "0" ] ;
do
while [ "$_sleep_c" -ge "0" ]; do
printf "\r \r"
__green "$_sleep_c"
_sleep_c="$(_math $_sleep_c - 1)"
@ -1612,7 +1595,6 @@ __initHome() {
fi
fi
if [ -z "$LE_WORKING_DIR" ]; then
if [ -f "$DEFAULT_INSTALL_HOME/account.conf" ]; then
_debug "It seems that $PROJECT_NAME is already installed in $DEFAULT_INSTALL_HOME"
@ -1720,7 +1702,6 @@ _initpath() {
ACCOUNT_JSON_PATH="$_DEFAULT_ACCOUNT_JSON_PATH"
fi
_DEFAULT_CERT_HOME="$LE_WORKING_DIR"
if [ -z "$CERT_HOME" ]; then
CERT_HOME="$_DEFAULT_CERT_HOME"
@ -1884,7 +1865,7 @@ _restoreApache() {
if ! _exec $_APACHECTL -t; then
_exec_err
_err "Sorry, restore apache config error, please contact me."
return 1;
return 1
fi
_debug "Restored successfully."
rm -f "$APACHE_CONF_BACKUP_DIR/$httpdconfname"
@ -1904,7 +1885,7 @@ _setApache() {
_exec_err
_err "The apache config file has error, please fix it first, then try again."
_err "Don't worry, there is nothing changed to your system."
return 1;
return 1
else
_info "OK"
fi
@ -1954,7 +1935,7 @@ Allow from all
else
_err "Sorry, The apache config file can not be restored, please report bug."
fi
return 1;
return 1
fi
if [ ! -d "$ACME_DIR" ]; then
@ -1966,7 +1947,7 @@ Allow from all
_exec_err
_err "$_APACHECTL graceful error, please contact me."
_restoreApache
return 1;
return 1
fi
usingApache="1"
return 0
@ -1993,8 +1974,7 @@ _clearupdns() {
fi
ventries=$(echo "$vlist" | tr ',' ' ')
for ventry in $ventries
do
for ventry in $ventries; do
d=$(echo $ventry | cut -d $sep -f 1)
keyauthorization=$(echo $ventry | cut -d $sep -f 2)
vtype=$(echo $ventry | cut -d $sep -f 4)
@ -2087,8 +2067,7 @@ _on_before_issue() {
_index=1
_currentRoot=""
_addrIndex=1
for d in $alldomains
do
for d in $alldomains; do
_debug "Check for domain" $d
_currentRoot="$(_getfield "$Le_Webroot" $_index)"
_debug "_currentRoot" "$_currentRoot"
@ -2220,13 +2199,11 @@ __calcAccountKeyHash() {
[ -f "$ACCOUNT_KEY_PATH" ] && cat "$ACCOUNT_KEY_PATH" | _digest sha256
}
#keylength
_regAccount() {
_initpath
_reg_length="$1"
if [ ! -f "$ACCOUNT_KEY_PATH" ] && [ -f "$_OLD_ACCOUNT_KEY" ]; then
_info "mv $_OLD_ACCOUNT_KEY to $ACCOUNT_KEY_PATH"
mv "$_OLD_ACCOUNT_KEY" "$ACCOUNT_KEY_PATH"
@ -2250,8 +2227,7 @@ _regAccount() {
_updateTos=""
_reg_res="new-reg"
while true ;
do
while true; do
_debug AGREEMENT "$AGREEMENT"
regjson='{"resource": "'$_reg_res'", "agreement": "'$AGREEMENT'"}'
@ -2316,7 +2292,6 @@ _regAccount() {
}
# domain folder file
_findHook() {
_hookdomain="$1"
@ -2364,7 +2339,7 @@ __get_domain_new_authz() {
_authz_i="$(_math "$_authz_i" + 1)"
_info "The server is busy, Sleep $_authz_i to retry."
_sleep "$_authz_i"
done;
done
if [ "$_authz_i" = "$_Max_new_authz_retry_times" ]; then
_debug "new-authz retry reach the max $_Max_new_authz_retry_times times."
@ -2507,8 +2482,7 @@ issue() {
alldomains=$(echo "$Le_Domain,$Le_Alt" | tr ',' ' ')
_index=1
_currentRoot=""
for d in $alldomains
do
for d in $alldomains; do
_info "Getting webroot for domain" $d
_w="$(echo $Le_Webroot | cut -d , -f $_index)"
_info _w "$_w"
@ -2555,14 +2529,12 @@ issue() {
keyauthorization="$token.$thumbprint"
_debug keyauthorization "$keyauthorization"
if printf "$response" | grep '"status":"valid"' >/dev/null 2>&1; then
_info "$d is already verified, skip."
keyauthorization=$STATE_VERIFIED
_debug keyauthorization "$keyauthorization"
fi
dvlist="$d$sep$keyauthorization$sep$uri$sep$vtype$sep$_currentRoot"
_debug dvlist "$dvlist"
@ -2573,8 +2545,7 @@ issue() {
#add entry
dnsadded=""
ventries=$(echo "$vlist" | tr ',' ' ')
for ventry in $ventries
do
for ventry in $ventries; do
d=$(echo $ventry | cut -d $sep -f 1)
keyauthorization=$(echo $ventry | cut -d $sep -f 2)
vtype=$(echo $ventry | cut -d $sep -f 4)
@ -2660,8 +2631,7 @@ issue() {
_ncIndex=1
ventries=$(echo "$vlist" | tr ',' ' ')
for ventry in $ventries
do
for ventry in $ventries; do
d=$(echo $ventry | cut -d $sep -f 1)
keyauthorization=$(echo $ventry | cut -d $sep -f 2)
uri=$(echo $ventry | cut -d $sep -f 3)
@ -2682,7 +2652,6 @@ issue() {
_debug "_currentRoot" "$_currentRoot"
if [ "$vtype" = "$VTYPE_HTTP" ]; then
if [ "$_currentRoot" = "$NO_VALUE" ]; then
_info "Standalone mode server"
@ -2731,7 +2700,7 @@ issue() {
_debug "Changing owner/group of .well-known to $webroot_owner"
chown -R $webroot_owner "$_currentRoot/.well-known"
else
_debug "not chaning owner/group of webroot";
_debug "not chaning owner/group of webroot"
fi
fi
@ -2825,7 +2794,7 @@ issue() {
_stopserver $serverproc
serverproc=""
_clearupwebbroot "$_currentRoot" "$removelevel" "$token"
break;
break
fi
if [ "$status" = "invalid" ]; then
@ -2847,7 +2816,7 @@ issue() {
_clearupwebbroot "$_currentRoot" "$removelevel" "$token"
_clearup
_on_issue_err
return 1;
return 1
fi
if [ "$status" = "pending" ]; then
@ -2909,7 +2878,6 @@ issue() {
fi
fi
if [ -z "$Le_LinkCert" ]; then
response="$(echo $response | _dbase64 "multiline" | _normalizeJson)"
_err "Sign failed: $(echo "$response" | _egrep_o '"detail":"[^"]*"')"
@ -2969,14 +2937,12 @@ issue() {
Le_NextRenewTime=$(_math $Le_CertCreateTime + $Le_RenewalDays \* 24 \* 60 \* 60)
Le_NextRenewTimeStr=$(_time2str $Le_NextRenewTime)
_savedomainconf "Le_NextRenewTimeStr" "$Le_NextRenewTimeStr"
Le_NextRenewTime=$(_math $Le_NextRenewTime - 86400)
_savedomainconf "Le_NextRenewTime" "$Le_NextRenewTime"
_on_issue_success
if [ "$Le_RealCertPath$Le_RealKeyPath$Le_RealCACertPath$Le_ReloadCmd$Le_RealFullChainPath" ]; then
@ -3000,7 +2966,7 @@ renew() {
_info "$(__green "Renew: '$Le_Domain'")"
if [ ! -f "$DOMAIN_CONF" ]; then
_info "'$Le_Domain' is not a issued domain, skip."
return 0;
return 0
fi
if [ "$Le_RenewalDays" ]; then
@ -3069,7 +3035,6 @@ renewAll() {
return $_ret
}
#csr webroot
signcsr() {
_csrfile="$1"
@ -3095,7 +3060,6 @@ signcsr(){
fi
_debug "_csrdomainlist" "$_csrdomainlist"
if [ -z "$_csrsubj" ]; then
_csrsubj="$(_getfield "$_csrdomainlist" 1)"
_debug _csrsubj "$_csrsubj"
@ -3151,7 +3115,6 @@ showcsr() {
_info "SubjectAltNames=$_csrdomainlist"
_csrkeylength=$(_readKeyLengthFromCSR "$_csrfile")
if [ "$?" != "0" ] || [ -z "$_csrkeylength" ]; then
_err "Can not read key length from csr: $_csrfile"
@ -3189,7 +3152,6 @@ list() {
fi
fi
}
deploy() {
@ -3265,7 +3227,6 @@ installcert() {
_installcert
}
_installcert() {
_savedomainconf "Le_RealCertPath" "$Le_RealCertPath"
@ -3314,7 +3275,6 @@ _installcert() {
fi
fi
if [ "$Le_RealKeyPath" ]; then
_installed=1
_info "Installing key to:$Le_RealKeyPath"
@ -3343,7 +3303,6 @@ _installcert() {
fi
fi
}
installcronjob() {
@ -3364,9 +3323,15 @@ installcronjob() {
return 1
fi
if _exists uname && uname -a | grep solaris >/dev/null; then
crontab -l | { cat; echo "0 0 * * * $lesh --cron --home \"$LE_WORKING_DIR\" > /dev/null"; } | crontab --
crontab -l | {
cat
echo "0 0 * * * $lesh --cron --home \"$LE_WORKING_DIR\" > /dev/null"
} | crontab --
else
crontab -l | { cat; echo "0 0 * * * $lesh --cron --home \"$LE_WORKING_DIR\" > /dev/null"; } | crontab -
crontab -l | {
cat
echo "0 0 * * * $lesh --cron --home \"$LE_WORKING_DIR\" > /dev/null"
} | crontab -
fi
fi
if [ "$?" != "0" ]; then
@ -3408,7 +3373,7 @@ revoke() {
_initpath $Le_Domain "$_isEcc"
if [ ! -f "$DOMAIN_CONF" ]; then
_err "$Le_Domain is not a issued domain, skip."
return 1;
return 1
fi
if [ ! -f "$CERT_PATH" ]; then
@ -3457,7 +3422,6 @@ revoke() {
return 1
}
#domain vtype
_deactivate() {
_d_domain="$1"
@ -3466,12 +3430,10 @@ _deactivate() {
_d_i=0
_d_max_retry=9
while [ "$_d_i" -lt "$_d_max_retry" ] ;
do
while [ "$_d_i" -lt "$_d_max_retry" ]; do
_info "Deactivate: $_d_domain"
_d_i="$(_math $_d_i + 1)"
if ! __get_domain_new_authz "$_d_domain"; then
_err "Can not get domain new authz token."
return 1
@ -3497,7 +3459,6 @@ _deactivate() {
_debug _vtype $_vtype
_info "Found $_vtype"
uri="$(printf "%s\n" "$entry" | _egrep_o '"uri":"[^"]*' | cut -d : -f 2,3 | tr -d '"')"
_debug uri $uri
@ -3534,8 +3495,7 @@ deactivate() {
_usage "Usage: $PROJECT_ENTRY --deactivate -d domain.com [-d domain.com]"
return 1
fi
for _d_dm in $(echo "$_d_domain_list" | tr ',' ' ' ) ;
do
for _d_dm in $(echo "$_d_domain_list" | tr ',' ' '); do
if [ -z "$_d_dm" ] || [ "$_d_dm" = "$NO_VALUE" ]; then
continue
fi
@ -3721,7 +3681,6 @@ _installalias() {
_info "No profile is found, you will need to go into $LE_WORKING_DIR to use $PROJECT_NAME"
fi
#for csh
_cshfile="$LE_WORKING_DIR/$PROJECT_ENTRY.csh"
_csh_profile="$HOME/.cshrc"
@ -3766,8 +3725,7 @@ install() {
#convert from le
if [ -d "$HOME/.le" ]; then
for envfile in "le.env" "le.sh.env"
do
for envfile in "le.env" "le.sh.env"; do
if [ -f "$HOME/.le/$envfile" ]; then
if grep "le.sh" "$HOME/.le/$envfile" >/dev/null; then
_upgrading="1"
@ -3775,7 +3733,7 @@ install() {
_info "Renaming \"$HOME/.le\" to $LE_WORKING_DIR"
mv "$HOME/.le" "$LE_WORKING_DIR"
mv "$LE_WORKING_DIR/$envfile" "$LE_WORKING_DIR/$PROJECT_ENTRY.env"
break;
break
fi
fi
done
@ -3808,7 +3766,6 @@ install() {
fi
done
if [ ! -f "$ACCOUNT_CONF_PATH" ]; then
_initconf
fi
@ -4536,7 +4493,7 @@ _process() {
*)
_err "Invalid command: $_CMD"
showhelp;
showhelp
return 1
;;
esac
@ -4561,24 +4518,15 @@ _process() {
}
if [ "$INSTALLONLINE" ]; then
INSTALLONLINE=""
_installOnline $BRANCH
exit
fi
main() {
[ -z "$1" ] && showhelp && return
if _startswith "$1" '-'; then _process "$@"; else "$@"; fi
}
main "$@"

View File

@ -6,8 +6,6 @@
#Which will be called by acme.sh to deploy the cert
#returns 0 means success, otherwise error.
######## Public functions #####################
#domain keyfile certfile cafile fullchain
@ -24,10 +22,7 @@ myapi_deploy() {
_debug _cca "$_cca"
_debug _cfullchain "$_cfullchain"
_err "Not implemented yet"
return 1
}

View File

@ -1,12 +1,10 @@
#!/usr/bin/env sh
#
#CF_Key="sdfsdfsdfljlbjkljlkjsdfoiwje"
#
#CF_Email="xxxx@sss.com"
CF_Api="https://api.cloudflare.com/client/v4"
######## Public functions #####################
@ -69,7 +67,7 @@ dns_cf_add(){
_info "Updated, sleeping 10 seconds"
sleep 10
#todo: check if the record takes effect
return 0;
return 0
fi
_err "Update error"
return 1
@ -77,14 +75,12 @@ dns_cf_add(){
}
#fulldomain
dns_cf_rm() {
fulldomain=$1
}
#################### Private functions bellow ##################################
#_acme-challenge.www.domain.com
#returns
@ -99,7 +95,7 @@ _get_root() {
h=$(printf $domain | cut -d . -f $i-100)
if [ -z "$h" ]; then
#not valid
return 1;
return 1
fi
if ! _cf_rest GET "zones?name=$h"; then
@ -145,5 +141,3 @@ _cf_rest() {
_debug2 response "$response"
return 0
}

View File

@ -6,10 +6,8 @@
#
#CX_Secret="sADDsdasdgdsf"
CX_Api="https://www.cloudxns.net/api2"
#REST_API
######## Public functions #####################
@ -30,7 +28,6 @@ dns_cx_add() {
_saveaccountconf CX_Key "$CX_Key"
_saveaccountconf CX_Secret "$CX_Secret"
_debug "First detect the root zone"
if ! _get_root $fulldomain; then
_err "invalid domain"
@ -56,15 +53,12 @@ dns_cx_add() {
return 1
}
#fulldomain
dns_cx_rm() {
fulldomain=$1
}
#usage: root sub
#return if the sub record already exists.
#echos the existing records count.
@ -127,9 +121,6 @@ update_record() {
return 1
}
#################### Private functions bellow ##################################
#_acme-challenge.www.domain.com
#returns
@ -150,7 +141,7 @@ _get_root() {
_debug h "$h"
if [ -z "$h" ]; then
#not valid
return 1;
return 1
fi
if printf "$response" | grep "$h." >/dev/null; then
@ -173,7 +164,6 @@ _get_root() {
return 1
}
#Usage: method URI data
_rest() {
m=$1
@ -214,5 +204,3 @@ _rest() {
fi
return 0
}

View File

@ -6,7 +6,6 @@
#
#GD_Secret="asdfsdfsfsdfsdfdfsdf"
GD_Api="https://api.godaddy.com/v1"
######## Public functions #####################
@ -35,7 +34,6 @@ dns_gd_add(){
_debug _sub_domain "$_sub_domain"
_debug _domain "$_domain"
_info "Adding record"
if _gd_rest PUT "domains/$_domain/records/TXT/$_sub_domain" "[{\"data\":\"$txtvalue\"}]"; then
if [ "$response" = "{}" ]; then
@ -53,17 +51,12 @@ dns_gd_add(){
}
#fulldomain
dns_gd_rm() {
fulldomain=$1
}
#################### Private functions bellow ##################################
#_acme-challenge.www.domain.com
#returns
@ -78,7 +71,7 @@ _get_root() {
h=$(printf $domain | cut -d . -f $i-100)
if [ -z "$h" ]; then
#not valid
return 1;
return 1
fi
if ! _gd_rest GET "domains/$h"; then
@ -121,5 +114,3 @@ _gd_rest() {
_debug2 response "$response"
return 0
}

View File

@ -65,14 +65,8 @@ dns_lexicon_add() {
}
#fulldomain
dns_lexicon_rm() {
fulldomain=$1
}

View File

@ -68,7 +68,7 @@ dns_lua_add() {
if [ "$?" = "0" ]; then
_info "Updated!"
#todo: check if the record takes effect
return 0;
return 0
fi
_err "Update error"
return 1
@ -76,14 +76,12 @@ dns_lua_add() {
}
#fulldomain
dns_lua_rm() {
fulldomain=$1
}
#################### Private functions bellow ##################################
#_acme-challenge.www.domain.com
#returns
@ -101,7 +99,7 @@ _get_root() {
h=$(printf $domain | cut -d . -f $i-100)
if [ -z "$h" ]; then
#not valid
return 1;
return 1
fi
if printf $response | grep \"name\":\"$h\" >/dev/null; then
@ -141,5 +139,3 @@ _LUA_rest() {
_debug2 response "$response"
return 0
}

View File

@ -6,8 +6,6 @@
#Which will be called by acme.sh to add the txt record to your api system.
#returns 0 means success, otherwise error.
######## Public functions #####################
#Usage: dns_myapi_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
@ -15,18 +13,15 @@ dns_myapi_add() {
fulldomain=$1
txtvalue=$2
_err "Not implemented!"
return 1;
return 1
}
#fulldomain
dns_myapi_rm() {
fulldomain=$1
}
#################### Private functions bellow ##################################
_info() {
if [ -z "$2" ]; then

View File

@ -1,6 +1,5 @@
#!/usr/bin/env sh
#Applcation Key
#OVH_AK="sdfsdfsdfljlbjkljlkjsdfoiwje"
#
@ -10,10 +9,8 @@
#Consumer Key
#OVH_CK="sdfsdfsdfsdfsdfdsf"
#OVH_END_POINT=ovh-eu
#'ovh-eu'
OVH_EU='https://eu.api.ovh.com/1.0'
@ -35,13 +32,10 @@ SYS_CA='https://ca.api.soyoustart.com/1.0'
#'runabove-ca'
RAV_CA='https://api.runabove.com/1.0'
wiki="https://github.com/Neilpang/acme.sh/wiki/How-to-use-OVH-domain-api"
ovh_success="https://github.com/Neilpang/acme.sh/wiki/OVH-Success"
_ovh_get_api() {
_ogaep="$1"
@ -76,8 +70,8 @@ _ovh_get_api() {
return
;;
*)
_err "Unknown parameter : $1"
return 1
;;
@ -101,7 +95,6 @@ dns_ovh_add(){
_saveaccountconf OVH_AK "$OVH_AK"
_saveaccountconf OVH_AS "$OVH_AS"
if [ -z "$OVH_END_POINT" ]; then
OVH_END_POINT="ovh-eu"
fi
@ -119,10 +112,9 @@ dns_ovh_add(){
_err "Can not get consumer key."
fi
#return and wait for retry.
return 1;
return 1
fi
_info "Checking authentication"
response="$(_ovh_rest GET "domain/")"
@ -173,7 +165,7 @@ dns_ovh_add(){
_debug "Refresh:$response"
_info "Updated, sleeping 10 seconds"
sleep 10
return 0;
return 0
fi
fi
_err "Update error"
@ -182,14 +174,12 @@ dns_ovh_add(){
}
#fulldomain
dns_ovh_rm() {
fulldomain=$1
}
#################### Private functions bellow ##################################
_ovh_authentication() {
@ -227,7 +217,6 @@ _ovh_authentication() {
}
#_acme-challenge.www.domain.com
#returns
# _sub_domain=_acme-challenge.www
@ -241,7 +230,7 @@ _get_root() {
h=$(printf $domain | cut -d . -f $i-100)
if [ -z "$h" ]; then
#not valid
return 1;
return 1
fi
if ! _ovh_rest GET "domain/zone/$h"; then
@ -274,7 +263,6 @@ _ovh_rest() {
data="$3"
_debug $ep
_ovh_url="$OVH_API/$ep"
_debug2 _ovh_url "$_ovh_url"
_ovh_t="$(_ovh_timestamp)"
@ -284,7 +272,6 @@ _ovh_rest() {
_ovh_hex="$(printf "%s" "$_ovh_p" | _digest sha1 hex)"
_debug2 _ovh_hex "$_ovh_hex"
_H1="X-Ovh-Application: $OVH_AK"
_H2="X-Ovh-Signature: \$1\$$_ovh_hex"
_debug2 _H2 "$_H2"
@ -305,5 +292,3 @@ _ovh_rest() {
_debug2 response "$response"
return 0
}

View File

@ -61,14 +61,12 @@ dns_pdns_add() {
return 0
}
#fulldomain
dns_pdns_rm() {
fulldomain=$1
}
set_record() {
_info "Adding record"
root=$1