通过shell脚本分析部署nginx网络服务

read -p "fuwu: " service_name

if systemctl status $service_name &> /dev/null; then

echo "$service_name anzhengle"

else

echo "$service_name meiyouanzhuang"

dnf install nginx -y

fi

config_path="/www/$service_name.conf"

mkdir -p /var/www/$service_name

echo "your_html_content" > /var/www/$service_name/index.html

cat << EOF > $config_path

server {

listen 80;

root /var/www/$service_name;

server_name $service_name.example.com;

}

EOF

systemctl restart nginx

if systemctl is-active service_name \|\| \[ "(curl -sL http://$service_name.example.com)" ]; then

echo "$service_name chenggpngyunxing"

cat $config_path

else

echo "$service_name meiyouyunxing,kanpeizhi:"

cat $config_path

fi

if [ $? -eq 0 ]; then

echo "yifasong [email protected]."

echo "neirong:" >> email.txt

cat script.sh >> email.txt

echo "fujian: email.txt" | mail -s "Nginx wancheng" [email protected]

else

echo "youwenti:"

cat $config_path | mail -s "Nginx shibai" [email protected]

fi

相关推荐
xzkyd outpaper几秒前
HTTP的Keep-Alive是什么?TCP 的 Keepalive 和 HTTP 的 Keep-Alive 是一个东西吗?
网络·网络协议·http
Ac157ol2 分钟前
创建两个进程
linux·运维·网络
czhc114007566315 分钟前
网络2 IP与MAC IP地址
网络·tcp/ip·macos
怕冷的火焰(~杰)32 分钟前
虚拟列表react-virtualized使用(npm install react-virtualized)
前端·react.js
云之兕34 分钟前
Spring Boot 自动配置原理详解
java·前端·spring boot
好_快44 分钟前
Lodash源码阅读-baseSortedIndexBy
前端·javascript·源码阅读
好_快44 分钟前
Lodash源码阅读-sortedLastIndex
前端·javascript·源码阅读
好_快1 小时前
Lodash源码阅读-sortedIndexOf
前端·javascript·源码阅读
好_快1 小时前
Lodash源码阅读-sortedLastIndexOf
前端·javascript·源码阅读
好_快1 小时前
Lodash源码阅读-findLastIndex
前端·javascript·源码阅读