v-delete-sys-theme 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/bash
  2. # info: removes a theme from the custom theme library
  3. # options: theme
  4. # labels: hestia
  5. #
  6. # example: v-delete-sys-theme dark
  7. #
  8. # The function removes a theme from the custom theme library.
  9. # Please note "default" theme can't be deleted due to dependencies for other themes
  10. #----------------------------------------------------------#
  11. # Variable&Function #
  12. #----------------------------------------------------------#
  13. # Argument definition
  14. theme=$1
  15. # Includes
  16. source $HESTIA/func/main.sh
  17. source $HESTIA/conf/hestia.conf
  18. #----------------------------------------------------------#
  19. # Verifications #
  20. #----------------------------------------------------------#
  21. # Perform verification if read-only mode is enabled
  22. check_hestia_demo_mode
  23. #----------------------------------------------------------#
  24. # Action #
  25. #----------------------------------------------------------#
  26. if [ -z "$theme" ]; then
  27. # Theme not specified, throw an error.
  28. echo "ERROR: No theme specified."
  29. exit 1
  30. else
  31. if [ -e $HESTIA_THEMES/$theme.css ]; then
  32. # Protect system themes from deletion
  33. # Users can use the terminal to work around this if really desired.
  34. echo "ERROR: Unable to delete system theme: $theme."
  35. exit 1
  36. fi
  37. if [ -e $HESTIA_THEMES_CUSTOM/$theme.css ]; then
  38. # Remove theme if it exists.
  39. echo "Deleting $theme..."
  40. rm -f $HESTIA_THEMES_CUSTOM/$theme.css > /dev/null 2&>1
  41. else
  42. # Theme doesn't exist, throw an error.
  43. echo "ERROR: Theme $theme does not exist."
  44. fi
  45. fi
  46. # Set default theme in configuration file if deleted theme was active
  47. if [ "$THEME" = "$theme" ]; then
  48. rm -f $HESTIA/web/css/active-theme.css
  49. $BIN/v-change-sys-config-value 'THEME' default
  50. fi
  51. #----------------------------------------------------------#
  52. # Hestia #
  53. #----------------------------------------------------------#
  54. exit