minor, fix error messages

This commit is contained in:
neil 2016-01-06 22:14:45 +08:00
parent bf108bb7f1
commit 960ab88c54

26
le.sh
View File

@ -47,15 +47,13 @@ createAccountKey() {
account=$1 account=$1
length=$2 length=$2
if [ -z "$2" ] ; then if [ -z "$2" ] ; then
echo Use default length 2048 _info "Use default length 2048"
length=2048 length=2048
fi fi
_initpath _initpath
mkdir -p $WORKING_DIR
ACCOUNT_KEY_PATH=$WORKING_DIR/account.acc
if [ -f "$ACCOUNT_KEY_PATH" ] ; then if [ -f "$ACCOUNT_KEY_PATH" ] ; then
echo account key exists, skip _info "Account key exists, skip"
return return
else else
#generate account key #generate account key
@ -74,7 +72,7 @@ createDomainKey() {
domain=$1 domain=$1
length=$2 length=$2
if [ -z "$2" ] ; then if [ -z "$2" ] ; then
echo Use default length 2048 _info "Use default length 2048"
length=2048 length=2048
fi fi
_initpath $domain _initpath $domain
@ -82,7 +80,7 @@ createDomainKey() {
CERT_KEY_PATH=$WORKING_DIR/$domain/$domain.key CERT_KEY_PATH=$WORKING_DIR/$domain/$domain.key
if [ -f "$CERT_KEY_PATH" ] ; then if [ -f "$CERT_KEY_PATH" ] ; then
echo domain key exists, skip _info "Domain key exists, skip"
else else
#generate account key #generate account key
openssl genrsa $length > $CERT_KEY_PATH openssl genrsa $length > $CERT_KEY_PATH
@ -102,18 +100,18 @@ createCSR() {
domainlist=$2 domainlist=$2
if [ -f $CSR_PATH ] ; then if [ -f $CSR_PATH ] ; then
echo CSR exists, skip _info "CSR exists, skip"
return return
fi fi
if [ -z "$domainlist" ] ; then if [ -z "$domainlist" ] ; then
#single domain #single domain
echo single domain _info "Single domain" $domain
openssl req -new -sha256 -key $CERT_KEY_PATH -subj "/CN=$domain" > $CSR_PATH openssl req -new -sha256 -key $CERT_KEY_PATH -subj "/CN=$domain" > $CSR_PATH
else else
alt=DNS:$(echo $domainlist | sed "s/,/,DNS:/g") alt=DNS:$(echo $domainlist | sed "s/,/,DNS:/g")
#multi #multi
echo multi domain $alt _info "Multi domain" $alt
openssl req -new -sha256 -key $CERT_KEY_PATH -subj "/CN=$domain" -reqexts SAN -config <(printf "[ req_distinguished_name ]\n[ req ]\ndistinguished_name = req_distinguished_name\n[SAN]\nsubjectAltName=$alt") -out $CSR_PATH openssl req -new -sha256 -key $CERT_KEY_PATH -subj "/CN=$domain" -reqexts SAN -config <(printf "[ req_distinguished_name ]\n[ req ]\ndistinguished_name = req_distinguished_name\n[SAN]\nsubjectAltName=$alt") -out $CSR_PATH
fi fi
@ -222,7 +220,7 @@ _startserver() {
_stopserver() { _stopserver() {
pid="$1" pid="$1"
if [ "$pid" ] ; then if [ "$pid" ] ; then
if [ -z "$DEBUG" ] ; then if [ "$DEBUG" ] ; then
kill -s 9 $pid 2>&1 kill -s 9 $pid 2>&1
killall -s 9 nc 2>&1 killall -s 9 nc 2>&1
else else
@ -375,7 +373,7 @@ issue() {
alldomains=$(echo "$Le_Domain,$Le_Alt" | sed "s/,/ /g") alldomains=$(echo "$Le_Domain,$Le_Alt" | sed "s/,/ /g")
for d in $alldomains for d in $alldomains
do do
_info "Verifing domain $d" _info "Verifing domain" $d
_send_signed_request "$API/acme/new-authz" "{\"resource\": \"new-authz\", \"identifier\": {\"type\": \"dns\", \"value\": \"$d\"}}" _send_signed_request "$API/acme/new-authz" "{\"resource\": \"new-authz\", \"identifier\": {\"type\": \"dns\", \"value\": \"$d\"}}"
@ -398,7 +396,7 @@ issue() {
if [ "$Le_Webroot" == "no" ] ; then if [ "$Le_Webroot" == "no" ] ; then
_info "Standalone mode server" _info "Standalone mode server"
_startserver "$keyauthorization" & 2>&1 >/dev/null _startserver "$keyauthorization" 2>&1 >/dev/null &
serverproc="$!" serverproc="$!"
sleep 2 sleep 2
_debug serverproc $serverproc _debug serverproc $serverproc
@ -435,7 +433,7 @@ issue() {
status=$(echo $response | egrep -o '"status":"[^"]+"' | cut -d : -f 2 | sed 's/"//g') status=$(echo $response | egrep -o '"status":"[^"]+"' | cut -d : -f 2 | sed 's/"//g')
if [ "$status" == "valid" ] ; then if [ "$status" == "valid" ] ; then
_info "Verify success:$d" _info "Success"
break; break;
fi fi
@ -447,7 +445,7 @@ issue() {
fi fi
if [ "$status" == "pending" ] ; then if [ "$status" == "pending" ] ; then
_info "Verify pending:$d" _info "Pending"
else else
_err "Verify error:$response" _err "Verify error:$response"
_stopserver $serverproc _stopserver $serverproc