Ernesto Nicolás Carrea 5 лет назад
Родитель
Сommit
64dcc1b9cf
4 измененных файлов с 71 добавлено и 0 удалено
  1. 31 0
      bin/module/awstats/install.inc
  2. 32 0
      bin/module/awstats/remove.inc
  3. 4 0
      func/osal_debian_based.sh
  4. 4 0
      func/osal_rhel_based.sh

+ 31 - 0
bin/module/awstats/install.inc

@@ -0,0 +1,31 @@
+#!/bin/sh
+
+hestia_module_awstats_install() {
+    source $HESTIA/bin/module/func.inc
+
+    module_installed=$(hestia_module_isinstalled webstats)
+    if [ "$module_installed" ] && [ ! "$param_force" ]; then
+        echo "Stats module is already installed. See 'hestia module info webstats'."
+        exit 1
+    fi
+
+    echo "Installing web stats (Awstats) module..."
+
+
+    hestia_config_backup 'awstats-install' $OSAL_PATH_AWSTATS_CONF /etc/cron.d/awstats
+
+    osal_package_preinstall
+    osal_package_install $OSAL_PKG_AWSTATS
+
+    # Disable AWStats cron
+    rm -f /etc/cron.d/awstats
+
+    osal_kv_write $HESTIA/conf/hestia.conf 'STATS_SYSTEM' 'awstats'
+    osal_kv_write $HESTIA_CONF_MODULES/webstats.conf 'installed' '1'
+    osal_kv_write $HESTIA_CONF_MODULES/webstats.conf 'description' 'Hestia web stats (Awstats) module'
+    osal_kv_write $HESTIA_CONF_MODULES/webstats.conf 'enabled' '1'
+    osal_kv_write $HESTIA_CONF_MODULES/webstats.conf 'variant' 'awstats'
+    osal_kv_write $HESTIA_CONF_MODULES/webstats.conf 'version' '1'
+
+    exit 0
+}

+ 32 - 0
bin/module/awstats/remove.inc

@@ -0,0 +1,32 @@
+#!/bin/sh
+
+hestia_module_awstats_remove() {
+    source $HESTIA/bin/module/func.inc
+
+    module_installed=$(hestia_module_isinstalled webstats)
+    if [ ! "$module_installed" ] && [ ! "$param_force" ]; then
+        echo "Web stats module is not installed. See 'hestia module info webstats'."
+        exit 1
+    fi
+
+    module_variant=$(hestia_module_getvariant webstats)
+    if [ "$module_variant" != 'awstats' ] && [ ! "$param_force" ]; then
+        echo "The installed web stats module is not Awstats. See 'hestia module info webstats'."
+        exit 1
+    fi
+
+    echo "Removing web stats (Awstats) module..."
+
+    hestia_config_backup 'awstats-remove' $OSAL_PATH_AWSTATS_CONF
+    osal_package_remove $OSAL_PKG_AWSTATS
+    rm -rf $OSAL_PATH_AWSTATS_CONF
+
+    osal_kv_write $HESTIA/conf/hestia.conf 'WEBSTATS_SYSTEM' 'no'
+    osal_kv_write $HESTIA_CONF_MODULES/webstats.conf 'installed' '0'
+    osal_kv_write $HESTIA_CONF_MODULES/webstats.conf 'description' ''
+    osal_kv_write $HESTIA_CONF_MODULES/webstats.conf 'enabled' '0'
+    osal_kv_write $HESTIA_CONF_MODULES/webstats.conf 'variant' ''
+    osal_kv_write $HESTIA_CONF_MODULES/webstats.conf 'version' '0'
+
+    exit 0
+}

+ 4 - 0
func/osal_debian_based.sh

@@ -16,6 +16,10 @@ OSAL_PATH_APACHE_CONF_D=/etc/apache2/conf.d
 OSAL_PATH_APACHE_MODS_ENABLED=/etc/apache2/mods-enabled
 OSAL_PATH_APACHE_MODS_ENABLED=/etc/apache2/mods-enabled
 OSAL_PATH_APACHE_MODS_AVAILABLE=/etc/apache2/mods-available
 OSAL_PATH_APACHE_MODS_AVAILABLE=/etc/apache2/mods-available
 
 
+# Awstats
+OSAL_PKG_AWSTATS=awstats
+OSAL_PATH_AWSTATS_CONF=/etc/awstats
+
 # Bind
 # Bind
 OSAL_SERVICE_BIND=bind9
 OSAL_SERVICE_BIND=bind9
 OSAL_USER_BIND=bind
 OSAL_USER_BIND=bind

+ 4 - 0
func/osal_rhel_based.sh

@@ -15,6 +15,10 @@ OSAL_PATH_APACHE_CONF=/etc/httpd/conf
 OSAL_PATH_APACHE_CONF_D=/etc/httpd/conf.d
 OSAL_PATH_APACHE_CONF_D=/etc/httpd/conf.d
 OSAL_PATH_APACHE_MODS_ENABLED=/etc/httpd/conf.modules.d
 OSAL_PATH_APACHE_MODS_ENABLED=/etc/httpd/conf.modules.d
 
 
+# Awstats
+OSAL_PKG_AWSTATS=awstats
+OSAL_PATH_AWSTATS_CONF=/etc/awstats
+
 # Bind
 # Bind
 OSAL_SERVICE_BIND=named
 OSAL_SERVICE_BIND=named
 OSAL_USER_BIND=named
 OSAL_USER_BIND=named