Просмотр исходного кода

hestia_module_variant_installed returns variant

Ernesto Nicolás Carrea 5 лет назад
Родитель
Сommit
bf4a7bc9bb

+ 1 - 1
bin/module/clamav/install.inc

@@ -57,7 +57,7 @@ hestia_module_clamav_install() {
     osal_kv_write $HESTIA_CONF_MODULES/antivirus.conf 'version' '1'
     osal_kv_write $HESTIA_CONF_MODULES/antivirus.conf 'service_name' $OSAL_SERVICE_CLAMAV
 
-    if hestia_module_variant_installed 'mta' 'exim'; then
+    if [[ $(hestia_module_variant_installed 'mta') == 'exim' ]]; then
         $BIN/hestia module clamav exim-integration enable
     fi
 }

+ 1 - 1
bin/module/clamav/remove.inc

@@ -16,7 +16,7 @@ hestia_module_clamav_remove() {
 
     echo "Removing antivirus (ClamAV) module..."
 
-    if hestia_module_variant_installed 'mta' 'exim'; then
+    if [[ $(hestia_module_variant_installed 'mta') == 'exim' ]]; then
         $BIN/hestia module clamav exim-integration disable
     fi
 

+ 2 - 2
bin/module/exim/install.inc

@@ -56,12 +56,12 @@ hestia_module_exim_install() {
     done
 
     # Setup ClamAv integration
-    if hestia_module_variant_installed 'antivirus' 'clamav'; then
+    if [[ $(hestia_module_variant_installed 'antivirus') == 'clamav' ]]; then
         $BIN/hestia module clamav exim-integration enable
     fi
 
     # Setup SpamAssassin integration
-    if hestia_module_variant_installed 'antispam' 'spamassassin'; then
+    if [[ $(hestia_module_variant_installed 'antispam') == 'spamassassin' ]]; then
         $BIN/hestia module spamassassin exim-integration enable
     fi
 }

+ 2 - 6
bin/module/func.inc

@@ -21,14 +21,10 @@ hestia_module_getvariant() {
 # Tests if a specific variant of a module is installed,
 # exits successfully if it does.
 hestia_module_variant_installed() {
-    local module_installed=$(hestia_module_isinstalled $1 && echo 1)
-    if [ "$module_installed" ]; then
+    if hestia_module_isinstalled $1; then
         local module_variant=$(hestia_module_getvariant $1)
-        if [ "$module_variant" = "$2" ]; then
-            return 0
-        fi
+        echo $module_variant
     fi
-    return 1
 }
 
 # Schedules a service restart (when doing multiple actions)

+ 12 - 5
bin/module/list.inc

@@ -3,12 +3,19 @@
 hestia_module_list() {
     source $HESTIA/bin/module/func.inc
 
-    for conf_file in $HESTIA_CONF_MODULES/*.conf; do
-        local mod_name=$(basename $conf_file .conf)
-        local mod_descr=$(osal_kv_read ${conf_file} 'description')
+    printf "%-16s %-12s %-4s %s\n" "Module" "Provides" "Inst" "Description"
+    for hmd in $HESTIA/data/modules/*.hmd; do
+        local mod_name=$(osal_kv_read $hmd 'name')
+        local mod_provides=$(osal_kv_read $hmd 'provides')
+        local mod_descr=$(osal_kv_read $hmd 'description')
 
-        if hestia_module_isinstalled $mod_name; then
-            echo "$mod_name: $mod_descr"
+        local mod_varinstalled=$(hestia_module_variant_installed $mod_provides)
+        if [ "$mod_varinstalled" == "$mod_name" ]; then
+            local mod_installed='Yes'
+        else
+            local mod_installed='No'
         fi
+
+        printf "%-16s %-12s %-4s %s\n" "$mod_name" "$mod_provides" "$mod_installed" "$mod_descr"
     done
 }

+ 7 - 2
bin/module/phpmyadmin/install.inc

@@ -8,8 +8,13 @@ hestia_module_phpmyadmin_install() {
         return 1
     fi
 
-    if [ -z "$WEB_SYSTEM" ] && [ ! "$param_force" ]; then
-        echo "phpMyAdmin needs a web server."
+    if ! hestia_module_isinstalled 'web' && [ ! "$param_force" ]; then
+        echo "phpMyAdmin needs a web server. Use 'hestia package install web-server'."
+        return 1
+    fi
+
+    if ! hestia_module_isinstalled 'php' && [ ! "$param_force" ]; then
+        echo "phpMyAdmin needs PHP. Use 'hestia module install php'."
         return 1
     fi
 

+ 1 - 1
bin/module/spamassassin/install.inc

@@ -41,7 +41,7 @@ hestia_module_spamassassin_install() {
     osal_kv_write $HESTIA_CONF_MODULES/antispam.conf 'version' '1'
     osal_kv_write $HESTIA_CONF_MODULES/antispam.conf 'service_name' $OSAL_SERVICE_SPAMASSASSIN
 
-    if hestia_module_variant_installed 'mta' 'exim'; then
+    if [[ $(hestia_module_variant_installed 'mta') == 'exim' ]]; then
         $BIN/hestia module spamassassin exim-integration enable
     fi
 }

+ 1 - 1
bin/module/spamassassin/remove.inc

@@ -16,7 +16,7 @@ hestia_module_spamassassin_remove() {
 
     echo "Removing antispam (SpamAssassin) module..."
 
-    if hestia_module_variant_installed 'mta' 'exim'; then
+    if [[ $(hestia_module_variant_installed 'mta') == 'exim' ]]; then
         $BIN/hestia module spamassassin exim-integration disable
     fi