v-delete-user-package 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. # info: delete user package
  3. # options: PACKAGE
  4. #
  5. # The function for deleting user package. It does not allow to delete pacakge
  6. # if it is in use.
  7. #----------------------------------------------------------#
  8. # Variable&Function #
  9. #----------------------------------------------------------#
  10. # Argument defenition
  11. package=$1
  12. # Includes
  13. source $VESTA/func/main.sh
  14. source $VESTA/conf/vesta.conf
  15. # Functions
  16. is_package_in_use() {
  17. check_package=$(grep "PACKAGE='$package'" $USER_DATA/*/user.conf)
  18. if [ ! -z "$check_package" ]; then
  19. echo "Error: package $package is in use"
  20. log_event "$E_INUSE" "$EVENT"
  21. exit $E_INUSE
  22. fi
  23. }
  24. #----------------------------------------------------------#
  25. # Verifications #
  26. #----------------------------------------------------------#
  27. check_args '1' "$#" 'PACKAGE'
  28. validate_format 'package'
  29. is_package_valid
  30. is_package_in_use
  31. #----------------------------------------------------------#
  32. # Action #
  33. #----------------------------------------------------------#
  34. # Deleting user package
  35. rm -f $VESTA/data/packages/$package.pkg
  36. #----------------------------------------------------------#
  37. # Vesta #
  38. #----------------------------------------------------------#
  39. log_history "deleted user package $package" '' 'admin'
  40. log_event "$OK" "$EVENT"
  41. exit