v-delete-user-package 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. # info: delete user package
  3. # options: PACKAGE
  4. # labels: panel
  5. #
  6. # example: v-delete-user-package admin palegreen
  7. #
  8. # The function for deleting user package. It does not allow to delete package
  9. # if it is in use.
  10. #----------------------------------------------------------#
  11. # Variable&Function #
  12. #----------------------------------------------------------#
  13. # Argument definition
  14. package=$1
  15. # Includes
  16. source $HESTIA/func/main.sh
  17. source $HESTIA/conf/hestia.conf
  18. # Functions
  19. is_package_in_use() {
  20. check_package=$(grep "PACKAGE='$package'" $USER_DATA/*/user.conf)
  21. if [ ! -z "$check_package" ]; then
  22. echo "Error: package $package is in use"
  23. log_event "$E_INUSE" "$ARGUMENTS"
  24. exit $E_INUSE
  25. fi
  26. }
  27. #----------------------------------------------------------#
  28. # Verifications #
  29. #----------------------------------------------------------#
  30. check_args '1' "$#" 'PACKAGE'
  31. is_format_valid 'package'
  32. is_package_valid
  33. is_package_in_use
  34. # Perform verification if read-only mode is enabled
  35. check_hestia_demo_mode
  36. #----------------------------------------------------------#
  37. # Action #
  38. #----------------------------------------------------------#
  39. # Deleting user package
  40. rm -f $HESTIA/data/packages/$package.pkg
  41. #----------------------------------------------------------#
  42. # Hestia #
  43. #----------------------------------------------------------#
  44. log_history "deleted user package $package" '' 'admin'
  45. log_event "$OK" "$ARGUMENTS"
  46. exit