v-restart-ftp 1.7 KB

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