v-copy-user-package 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. # info: duplicate existing package
  3. # options: PACKAGE NEW_PACKAGE
  4. # labels: hestia
  5. #
  6. # example: v-copy-user-package default new
  7. #
  8. # The function allows the user to duplicate an existing
  9. # package file to facilitate easier configuration.
  10. #----------------------------------------------------------#
  11. # Variable&Function #
  12. #----------------------------------------------------------#
  13. # Argument definition
  14. package=$1
  15. new_package=$2
  16. # Includes
  17. # shellcheck source=/usr/local/hestia/func/main.sh
  18. source $HESTIA/func/main.sh
  19. # shellcheck source=/usr/local/hestia/conf/hestia.conf
  20. source $HESTIA/conf/hestia.conf
  21. # Perform verification if read-only mode is enabled
  22. check_hestia_demo_mode
  23. #----------------------------------------------------------#
  24. # Action #
  25. #----------------------------------------------------------#
  26. if [ ! -z $1 ]; then
  27. if [ ! -f $HESTIA/data/packages/$package.pkg ]; then
  28. echo "Error: package does not exist."
  29. exit
  30. fi
  31. if [ ! -z $2 ]; then
  32. # Copy package
  33. cp -f $HESTIA/data/packages/$package.pkg $HESTIA/data/packages/$new_package.pkg
  34. # Don't leave the .sh file behind
  35. if [ ! -f $HESTIA/data/packages/$package.sh ]; then
  36. cp $HESTIA/data/packages/$package.sh $HESTIA/data/packages/$new_package.sh
  37. fi
  38. else
  39. echo "Error: new package name not specified."
  40. fi
  41. else
  42. echo "Error: package name not specified."
  43. fi
  44. #----------------------------------------------------------#
  45. # Hestia #
  46. #----------------------------------------------------------#
  47. $BIN/v-log-action "system" "Info" "System" "Package copied (Package: $package, New Package: $new_package)."
  48. log_event "$OK" "$ARGUMENTS"
  49. exit