func.inc 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/sh
  2. HESTIA_CONF_MODULES=$HESTIA/conf/modules
  3. mkdir -p $HESTIA_CONF_MODULES
  4. # Returns 1 if module is installed
  5. hestia_module_isinstalled() {
  6. osal_kv_read_bool $HESTIA_CONF_MODULES/${1}.conf 'installed'
  7. }
  8. # Returns 1 if module is installed and enabled
  9. hestia_module_isenabled() {
  10. is_installed=$(osal_kv_read_bool $HESTIA_CONF_MODULES/${1}.conf 'installed')
  11. is_enabled=$(osal_kv_read_bool $HESTIA_CONF_MODULES/${1}.conf 'enabled')
  12. if [ "$is_installed" ] && [ "$is_enabled" ]; then
  13. echo 1
  14. fi
  15. }
  16. hestia_module_getversion() {
  17. osal_kv_read $HESTIA_CONF_MODULES/${1}.conf 'version'
  18. }
  19. hestia_module_getvariant() {
  20. osal_kv_read $HESTIA_CONF_MODULES/${1}.conf 'variant'
  21. }
  22. hestia_module_variant_installed() {
  23. module_installed=$(hestia_module_isinstalled $1)
  24. if [ "$module_installed" ]; then
  25. module_variant=$(hestia_module_getvariant $1)
  26. if [ "$module_variant" = "$2" ]; then
  27. echo 1
  28. fi
  29. fi
  30. }
  31. # Backup config files (usually prior to module install)
  32. # hestia_config_backup 'prefix' file1 file2 file3 ...
  33. hestia_config_backup() {
  34. dest=$HESTIA/data/backup/
  35. filename=${1}-$(date +%Y%m%d%H%M%S)
  36. shift
  37. mkdir -p $dest
  38. tar -zc --warning=none --ignore-failed-read -f $dest/${filename}.tar.gz $@ > /dev/null 2>&1
  39. }