final_check.sh 775 B

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. SERVER_IP="45.61.60.10"
  3. SERVER_USER="root"
  4. SERVER_PASS="UQb9TgSwC@vwhEM"
  5. /usr/bin/expect <<EOF
  6. set timeout 30
  7. spawn ssh -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP
  8. expect {
  9. "password:" { send "$SERVER_PASS\r" }
  10. "yes/no" { send "yes\r"; exp_continue }
  11. }
  12. expect "#"
  13. # 确保配置已移动
  14. send "if test -f /tmp/ccdw_full.conf && test -f /etc/letsencrypt/live/ccdw.xyz/fullchain.pem; then mv /tmp/ccdw_full.conf /etc/nginx/sites-available/ccdw.xyz.conf && ln -sf /etc/nginx/sites-available/ccdw.xyz.conf /etc/nginx/sites-enabled/ccdw.xyz.conf; fi\r"
  15. # 强制重启 Nginx
  16. send "systemctl restart nginx\r"
  17. # 验证
  18. send "echo '--- VALIDATION ---'\r"
  19. send "curl -I https://ccdw.xyz\r"
  20. send "curl -I http://ccdw.xyz\r"
  21. send "exit\r"
  22. expect eof
  23. EOF