v-deactivate-vesta-license 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/bash
  2. # info: deactivate vesta license
  3. # options: MODULE LICENSE
  4. #
  5. # The function activates and register vesta license
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. module=$(echo $1 | tr '[:lower:]' '[:upper:]')
  11. license=$2
  12. # Importing system environment
  13. source /etc/profile
  14. # Includes
  15. source $VESTA/func/main.sh
  16. source $VESTA/conf/vesta.conf
  17. #----------------------------------------------------------#
  18. # Verifications #
  19. #----------------------------------------------------------#
  20. # Checking arg number
  21. check_args '2' "$#" 'MODULE LICENSE'
  22. #----------------------------------------------------------#
  23. # Action #
  24. #----------------------------------------------------------#
  25. # Activating license
  26. v_host='https://vestacp.com/checkout'
  27. answer=$(curl -s $v_host/cancel.php?licence_key=$license)
  28. check_result $? "cant' connect to vestacp.com " $E_CONNECT
  29. # Checking server answer
  30. if [[ "$answer" != '0' ]]; then
  31. echo "Error: $module license $license is invalid"
  32. exit $E_INVALID
  33. fi
  34. #----------------------------------------------------------#
  35. # Vesta #
  36. #----------------------------------------------------------#
  37. # Updating vesta.conf
  38. if [ ! -z "$(grep "${module}_KEY" $VESTA/conf/vesta.conf)" ]; then
  39. sed -i "s/${module}_KEY=.*/${module}_KEY=''/g" $VESTA/conf/vesta.conf
  40. fi
  41. # Deactivating sftpjail
  42. if [ "$module" = 'SFTPJAIL' ]; then
  43. setsid $BIN/v-delete-sys-sftp-jail 2>/dev/null
  44. fi
  45. # Logging
  46. log_event "$OK" "$ARGUMENTS"
  47. exit