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