v-restart-proxy 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. # info: restart proxy server
  3. # options: NONE
  4. #
  5. # The function reloads proxy server configuration.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Includes
  10. source $VESTA/func/main.sh
  11. source $VESTA/conf/vesta.conf
  12. PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
  13. send_email_report() {
  14. email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
  15. email=$(echo "$email" | cut -f 2 -d "'")
  16. tmpfile=$(mktemp)
  17. subj="$(hostname): $PROXY_SYSTEM restart failed"
  18. service $PROXY_SYSTEM configtest >> $tmpfile 2>&1
  19. service $PROXY_SYSTEM restart >> $tmpfile 2>&1
  20. cat $tmpfile |$SENDMAIL -s "$subj" $email
  21. rm -f $tmpfile
  22. }
  23. #----------------------------------------------------------#
  24. # Action #
  25. #----------------------------------------------------------#
  26. # Exit
  27. if [ "$1" = "no" ]; then
  28. exit
  29. fi
  30. # Schedule restart
  31. if [ "$1" = 'scheduled' ]; then
  32. echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe
  33. exit
  34. fi
  35. if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then
  36. echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe
  37. exit
  38. fi
  39. if [ -z "$PROXY_SYSTEM" ] || [ "$PROXY_SYSTEM" = 'remote' ]; then
  40. exit
  41. fi
  42. # Restart system
  43. service $PROXY_SYSTEM restart >/dev/null 2>&1
  44. if [ $? -ne 0 ]; then
  45. send_email_report
  46. check_result $E_RESTART "$PROXY_SYSTEM restart failed"
  47. fi
  48. # Update restart queue
  49. if [ -e "$VESTA/data/queue/restart.pipe" ]; then
  50. sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe
  51. fi
  52. #----------------------------------------------------------#
  53. # Vesta #
  54. #----------------------------------------------------------#
  55. exit