v-restart-proxy 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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/conf/vesta.conf
  11. source $VESTA/func/main.sh
  12. #----------------------------------------------------------#
  13. # Action #
  14. #----------------------------------------------------------#
  15. # Schedule restart
  16. if [ "$1" = 'scheduled' ]; then
  17. echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe
  18. exit
  19. fi
  20. if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then
  21. echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe
  22. exit
  23. fi
  24. # Restart system
  25. if [ ! -z "$PROXY_SYSTEM" ]; then
  26. /etc/init.d/$PROXY_SYSTEM reload >/dev/null 2>&1
  27. if [ $? -ne 0 ]; then
  28. /etc/init.d/$PROXY_SYSTEM restart >/dev/null 2>&1
  29. if [ $? -ne 0 ]; then
  30. if [ -e "$VESTA/web/inc/mail-wrapper.php" ]; then
  31. send_mail="$VESTA/web/inc/mail-wrapper.php"
  32. else
  33. send_mail=$(which mail)
  34. fi
  35. email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
  36. email=$(echo "$email" | cut -f 2 -d "'")
  37. tmpfile=$(mktemp)
  38. subj="$(hostname): $PROXY_SYSTEM restart failed"
  39. /etc/init.d/$PROXY_SYSTEM configtest >> $tmpfile 2>&1
  40. /etc/init.d/$PROXY_SYSTEM restart >> $tmpfile 2>&1
  41. cat $tmpfile | $send_mail -s "$subj" $email
  42. rm -f $tmpfile
  43. exit $E_RESTART
  44. fi
  45. fi
  46. fi
  47. # Update restart queue
  48. if [ -e "$VESTA/data/queue/restart.pipe" ]; then
  49. sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe
  50. fi
  51. #----------------------------------------------------------#
  52. # Vesta #
  53. #----------------------------------------------------------#
  54. exit