v-delete-sys-mail-ssl 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. # info: delete sys vesta user ssl certificate
  3. # options: NONE
  4. #
  5. # The script disables user domain ssl synchronization
  6. #----------------------------------------------------------#
  7. # Variable & Function #
  8. #----------------------------------------------------------#
  9. # Includes
  10. source $VESTA/func/main.sh
  11. source $VESTA/conf/vesta.conf
  12. #----------------------------------------------------------#
  13. # Verifications #
  14. #----------------------------------------------------------#
  15. #----------------------------------------------------------#
  16. # Action #
  17. #----------------------------------------------------------#
  18. vst_crt="$VESTA/ssl/certificate.crt"
  19. vst_key="$VESTA/ssl/certificate.key"
  20. # Updating mail certificate
  21. case $MAIL_SYSTEM in
  22. exim) conf='/etc/exim/exim.conf';;
  23. exim4) conf='/etc/exim4/exim4.conf.template';;
  24. esac
  25. if [ -e "$conf" ]; then
  26. sed -e "s|^tls_certificate.*|tls_certificate = $vst_crt|" \
  27. -e "s|^tls_privatekey.*|tls_privatekey = $vst_key|" -i $conf
  28. fi
  29. # Updating imap certificate
  30. conf="/etc/dovecot/conf.d/10-ssl.conf"
  31. if [ ! -z "$IMAP_SYSTEM" ] && [ -e "$conf" ]; then
  32. sed -e "s|ssl_cert.*|ssl_cert = <$vst_crt|" \
  33. -e "s|ssl_key.*|ssl_key = <$vst_key|" -i $conf
  34. fi
  35. # Moving old certificates
  36. if [ -e "$VESTA/ssl/mail.crt" ]; then
  37. mv -f $VESTA/ssl/mail.crt $VESTA/ssl/mail.crt.old
  38. fi
  39. if [ -e "VESTA/ssl/mail.key" ]; then
  40. mv $VESTA/ssl/mail.key VESTA/ssl/mail.key.old
  41. fi
  42. # Updating vesta.conf value
  43. sed -i "/MAIL_CERTIFICATE=/ d" $VESTA/conf/vesta.conf
  44. #----------------------------------------------------------#
  45. # Vesta #
  46. #----------------------------------------------------------#
  47. # Restarting services
  48. if [ "$restart" != 'no' ]; then
  49. if [ ! -z "$MAIL_SYSTEM" ]; then
  50. $BIN/v-restart-service $MAIL_SYSTEM
  51. fi
  52. if [ ! -z "$IMAP_SYSTEM" ]; then
  53. $BIN/v-restart-service $IMAP_SYSTEM
  54. fi
  55. fi
  56. # Logging
  57. log_event "$OK" "$ARGUMENTS"
  58. exit