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 lxx1065372838@163.com."
echo "neirong:" >> email.txt
cat script.sh >> email.txt
echo "fujian: email.txt" | mail -s "Nginx wancheng" lxx1065372838@163.com
else
echo "youwenti:"
cat $config_path | mail -s "Nginx shibai" lxx1065372838@163.com
fi