v_add_ssl_certificate 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. # info: adding ssl certificate
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. user="$1"
  8. cert="$2"
  9. # Importing variables
  10. source $VESTA/conf/vars.conf
  11. source $V_FUNC/shared_func.sh
  12. source $V_FUNC/cert_func.sh
  13. #----------------------------------------------------------#
  14. # Verifications #
  15. #----------------------------------------------------------#
  16. # Checking arg number
  17. check_args '2' "$#" 'user certificate'
  18. # Checking argument format
  19. format_validation 'user' 'certificate'
  20. # Checking user
  21. is_user_valid
  22. # Checking user is active
  23. is_user_suspended
  24. # Checking certificate name
  25. is_cert_free
  26. # Checking template
  27. is_cert_valid "$V_TMP"
  28. #----------------------------------------------------------#
  29. # Action #
  30. #----------------------------------------------------------#
  31. # Adding certificate to user dir
  32. mv $V_TMP/$cert.crt $V_USERS/$user/cert/
  33. mv $V_TMP/$cert.key $V_USERS/$user/cert/
  34. #----------------------------------------------------------#
  35. # Vesta #
  36. #----------------------------------------------------------#
  37. # Logging
  38. log_history "$V_EVENT" "v_del_ssl_certificate $user $cert"
  39. log_event 'system' "$V_EVENT"
  40. exit $OK