Skip to content

Commit

Permalink
Change caddy automatic application certificate to manual designation …
Browse files Browse the repository at this point in the history
…(application by acme.sh)
  • Loading branch information
loyess committed Jul 5, 2020
1 parent 711278f commit 83eeaaf
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 129 deletions.
33 changes: 2 additions & 31 deletions prepare/mos_tls_tunnel_prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,6 @@ get_input_server_name(){
done
}

get_input_email_for_caddy(){
while true
do
echo
read -e -p "请输入一个邮箱(caddy证书生成所需):" email
if [ -z "$(echo $email | grep -E ${EMAIL_RE})" ]; then
echo
echo -e "${Error} 请输入正确合法的邮箱."
echo
continue
fi

echo
echo -e "${Red} email = ${email}${suffix}"
echo
break
done
}

get_input_wss_path(){
while true
do
Expand Down Expand Up @@ -357,22 +338,12 @@ install_prepare_libev_mos_tls_tunnel(){
acme_get_certificate_by_force "${serverName}"
elif [[ ${domainType} = DNS-Only ]] && [[ ${isEnableWeb} = enable ]]; then
get_input_mirror_site

if [[ ${web_flag} = "1" ]]; then
get_input_email_for_caddy
elif [[ ${web_flag} = "2" ]]; then
acme_get_certificate_by_force "${serverName}"
fi
acme_get_certificate_by_force "${serverName}"
elif [[ ${domainType} = CDN ]] && [[ ${isEnableWeb} = disable ]]; then
acme_get_certificate_by_api_or_manual "${serverName}"
elif [[ ${domainType} = CDN ]] && [[ ${isEnableWeb} = enable ]]; then
get_input_mirror_site

if [[ ${web_flag} = "1" ]]; then
choose_api_get_mode
elif [[ ${web_flag} = "2" ]]; then
acme_get_certificate_by_api_or_manual "${serverName}"
fi
acme_get_certificate_by_api_or_manual "${serverName}"
fi
fi
}
33 changes: 2 additions & 31 deletions prepare/v2ray_plugin_prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,25 +157,6 @@ get_input_host(){
done
}

get_input_email_for_caddy(){
while true
do
echo
read -e -p "请输入供于域名证书生成所需的 Email:" email
if [ -z "$(echo $email | grep -E ${EMAIL_RE})" ]; then
echo
echo -e "${Error} 请输入正确合法的邮箱."
echo
continue
fi

echo
echo -e "${Red} email = ${email}${suffix}"
echo
break
done
}

get_input_ws_path(){
while true
do
Expand Down Expand Up @@ -362,12 +343,7 @@ install_prepare_libev_v2ray(){
fi

if is_dns_only ${domain_ip}; then
if [[ ${web_flag} = "1" ]]; then
get_input_email_for_caddy
elif [[ ${web_flag} = "2" ]]; then
acme_get_certificate_by_force ${domain}
fi

acme_get_certificate_by_force ${domain}
get_input_ws_path
get_input_mirror_site
is_disable_mux
Expand All @@ -392,12 +368,7 @@ install_prepare_libev_v2ray(){
fi

if is_cdn_proxied ${domain_ip}; then
if [[ ${web_flag} = "1" ]]; then
choose_api_get_mode
elif [[ ${web_flag} = "2" ]]; then
acme_get_certificate_by_api_or_manual ${domain}
fi

acme_get_certificate_by_api_or_manual ${domain}
get_input_ws_path
get_input_mirror_site
is_disable_mux
Expand Down
5 changes: 0 additions & 5 deletions service/caddy_centos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ if [ ! -d $PID_DIR ]; then
fi
fi

if $(grep -q 'cloudflare' $CONF); then
export CLOUDFLARE_EMAIL=$(cat ~/.api/cf.api | grep "CLOUDFLARE_EMAIL" | cut -d= -f2)
export CLOUDFLARE_API_KEY=$(cat ~/.api/cf.api | grep "CLOUDFLARE_API_KEY" | cut -d= -f2)
fi

if [ ! -f $CONF ]; then
echo "$NAME config file $CONF not found"
exit 1
Expand Down
5 changes: 0 additions & 5 deletions service/caddy_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ if [ ! -f $CONF ]; then
exit 1
fi

if $(grep -q 'cloudflare' $CONF); then
export CLOUDFLARE_EMAIL=$(cat ~/.api/cf.api | grep "CLOUDFLARE_EMAIL" | cut -d= -f2)
export CLOUDFLARE_API_KEY=$(cat ~/.api/cf.api | grep "CLOUDFLARE_API_KEY" | cut -d= -f2)
fi

check_running() {
if [ -e $PID_FILE ]; then
if [ -r $PID_FILE ]; then
Expand Down
32 changes: 8 additions & 24 deletions ss-plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export PATH

# shell version
# ====================
SHELL_VERSION="2.6.1"
SHELL_VERSION="2.6.2"
# ====================


Expand Down Expand Up @@ -512,17 +512,6 @@ choose_script_bbr(){
esac
}

choose_caddy_extension(){
local libev_v2ray=$1

improt_package "tools" "caddy_install.sh"
if [[ ${libev_v2ray} == "4" ]]; then
install_caddy
elif [[ ${libev_v2ray} == "5" ]]; then
install_caddy "tls.dns.cloudflare"
fi
}

get_ip(){
local IP=$( ip addr | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | egrep -v "^192\.168|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-2]\.|^10\.|^127\.|^255\.|^0\." | head -n 1 )
[ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipv4.icanhazip.com )
Expand Down Expand Up @@ -646,15 +635,15 @@ config_ss(){
elif [[ ${libev_v2ray} == "4" ]]; then
ss_v2ray_ws_tls_web_config
if [[ ${web_flag} = "1" ]]; then
caddy_config_none_cdn
caddy_config
elif [[ ${web_flag} = "2" ]]; then
mirror_domain=$(echo ${mirror_site} | sed 's/https:\/\///g')
nginx_config
fi
elif [[ ${libev_v2ray} == "5" ]]; then
ss_v2ray_ws_tls_web_cdn_config
if [[ ${web_flag} = "1" ]]; then
caddy_config_with_cdn
caddy_config
elif [[ ${web_flag} = "2" ]]; then
mirror_domain=$(echo ${mirror_site} | sed 's/https:\/\///g')
nginx_config
Expand Down Expand Up @@ -714,10 +703,8 @@ config_ss(){
ss_mtt_wss_dns_only_or_cdn_web_config
domain=${serverName}
path=${wssPath}
if [[ ${domainType} = DNS-Only ]] && [[ ${web_flag} = "1" ]]; then
caddy_config_none_cdn
elif [[ ${domainType} = CDN ]] && [[ ${web_flag} = "1" ]]; then
caddy_config_with_cdn
if [[ ${web_flag} = "1" ]]; then
caddy_config
elif [[ ${web_flag} = "2" ]]; then
mirror_domain=$(echo ${mirror_site} | sed 's/https:\/\///g')
nginx_config
Expand Down Expand Up @@ -1031,7 +1018,8 @@ install_main(){
improt_package "plugins" "v2ray_plugin_install.sh"
install_v2ray_plugin
if [[ ${web_flag} = "1" ]]; then
choose_caddy_extension ${libev_v2ray}
improt_package "tools" "caddy_install.sh"
install_caddy
elif [[ ${web_flag} = "2" ]]; then
improt_package "tools" "nginx_install.sh"
install_nginx
Expand Down Expand Up @@ -1059,11 +1047,7 @@ install_main(){
install_mos_tls_tunnel
if [[ ${web_flag} = "1" ]]; then
improt_package "tools" "caddy_install.sh"
if [[ ${domainType} = DNS-Only ]] && [[ ${isEnableWeb} = enable ]]; then
install_caddy
elif [[ ${domainType} = CDN ]] && [[ ${isEnableWeb} = enable ]]; then
install_caddy "tls.dns.cloudflare"
fi
install_caddy
elif [[ ${web_flag} = "2" ]]; then
improt_package "tools" "nginx_install.sh"
install_nginx
Expand Down
28 changes: 2 additions & 26 deletions templates/config_file_templates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,13 @@ ss_v2ray_ws_tls_web_config(){
EOF
}

caddy_config_none_cdn(){
caddy_config(){
cat > ${CADDY_CONF_FILE}<<-EOF
${domain}:443 {
gzip
log /var/log/caddy-access.log
errors /var/log/caddy-error.log
tls ${email} {
protocols tls1.3
}
tls ${cerPath} ${keyPath}
timeouts none
proxy ${path} localhost:${shadowsocksport} {
websocket
Expand Down Expand Up @@ -122,28 +120,6 @@ ss_v2ray_ws_tls_web_cdn_config(){
EOF
}

caddy_config_with_cdn(){
cat > ${CADDY_CONF_FILE}<<-EOF
${domain}:443 {
gzip
log /var/log/caddy-access.log
errors /var/log/caddy-error.log
tls {
dns cloudflare
protocols tls1.3
}
timeouts none
proxy ${path} localhost:${shadowsocksport} {
websocket
header_upstream -Origin
}
proxy / ${mirror_site} {
except ${path}
}
}
EOF
}

nginx_config(){
cat > /etc/nginx/nginx.conf<<-EOF
user nginx;
Expand Down
9 changes: 2 additions & 7 deletions utils/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,10 @@ update_caddy(){
exit 1
fi

if ! $(grep -q 'cloudflare' /usr/local/caddy/Caddyfile); then
libev_v2ray=4
else
libev_v2ray=5
fi

echo -e "${Info} 检测到caddy有新版本,开始下载并安装."
do_stop > /dev/null 2>&1
choose_caddy_extension ${libev_v2ray}
improt_package "tools" "caddy_install.sh"
install_caddy
do_restart > /dev/null 2>&1

echo -e "${Info} caddy已成功升级为最新版本${caddy_ver}"
Expand Down

0 comments on commit 83eeaaf

Please sign in to comment.