修改nginx和增加了acme的调用
This commit is contained in:
parent
95047371a8
commit
0f0a8edc6c
@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
declare domain_str=$2
|
||||
|
||||
if ! command -v socat &> /dev/null; then
|
||||
if [[ -f "/usr/bin/apt-get" ]];then
|
||||
apt-get update -y
|
||||
@ -29,7 +31,8 @@ if [[ ! -f "${HOME}/.acme.sh/acme.sh" ]];then
|
||||
curl https://get.acme.sh | sh -s "email=$mail"
|
||||
fi
|
||||
|
||||
declare domain_str=''
|
||||
|
||||
if [[ $domain_str ]];then
|
||||
echo "请输入需要申请SSL证书的域名"
|
||||
while(true);do
|
||||
read -p "不输入退出添加:" domain
|
||||
@ -46,6 +49,7 @@ if [[ -z $domain_str ]]; then
|
||||
echo "需要添加的域名不能为空"
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
declare pick_mode
|
||||
echo "1.http验证"
|
||||
@ -57,6 +61,17 @@ case $pick_mode in
|
||||
declare mode
|
||||
if command -v nginx &> /dev/null; then
|
||||
mode="nginx"
|
||||
cat > "/etc/nginx/conf.d/test" << EOF
|
||||
server {
|
||||
listen 80; # 监听80端口
|
||||
server_name ${domain}; # 服务器名称(本地)
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html; # 指定根目录
|
||||
index index.html index.htm; # 默认页面
|
||||
}
|
||||
}
|
||||
EOF
|
||||
elif command -v apache &> /dev/null; then
|
||||
mode="apache"
|
||||
else
|
||||
@ -65,6 +80,7 @@ case $pick_mode in
|
||||
echo "请到服务器将80和443端口开启,将域名解析到本机"
|
||||
read -p "解析完成请回车:"
|
||||
eval "${HOME}/.acme.sh/acme.sh --issue ${domain_str} --${mode}"
|
||||
rm /etc/nginx/conf.d/test
|
||||
;;
|
||||
'2')
|
||||
declare pick=0
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
declare path_script=$1
|
||||
|
||||
if ! command -v nginx &> /dev/null; then
|
||||
if [[ -f "/usr/bin/apt-get" ]];then
|
||||
apt-get update -y
|
||||
@ -32,6 +34,10 @@ case $pick in
|
||||
declare ssl_domain=$(echo "${domain}" | awk '{print $1}')
|
||||
|
||||
echo "ssl证书地址"
|
||||
echo "1.自动申请"
|
||||
echo "2.手动输入"
|
||||
read -p "请输入:" pick
|
||||
if [[ $pick == 2 ]]; then
|
||||
echo "证书,默认 ${HOME}/.acme.sh/${ssl_domain}_ecc/fullchain.cer"
|
||||
read -p "请输入证书地址:" ssl_certificate
|
||||
if [[ -z $ssl_certificate ]];then
|
||||
@ -43,6 +49,20 @@ case $pick in
|
||||
if [[ -z $ssl_certificate_key ]];then
|
||||
ssl_certificate_key="${HOME}/.acme.sh/${ssl_domain}_ecc/${ssl_domain}.key"
|
||||
fi
|
||||
else
|
||||
declare ssl_domain=""
|
||||
for i in ${domain} ; do
|
||||
if ! [[ $i =~ [\w\.]+ ]]; then
|
||||
echo "域名输入错误"
|
||||
exit
|
||||
fi
|
||||
ssl_domain="${ssl_domain} -d ${i}"
|
||||
done
|
||||
bash "${path_script}/Config/Web/acme.sh"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
declare name
|
||||
read -p "请输入配置文件名,默认为域名:" name
|
||||
if [[ -z $name ]]; then
|
||||
@ -54,7 +74,6 @@ case $pick in
|
||||
echo "2.静态文件"
|
||||
read -p "请选择:" pick
|
||||
declare path
|
||||
declare mode_pick
|
||||
if [[ $pick == 2 ]]; then
|
||||
read -p "请输入要代理的站点路径" path
|
||||
cat > "/etc/nginx/sites-available/${name}.conf" << EOF
|
||||
@ -174,7 +193,7 @@ server {
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
ln -s "/etc/nginx/sites-available/${name}.conf" "/etc/nginx/sites-enabled"
|
||||
ln -s "/etc/nginx/sites-available/${name}.conf" "/etc/nginx/sites-enabled" &> /dev/null
|
||||
nginx -s reload &> /dev/null
|
||||
echo "配置完成"
|
||||
;;
|
||||
|
@ -17,5 +17,5 @@ echo "========Web========"
|
||||
read -p "请输入要使用的功能:" pick
|
||||
|
||||
if [[ "${pick}" =~ [1-${#print_array[*]}] ]];then
|
||||
bash "${path_script}/Config/${file_name}/${print_array[${pick}]}.sh"
|
||||
bash "${path_script}/Config/${file_name}/${print_array[${pick}]}.sh" "${path_script}"
|
||||
fi
|
Loading…
Reference in New Issue
Block a user