mirror of
https://github.com/plantroon/acme.sh.git
synced 2024-12-22 21:21:42 +00:00
fix compatible for sh
This commit is contained in:
parent
036e9d1074
commit
dceb3acace
36
acme.sh
36
acme.sh
@ -56,7 +56,19 @@ _debug2() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_exists() {
|
_startswith(){
|
||||||
|
_str="$1"
|
||||||
|
_sub="$2"
|
||||||
|
echo $_str | grep ^$_sub >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
_contains(){
|
||||||
|
_str="$1"
|
||||||
|
_sub="$2"
|
||||||
|
echo $_str | grep $_sub >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
_exists(){
|
||||||
cmd="$1"
|
cmd="$1"
|
||||||
if [[ -z "$cmd" ]] ; then
|
if [[ -z "$cmd" ]] ; then
|
||||||
_err "Usage: _exists cmd"
|
_err "Usage: _exists cmd"
|
||||||
@ -252,7 +264,7 @@ createAccountKey() {
|
|||||||
length=$2
|
length=$2
|
||||||
_debug account "$account"
|
_debug account "$account"
|
||||||
_debug length "$length"
|
_debug length "$length"
|
||||||
if [[ "$length" == "ec-"* ]] ; then
|
if _startswith "$length" "ec-" ; then
|
||||||
length=2048
|
length=2048
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -283,7 +295,7 @@ createDomainKey() {
|
|||||||
domain=$1
|
domain=$1
|
||||||
length=$2
|
length=$2
|
||||||
isec=""
|
isec=""
|
||||||
if [[ "$length" == "ec-"* ]] ; then
|
if _startswith "$length" "ec-" ; then
|
||||||
isec="1"
|
isec="1"
|
||||||
length=$(printf $length | cut -d '-' -f 2-100)
|
length=$(printf $length | cut -d '-' -f 2-100)
|
||||||
eccname="$length"
|
eccname="$length"
|
||||||
@ -583,14 +595,14 @@ _setopt() {
|
|||||||
|
|
||||||
if grep -H -n "^$__opt$__sep" "$__conf" > /dev/null ; then
|
if grep -H -n "^$__opt$__sep" "$__conf" > /dev/null ; then
|
||||||
_debug2 OK
|
_debug2 OK
|
||||||
if [[ "$__val" == *"&"* ]] ; then
|
if _contains "$__val" "&" ; then
|
||||||
__val="$(echo $__val | sed 's/&/\\&/g')"
|
__val="$(echo $__val | sed 's/&/\\&/g')"
|
||||||
fi
|
fi
|
||||||
text="$(cat $__conf)"
|
text="$(cat $__conf)"
|
||||||
echo "$text" | sed "s|^$__opt$__sep.*$|$__opt$__sep$__val$__end|" > "$__conf"
|
echo "$text" | sed "s|^$__opt$__sep.*$|$__opt$__sep$__val$__end|" > "$__conf"
|
||||||
|
|
||||||
elif grep -H -n "^#$__opt$__sep" "$__conf" > /dev/null ; then
|
elif grep -H -n "^#$__opt$__sep" "$__conf" > /dev/null ; then
|
||||||
if [[ "$__val" == *"&"* ]] ; then
|
if _contains "$__val" "&" ; then
|
||||||
__val="$(echo $__val | sed 's/&/\\&/g')"
|
__val="$(echo $__val | sed 's/&/\\&/g')"
|
||||||
fi
|
fi
|
||||||
text="$(cat $__conf)"
|
text="$(cat $__conf)"
|
||||||
@ -798,7 +810,7 @@ _initpath() {
|
|||||||
|
|
||||||
_apachePath() {
|
_apachePath() {
|
||||||
httpdconfname="$(apachectl -V | grep SERVER_CONFIG_FILE= | cut -d = -f 2 | tr -d '"' )"
|
httpdconfname="$(apachectl -V | grep SERVER_CONFIG_FILE= | cut -d = -f 2 | tr -d '"' )"
|
||||||
if [[ "$httpdconfname" == '/'* ]] ; then
|
if _startswith "$httpdconfname" '/' ; then
|
||||||
httpdconf="$httpdconfname"
|
httpdconf="$httpdconfname"
|
||||||
httpdconfname="$(basename $httpdconfname)"
|
httpdconfname="$(basename $httpdconfname)"
|
||||||
else
|
else
|
||||||
@ -987,7 +999,7 @@ issue() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [[ "$Le_Webroot" == *"no"* ]] ; then
|
if _contains "$Le_Webroot" "no" ; then
|
||||||
_info "Standalone mode."
|
_info "Standalone mode."
|
||||||
if ! _exists "nc" ; then
|
if ! _exists "nc" ; then
|
||||||
_err "Please install netcat(nc) tools first."
|
_err "Please install netcat(nc) tools first."
|
||||||
@ -1008,7 +1020,7 @@ issue() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$Le_Webroot" == *"apache"* ]] ; then
|
if _contains "$Le_Webroot" "apache" ; then
|
||||||
if ! _setApache ; then
|
if ! _setApache ; then
|
||||||
_err "set up apache error. Report error to me."
|
_err "set up apache error. Report error to me."
|
||||||
return 1
|
return 1
|
||||||
@ -1097,7 +1109,7 @@ issue() {
|
|||||||
let "_index+=1"
|
let "_index+=1"
|
||||||
|
|
||||||
vtype="$VTYPE_HTTP"
|
vtype="$VTYPE_HTTP"
|
||||||
if [[ "$_currentRoot" == "dns"* ]] ; then
|
if _startswith "$_currentRoot" "dns" ; then
|
||||||
vtype="$VTYPE_DNS"
|
vtype="$VTYPE_DNS"
|
||||||
fi
|
fi
|
||||||
_info "Getting token for domain" $d
|
_info "Getting token for domain" $d
|
||||||
@ -2040,7 +2052,7 @@ _process() {
|
|||||||
--domain|-d)
|
--domain|-d)
|
||||||
_dvalue="$2"
|
_dvalue="$2"
|
||||||
|
|
||||||
if [[ -z "$_dvalue" ]] || [[ "$_dvalue" == "-"* ]] ; then
|
if [[ -z "$_dvalue" ]] || _startswith "$_dvalue" "-" ; then
|
||||||
_err "'$_dvalue' is not a valid domain for parameter '$1'"
|
_err "'$_dvalue' is not a valid domain for parameter '$1'"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -2064,7 +2076,7 @@ _process() {
|
|||||||
STAGE="1"
|
STAGE="1"
|
||||||
;;
|
;;
|
||||||
--debug)
|
--debug)
|
||||||
if [[ "$2" == "-"* ]] || [[ -z "$2" ]]; then
|
if [[ -z "$2" ]] || _startswith "$2" "-" ; then
|
||||||
DEBUG="1"
|
DEBUG="1"
|
||||||
else
|
else
|
||||||
DEBUG="$2"
|
DEBUG="$2"
|
||||||
@ -2098,7 +2110,7 @@ _process() {
|
|||||||
;;
|
;;
|
||||||
--dns)
|
--dns)
|
||||||
wvalue="dns"
|
wvalue="dns"
|
||||||
if [[ "$2" != "-"* ]] ; then
|
if ! _startswith "$2" "-" ; then
|
||||||
wvalue="$2"
|
wvalue="$2"
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user