separate "installcert" from "issue" command.

This commit is contained in:
neil 2016-01-23 09:38:08 +08:00
parent 6e89f81139
commit 79c2453a2c

71
le.sh
View File

@ -714,33 +714,7 @@ issue() {
_setopt "$DOMAIN_CONF" "Le_NextRenewTimeStr" "=" "\"$Le_NextRenewTimeStr\""
if [ "$Le_RealCertPath" ] ; then
if [ -f "$Le_RealCertPath" ] ; then
cp -p "$Le_RealCertPath" "$Le_RealCertPath".bak
fi
cat "$CERT_PATH" > "$Le_RealCertPath"
fi
if [ "$Le_RealCACertPath" ] ; then
if [ -f "$Le_RealCACertPath" ] ; then
cp -p "$Le_RealCACertPath" "$Le_RealCACertPath".bak
fi
cat "$CA_CERT_PATH" > "$Le_RealCACertPath"
fi
if [ "$Le_RealKeyPath" ] ; then
if [ -f "$Le_RealKeyPath" ] ; then
cp -p "$Le_RealKeyPath" "$Le_RealKeyPath".bak
fi
cat "$CERT_KEY_PATH" > "$Le_RealKeyPath"
fi
if [ "$Le_ReloadCmd" ] ; then
_info "Run Le_ReloadCmd: $Le_ReloadCmd"
$Le_ReloadCmd
fi
installcert $Le_Domain "$Le_RealCertPath" "$Le_RealKeyPath" "$Le_RealCACertPath" "$Le_ReloadCmd"
}
@ -807,6 +781,47 @@ renewAll() {
}
installcert() {
Le_Domain="$1"
if [ -z "$Le_Domain" ] ; then
_err "Usage: $0 domain.com [cert-file-path]|no [key-file-path]|no [ca-cert-file-path]|no [reloadCmd]|no"
return 1
fi
Le_RealCertPath="$2"
Le_RealKeyPath="$3"
Le_RealCACertPath="$4"
Le_ReloadCmd="$5"
_initpath $Le_Domain
_setopt "$DOMAIN_CONF" "Le_RealCertPath" "=" "\"$Le_RealCertPath\""
_setopt "$DOMAIN_CONF" "Le_RealCACertPath" "=" "\"$Le_RealCACertPath\""
_setopt "$DOMAIN_CONF" "Le_RealKeyPath" "=" "\"$Le_RealKeyPath\""
_setopt "$DOMAIN_CONF" "Le_ReloadCmd" "=" "\"$Le_ReloadCmd\""
if [ "$Le_RealCACertPath" ] ; then
if [ -f "$Le_RealCACertPath" ] ; then
cp -p "$Le_RealCACertPath" "$Le_RealCACertPath".bak
fi
cat "$CA_CERT_PATH" > "$Le_RealCACertPath"
fi
if [ "$Le_RealKeyPath" ] ; then
if [ -f "$Le_RealKeyPath" ] ; then
cp -p "$Le_RealKeyPath" "$Le_RealKeyPath".bak
fi
cat "$CERT_KEY_PATH" > "$Le_RealKeyPath"
fi
if [ "$Le_ReloadCmd" ] ; then
_info "Run Le_ReloadCmd: $Le_ReloadCmd"
$Le_ReloadCmd
fi
}
install() {
_initpath
if ! command -v "curl" > /dev/null ; then
@ -890,7 +905,7 @@ version() {
}
showhelp() {
version
echo "Usage: issue|renew|renewAll|createAccountKey|createDomainKey|createCSR|install|uninstall|version"
echo "Usage: issue|installcert|renew|renewAll|createAccountKey|createDomainKey|createCSR|install|uninstall|version"
}