Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持多域名配置 Allow multiple domains configuration #58

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# syno-acme

> Deprecated:已弃用,可直接使用 [acme.sh](https://github.com/acmesh-official/acme.sh),已支持直接部署至群晖,详见 [Synology-NAS-Guide](https://github.com/acmesh-official/acme.sh/wiki/Synology-NAS-Guide)

通过acme协议更新群晖HTTPS泛域名证书的自动脚本

使用方法参见: [http://www.up4dev.com/2018/05/29/synology-ssl-wildcard-cert-update/](http://www.up4dev.com/2018/05/29/synology-ssl-wildcard-cert-update/)
38 changes: 30 additions & 8 deletions cert-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ ACME_BIN_PATH=${BASE_ROOT}/acme.sh
TEMP_PATH=${BASE_ROOT}/temp
CRT_PATH_NAME=`cat ${CRT_BASE_PATH}/_archive/DEFAULT`
CRT_PATH=${CRT_BASE_PATH}/_archive/${CRT_PATH_NAME}
FIND_MAJORVERSION_FILE="/etc/VERSION"
FIND_MAJORVERSION_STR="majorversion=\"7\""

backupCrt () {
echo 'begin backupCrt'
Expand Down Expand Up @@ -48,8 +50,12 @@ generateCrt () {
source config
echo 'begin updating default cert by acme.sh tool'
source ${ACME_BIN_PATH}/acme.sh.env
${ACME_BIN_PATH}/acme.sh --force --log --issue --dns ${DNS} --dnssleep ${DNS_SLEEP} -d "${DOMAIN}" -d "*.${DOMAIN}"
${ACME_BIN_PATH}/acme.sh --force --installcert -d ${DOMAIN} -d *.${DOMAIN} \
for d in ${DOMAIN//,/ }
do
domain_params="${domain_params} -d ${d}"
done
${ACME_BIN_PATH}/acme.sh --force --log --issue --dns ${DNS} --dnssleep ${DNS_SLEEP} ${domain_params}
${ACME_BIN_PATH}/acme.sh --force --installcert ${domain_params} \
--certpath ${CRT_PATH}/cert.pem \
--key-file ${CRT_PATH}/privkey.pem \
--fullchain-file ${CRT_PATH}/fullchain.pem
Expand All @@ -68,18 +74,34 @@ generateCrt () {
updateService () {
echo 'begin updateService'
echo 'cp cert path to des'
/bin/python2 ${BASE_ROOT}/crt_cp.py ${CRT_PATH_NAME}
if [ `grep -c "$FIND_MAJORVERSION_STR" $FIND_MAJORVERSION_FILE` -ne '0' ];then
echo "MajorVersion = 7, use system default python2"
python2 ${BASE_ROOT}/crt_cp.py ${CRT_PATH_NAME}
else
echo "MajorVersion < 7"
/bin/python2 ${BASE_ROOT}/crt_cp.py ${CRT_PATH_NAME}
fi
echo 'done updateService'
}

reloadWebService () {
echo 'begin reloadWebService'
echo 'reloading new cert...'
/usr/syno/etc/rc.sysv/nginx.sh reload
echo 'relading Apache 2.2'
stop pkg-apache22
start pkg-apache22
reload pkg-apache22
if [ `grep -c "$FIND_MAJORVERSION_STR" $FIND_MAJORVERSION_FILE` -ne '0' ];then
echo "MajorVersion = 7"
synow3tool --gen-all && systemctl reload nginx
else
echo "MajorVersion < 7"
/usr/syno/etc/rc.sysv/nginx.sh reload
fi
if [ `grep -c "$FIND_MAJORVERSION_STR" $FIND_MAJORVERSION_FILE` -ne '0' ];then
echo "MajorVersion = 7, no need to reload apache"
else
echo 'relading Apache on DSM 6.x'
stop pkg-apache22
start pkg-apache22
reload pkg-apache22
fi
echo 'done reloadWebService'
}

Expand Down
4 changes: 2 additions & 2 deletions config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 你主域名,如 baidu.com sina.com.cn 等
export DOMAIN=your_domain
# 你域名,如 baidu.com sina.com.cn 等,多个域名之间逗号分隔,支持泛域名
export DOMAIN=your_domain1,*.your_domain1,your_domain2,*.your_domain2

# DNS类型,根据域名服务商而定
export DNS=dns_xxx
Expand Down