v_add_ssl_certificate 1.4 KB

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