Browse Source

osal_bool_tostring

Ernesto Nicolás Carrea 5 years ago
parent
commit
1f74e71ad5
3 changed files with 7 additions and 6 deletions
  1. 1 1
      bin/module/info.inc
  2. 2 2
      bin/module/php/list.inc
  3. 4 3
      func/osal.sh

+ 1 - 1
bin/module/info.inc

@@ -14,7 +14,7 @@ hestia_module_info() {
 
 
         echo "Installed       : yes"
         echo "Installed       : yes"
         echo "Description     : $(osal_kv_read $HESTIA_CONF_MODULES/${1}.conf 'description')"
         echo "Description     : $(osal_kv_read $HESTIA_CONF_MODULES/${1}.conf 'description')"
-        echo "Enabled         : $(osal_bool_yes $module_enabled)"
+        echo "Enabled         : $(osal_bool_tostring $module_enabled)"
         echo "Variant         : $module_variant"
         echo "Variant         : $module_variant"
         echo "Version         : $module_version"
         echo "Version         : $module_version"
     else
     else

+ 2 - 2
bin/module/php/list.inc

@@ -19,8 +19,8 @@ hestia_module_php_list() {
     echo "Present PHP (FPM) versions"
     echo "Present PHP (FPM) versions"
     for php_version in $PHP_SUPPORTED_VERSIONS; do
     for php_version in $PHP_SUPPORTED_VERSIONS; do
         php_withoutdot=${php_version//.}
         php_withoutdot=${php_version//.}
-        php_version_present=$(osal_kv_read_bool $HESTIA_CONF_MODULES/php.conf "php${php_withoutdot}_present")
-        echo PHP ${php_version}: $(osal_bool_yes $php_version_present 'present' 'not present')
+        php_version_present=$(osal_kv_read $HESTIA_CONF_MODULES/php.conf "php${php_withoutdot}_present" 0)
+        echo PHP ${php_version}: $(osal_bool_tostring $php_version_present 'present' 'not present')
     done
     done
 
 
     exit 0
     exit 0

+ 4 - 3
func/osal.sh

@@ -100,14 +100,15 @@ osal_kv_read_bool() {
     fi
     fi
 }
 }
 
 
-osal_bool_yes() {
+# answer=$(osal_bool_tostring boolean_value yes_value no_value)
+osal_bool_tostring() {
     if [ "${1,,}" == "yes" ] \
     if [ "${1,,}" == "yes" ] \
         || [ "${1,,}" == "true" ] \
         || [ "${1,,}" == "true" ] \
         || [ "${1,,}" == "on" ] \
         || [ "${1,,}" == "on" ] \
         || [ "$1" == "1" ]; then
         || [ "$1" == "1" ]; then
-        echo 'yes'
+        if [ -n "$2" ]; then echo "$2"; else echo 'yes'; fi
     else
     else
-        echo 'no'
+        if [ -n "$3" ]; then echo "$3"; else echo 'no'; fi
     fi
     fi
 }
 }