func.inc 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 'prefix' file1 file2 file3 ...
  24. hestia_config_backup() {
  25. dest=$HESTIA/data/backup/
  26. filename=${1}-$(date +%Y%m%d%H%M%S)
  27. shift
  28. mkdir -p $dest
  29. tar -zc --warning=none --ignore-failed-read -f $dest/${filename}.tar.gz $@ > /dev/null 2>&1
  30. }