func.inc 926 B

123456789101112131415161718192021222324252627282930313233343536
  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. # Backup config files (usually prior to module install)
  23. hestia_config_backup() {
  24. dest=$HESTIA/data/backup/
  25. filename=${1}-$(date +%Y%m%d%H%M%S)
  26. shift
  27. mkdir -p $dest
  28. tar -zcf ${filename}.tar.gz $@
  29. }