Serghey Rodin 13 anni fa
parent
commit
fc80b0949a

+ 34 - 51
bin/v-list-sys-services

@@ -39,16 +39,15 @@ get_srv_state() {
         # Get pid date
         # Get pid date
         if [ ! -z $pid ] && [ -e "/proc/$pid/cmdline" ]; then
         if [ ! -z $pid ] && [ -e "/proc/$pid/cmdline" ]; then
             mtime=$(stat -c "%Y" /proc/$pid/cmdline)
             mtime=$(stat -c "%Y" /proc/$pid/cmdline)
-            ptime=$(date -d @$mtime +%T)
-            pdate=$(date -d @$mtime +%F)
+            rtime=$((ctime - mtime))
+            rtime=$((rtime  / 60))
         fi
         fi
     else
     else
         # Service is stopped
         # Service is stopped
         state='stopped'
         state='stopped'
         mem=0
         mem=0
         cpu=0
         cpu=0
-        ptime="$TIME"
-        pdate="$DATE"
+        rtime="0"
     fi
     fi
 }
 }
 
 
@@ -59,139 +58,123 @@ get_srv_state() {
 
 
 # Save current proccess list
 # Save current proccess list
 tmp_file=$(mktemp)
 tmp_file=$(mktemp)
-ps aux | awk '{print $2" "$3}' | cut -f 1 -d '.' > $tmp_file
+if [ "$format" = 'json' ]; then
+    ps aux | awk '{print $2" "$3}' | tr -d '.' > $tmp_file
+else
+    ps aux | awk '{print $2" "$3}' | cut -f 1 -d '.' > $tmp_file
+fi
+
+# Get current time
+ctime=$(date +%s)
 
 
 # Proxy
 # Proxy
 service=$PROXY_SYSTEM
 service=$PROXY_SYSTEM
-spnd='yes'
 if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
 if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
-    spnd='no'
     get_srv_state $service
     get_srv_state $service
+    str="NAME='$service' SYSTEM='reverse proxy' STATE='$state' CPU='$cpu'"
+    str="$str MEM='$mem' RTIME='$rtime'"
 fi
 fi
-str="NAME='$service' SYSTEM='proxy' STATE='$state' CPU='$cpu'"
-str="$str MEM='$mem' SUSPENDED='$spnd' TIME='$ptime' DATE='$pdate'"
 
 
 # Web
 # Web
 service=$WEB_SYSTEM
 service=$WEB_SYSTEM
-spnd='yes'
 if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
 if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
-    spnd='no'
     if [ "$service" == 'apache' ]; then
     if [ "$service" == 'apache' ]; then
         service='httpd'
         service='httpd'
     fi
     fi
     get_srv_state $service
     get_srv_state $service
+    str="$str\nNAME='$service' SYSTEM='web server' STATE='$state' CPU='$cpu'"
+    str="$str MEM='$mem' RTIME='$rtime'"
+
 fi
 fi
-str="$str\nNAME='$service' SYSTEM='web' STATE='$state' CPU='$cpu'"
-str="$str MEM='$mem' SUSPENDED='$spnd' TIME='$ptime' DATE='$pdate'"
 
 
 # DNS
 # DNS
 service=$DNS_SYSTEM
 service=$DNS_SYSTEM
-spnd='yes'
 if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
 if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
-    spnd='no'
     if [ "$service" == 'bind' ]; then
     if [ "$service" == 'bind' ]; then
         service='named'
         service='named'
     fi
     fi
     get_srv_state $service
     get_srv_state $service
+    str="$str\nNAME='$service' SYSTEM='dns server' STATE='$state' CPU='$cpu'"
+    str="$str MEM='$mem' RTIME='$rtime'"
 fi
 fi
-str="$str\nNAME='$service' SYSTEM='dns' STATE='$state' CPU='$cpu'"
-str="$str MEM='$mem' SUSPENDED='$spnd' TIME='$ptime' DATE='$pdate'"
 
 
 # MAIL
 # MAIL
 service=$MAIL_SYSTEM
 service=$MAIL_SYSTEM
-spnd='yes'
 if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
 if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
-    spnd='no'
     get_srv_state $service
     get_srv_state $service
+    str="$str\nNAME='$service' SYSTEM='mail server' STATE='$state' CPU='$cpu'"
+    str="$str MEM='$mem' RTIME='$rtime'"
 fi
 fi
-str="$str\nNAME='$service' SYSTEM='mail' STATE='$state' CPU='$cpu'"
-str="$str MEM='$mem' SUSPENDED='$spnd' TIME='$ptime' DATE='$pdate'"
 
 
 # IMAP
 # IMAP
 service=$IMAP_SYSTEM
 service=$IMAP_SYSTEM
-spnd='yes'
 if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
 if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
-    spnd='no'
     get_srv_state $service
     get_srv_state $service
+    str="$str\nNAME='$service' SYSTEM='pop/imap server' STATE='$state'"
+    str="$str CPU='$cpu' MEM='$mem' RTIME='$rtime'"
 fi
 fi
-str="$str\nNAME='$service' SYSTEM='imap' STATE='$state' CPU='$cpu'"
-str="$str MEM='$mem' SUSPENDED='$spnd' TIME='$ptime' DATE='$pdate'"
 
 
 # ANTIVIRUS
 # ANTIVIRUS
 service=$ANTIVIRUS_SYSTEM
 service=$ANTIVIRUS_SYSTEM
-spnd='yes'
 if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
 if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
-    spnd='no'
     if [ "$ANTIVIRUS_SYSTEM" = 'clamav' ]; then
     if [ "$ANTIVIRUS_SYSTEM" = 'clamav' ]; then
         service='clamd'
         service='clamd'
     fi
     fi
     get_srv_state $service
     get_srv_state $service
+    str="$str\nNAME='$service' SYSTEM='email antivirus' STATE='$state'"
+    str="$str CPU='$cpu' MEM='$mem' RTIME='$rtime'"
 fi
 fi
-str="$str\nNAME='$service' SYSTEM='antivirus' STATE='$state' CPU='$cpu'"
-str="$str MEM='$mem' SUSPENDED='$spnd' TIME='$ptime' DATE='$pdate'"
 
 
 # ANTISPAM
 # ANTISPAM
 service=$ANTISPAM_SYSTEM
 service=$ANTISPAM_SYSTEM
-spnd='yes'
 if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
 if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
-    spnd='no'
     get_srv_state $service spamd
     get_srv_state $service spamd
+    str="$str\nNAME='$service' SYSTEM='email antispam' STATE='$state'"
+    str="$str CPU='$cpu' MEM='$mem' RTIME='$rtime'"
 fi
 fi
-str="$str\nNAME='$service' SYSTEM='antispam' STATE='$state' CPU='$cpu'"
-str="$str MEM='$mem' SUSPENDED='$spnd' TIME='$ptime' DATE='$pdate'"
 
 
 # DB
 # DB
 service=$DB_SYSTEM
 service=$DB_SYSTEM
-spnd='yes'
 if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
 if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
-    spnd='no'
     for db in ${DB_SYSTEM//,/ }; do
     for db in ${DB_SYSTEM//,/ }; do
         service="$db"
         service="$db"
         if [ "$service" == 'mysql' ] && [ ! -e "/etc/init.d/$service" ]; then
         if [ "$service" == 'mysql' ] && [ ! -e "/etc/init.d/$service" ]; then
             service='mysqld'
             service='mysqld'
         fi
         fi
         get_srv_state $service
         get_srv_state $service
-        str="$str\nNAME='$service' SYSTEM='db' STATE='$state' CPU='$cpu'"
-        str="$str MEM='$mem' SUSPENDED='$spnd' TIME='$ptime' DATE='$pdate'"
+        str="$str\nNAME='$service' SYSTEM='database server' STATE='$state'"
+        str="$str CPU='$cpu' MEM='$mem' RTIME='$rtime'"
     done
     done
-else
-    str="$str\nNAME='$service' SYSTEM='db' STATE='$state' CPU='$cpu''"
-    str="$str MEM='$mem' SUSPENDED='$spnd' TIME='$ptime' DATE='$pdate'"
 fi
 fi
 
 
 # FTP
 # FTP
 service=$FTP_SYSTEM
 service=$FTP_SYSTEM
-spnd='yes'
 if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
 if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
-    spnd='no'
     get_srv_state $service
     get_srv_state $service
+    str="$str\nNAME='$service' SYSTEM='ftp server' STATE='$state' CPU='$cpu'"
+    str="$str MEM='$mem' RTIME='$rtime'"
 fi
 fi
-str="$str\nNAME='$service' SYSTEM='ftp' STATE='$state' CPU='$cpu'"
-str="$str MEM='$mem' SUSPENDED='$spnd' TIME='$ptime' DATE='$pdate'"
 
 
 # CRON
 # CRON
 service=$CRON_SYSTEM
 service=$CRON_SYSTEM
-spnd='yes'
 if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
 if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
-    spnd='no'
     get_srv_state $service
     get_srv_state $service
+    str="$str\nNAME='$service' SYSTEM='job scheduler' STATE='$state'"
+    str="$str CPU='$cpu' MEM='$mem' RTIME='$rtime'"
 fi
 fi
-str="$str\nNAME='$service' SYSTEM='ftp' STATE='$state' CPU='$cpu'"
-str="$str MEM='$mem' SUSPENDED='$spnd' TIME='$ptime' DATE='$pdate'"
 
 
 # Defining config
 # Defining config
-
 echo -e "$str" > $tmp_file
 echo -e "$str" > $tmp_file
 conf=$tmp_file
 conf=$tmp_file
 
 
 # Defining fileds to select
 # Defining fileds to select
-fields="\$NAME \$SYSTEM \$STATE \$CPU \$MEM \$SUSPENDED \$TIME \$DATE"
+fields="\$NAME \$SYSTEM \$STATE \$CPU \$MEM \$RTIME"
 
 
 # Listing services
 # Listing services
 case $format in 
 case $format in 
     json)   json_list ;;
     json)   json_list ;;
     plain)  nohead=1; shell_list ;;
     plain)  nohead=1; shell_list ;;
-    shell)  fields='$NAME $STATE $CPU $MEM $SUSPENDED $TIME $DATE'
+    shell)  fields='$NAME $STATE $CPU $MEM $RTIME'
             shell_list | column -t ;;
             shell_list | column -t ;;
     *)      check_args '1' '0' 'USER [FORMAT]'
     *)      check_args '1' '0' 'USER [FORMAT]'
 esac
 esac

+ 2 - 4
bin/v-restart-cron

@@ -12,7 +12,6 @@
 # Includes
 # Includes
 source $VESTA/conf/vesta.conf
 source $VESTA/conf/vesta.conf
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
-EVENT=${1-$EVENT}
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
@@ -21,11 +20,10 @@ EVENT=${1-$EVENT}
 
 
 # Parsing config / or just source config
 # Parsing config / or just source config
 if [ "$CRON_SYSTEM" = 'crond' ]; then
 if [ "$CRON_SYSTEM" = 'crond' ]; then
-    /etc/init.d/crond 'reload' &>/dev/null
+    /etc/init.d/crond 'reload' >/dev/null 2>&1
     if [ $? -ne 0 ]; then
     if [ $? -ne 0 ]; then
-        /etc/init.d/crond 'restart' &>/dev/null
+        /etc/init.d/crond 'restart' >/dev/null 2>&1
         if [ $? -ne 0 ]; then
         if [ $? -ne 0 ]; then
-            log_event "$E_RESTART" "$EVENT"
             exit $E_RESTART
             exit $E_RESTART
         fi
         fi
     fi
     fi

+ 3 - 4
bin/v-restart-dns

@@ -12,18 +12,17 @@
 # Includes
 # Includes
 source $VESTA/conf/vesta.conf
 source $VESTA/conf/vesta.conf
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
-EVENT=${1-$EVENT}
+
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                       Action                             #
 #                       Action                             #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
 if [ "$DNS_SYSTEM" = 'bind' ]; then
 if [ "$DNS_SYSTEM" = 'bind' ]; then
-    /etc/init.d/named reload &>/dev/null
+    /etc/init.d/named reload >/dev/null 2>&1
     if [ $? -ne 0 ]; then
     if [ $? -ne 0 ]; then
-        /etc/init.d/named restart &>/dev/null
+        /etc/init.d/named restart >/dev/null 2>&1
         if [ $? -ne 0 ]; then
         if [ $? -ne 0 ]; then
-            log_event "$E_RESTART" "$EVENT"
             exit $E_RESTART
             exit $E_RESTART
         fi
         fi
     fi
     fi

+ 3 - 4
bin/v-restart-mail

@@ -12,18 +12,17 @@
 # Includes
 # Includes
 source $VESTA/conf/vesta.conf
 source $VESTA/conf/vesta.conf
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
-EVENT=${1-$EVENT}
+
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                       Action                             #
 #                       Action                             #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
 if [ "$MAIL_SYSTEM" = 'exim' ]; then
 if [ "$MAIL_SYSTEM" = 'exim' ]; then
-    /etc/init.d/exim reload &>/dev/null
+    /etc/init.d/exim reload  >/dev/null 2>&1
     if [ $? -ne 0 ]; then
     if [ $? -ne 0 ]; then
-        /etc/init.d/exim restart &>/dev/null
+        /etc/init.d/exim restart >/dev/null 2>&1
         if [ $? -ne 0 ]; then
         if [ $? -ne 0 ]; then
-            log_event "$E_RESTART" "$EVENT"
             exit $E_RESTART
             exit $E_RESTART
         fi
         fi
     fi
     fi

+ 42 - 0
bin/v-restart-service

@@ -0,0 +1,42 @@
+#!/bin/bash
+# info: restart service
+# options: service
+#
+# The function restarts system service.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+service=$1
+
+# Includes
+source $VESTA/func/main.sh
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '1' "$#" 'SERVICE'
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+if [ -x "/etc/init.d/$service" ]; then
+    /etc/init.d/$service restart >/dev/null 2>&1
+    if [ $? -ne 0 ]; then
+        exit $E_RESTART
+    fi
+fi
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+exit

+ 9 - 13
bin/v-restart-web

@@ -1,8 +1,8 @@
 #!/bin/bash
 #!/bin/bash
-# info: restart dns service
+# info: restart web services
 # options: NONE
 # options: NONE
 #
 #
-# The function tells BIND service to reload dns zone files.
+# The function reloads web server configuration.
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
@@ -12,41 +12,37 @@
 # Includes
 # Includes
 source $VESTA/conf/vesta.conf
 source $VESTA/conf/vesta.conf
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
-EVENT=${1-$EVENT}
+
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                       Action                             #
 #                       Action                             #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
 if [ "$WEB_SYSTEM" = 'apache' ]; then
 if [ "$WEB_SYSTEM" = 'apache' ]; then
-    /etc/init.d/httpd status &>/dev/null
+    /etc/init.d/httpd status >/dev/null 2>&1
     if [ $? -eq 0 ]; then
     if [ $? -eq 0 ]; then
-        /etc/init.d/httpd graceful &>/dev/null
+        /etc/init.d/httpd graceful >/dev/null 2>&1
         if [ $? -ne 0 ]; then
         if [ $? -ne 0 ]; then
-            log_event "$E_RESTART" "$EVENT"
             exit $E_RESTART
             exit $E_RESTART
         fi
         fi
     else
     else
-        /etc/init.d/httpd start &>/dev/null
+        /etc/init.d/httpd start >/dev/null 2>&1
         if [ $? -ne 0 ]; then
         if [ $? -ne 0 ]; then
-            log_event "$E_RESTART" "$EVENT"
             exit $E_RESTART
             exit $E_RESTART
         fi
         fi
     fi
     fi
 fi
 fi
 
 
 if [ "$PROXY_SYSTEM" = 'nginx' ]; then
 if [ "$PROXY_SYSTEM" = 'nginx' ]; then
-    /etc/init.d/nginx status &>/dev/null
+    /etc/init.d/nginx status >/dev/null 2>&1
     if [ $? -eq 0 ]; then
     if [ $? -eq 0 ]; then
-        /etc/init.d/nginx reload &>/dev/null
+        /etc/init.d/nginx reload >/dev/null 2>&1
         if [ $? -ne 0 ]; then
         if [ $? -ne 0 ]; then
-            log_event "$E_RESTART" "$EVENT"
             exit $E_RESTART
             exit $E_RESTART
         fi
         fi
     else
     else
-        /etc/init.d/nginx start &>/dev/null
+        /etc/init.d/nginx start >/dev/null 2>&1
         if [ $? -ne 0 ]; then
         if [ $? -ne 0 ]; then
-            log_event "$E_RESTART" "$EVENT"
             exit $E_RESTART
             exit $E_RESTART
         fi
         fi
     fi
     fi

+ 42 - 0
bin/v-start-service

@@ -0,0 +1,42 @@
+#!/bin/bash
+# info: start service
+# options: service
+#
+# The function starts system service.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+service=$1
+
+# Includes
+source $VESTA/func/main.sh
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '1' "$#" 'SERVICE'
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+if [ -x "/etc/init.d/$service" ]; then
+    /etc/init.d/$service start >/dev/null 2>&1
+    if [ $? -ne 0 ]; then
+        exit $E_RESTART
+    fi
+fi
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+exit

+ 42 - 0
bin/v-stop-service

@@ -0,0 +1,42 @@
+#!/bin/bash
+# info: stop service
+# options: service
+#
+# The function stops system service.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+service=$1
+
+# Includes
+source $VESTA/func/main.sh
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '1' "$#" 'SERVICE'
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+if [ -x "/etc/init.d/$service" ]; then
+    /etc/init.d/$service stop >/dev/null 2>&1
+    if [ $? -ne 0 ]; then
+        exit $E_RESTART
+    fi
+fi
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+exit

+ 28 - 0
web/bulk/service/index.php

@@ -0,0 +1,28 @@
+<?php
+// Init
+error_reporting(NULL);
+ob_start();
+session_start();
+
+include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
+
+$service = $_POST['service'];
+$action = $_POST['action'];
+
+if ($_SESSION['user'] == 'admin') {
+    switch ($action) {
+        case 'stop': $cmd='v-stop-service';
+            break;
+        case 'start': $cmd='v-start-service';
+            break;
+        case 'restart': $cmd='v-restart-service';
+            break;
+        default: header("Location: /list/services/"); exit;
+    }
+    foreach ($service as $value) {
+        $value = escapeshellarg($value);
+        exec (VESTA_CMD.$cmd." ".$value, $output, $return_var);
+    }
+}
+
+header("Location: /list/services/");

BIN
web/images/start.png


BIN
web/images/stop.png


+ 21 - 3
web/inc/main.php

@@ -44,10 +44,28 @@ function top_panel($user, $TAB) {
 function humanize_time($usage) {
 function humanize_time($usage) {
     if ( $usage > 60 ) {
     if ( $usage > 60 ) {
         $usage = $usage / 60;
         $usage = $usage / 60;
-        $usage = number_format($usage, 2);
-        $usage = $usage." Hour.";
+        if ( $usage > 24 ) {
+             $usage = $usage / 24;
+            $usage = number_format($usage, 0);
+            if ( $usage == 1 ) {
+                $usage = $usage." day";
+            } else {
+                $usage = $usage." days";
+            }
+        } else {
+            $usage = number_format($usage, 0);
+            if ( $usage == 1 ) {
+                $usage = $usage." hour";
+            } else {
+                $usage = $usage." hours";
+            }
+        }
     } else {
     } else {
-        $usage = $usage." Min.";
+        if ( $usage == 1 ) {
+            $usage = $usage." minute";
+        } else {
+            $usage = $usage." minutes";
+        }
     }
     }
     return $usage;
     return $usage;
 }
 }

+ 3 - 3
web/js/events.js

@@ -60,7 +60,7 @@ VE.callbacks.click.do_suspend = function(evt, elm) {
      var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls');
      var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls');
      var url = $('input[name="suspend_url"]', ref).val();
      var url = $('input[name="suspend_url"]', ref).val();
      var dialog_elm = ref.find('.confirmation-text-suspention');
      var dialog_elm = ref.find('.confirmation-text-suspention');
-     VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm SUSPEND', url);
+     VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm action', url);
 }
 }
 
 
 /*
 /*
@@ -70,7 +70,7 @@ VE.callbacks.click.do_unsuspend = function(evt, elm) {
      var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls');
      var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls');
      var url = $('input[name="unsuspend_url"]', ref).val();
      var url = $('input[name="unsuspend_url"]', ref).val();
      var dialog_elm = ref.find('.confirmation-text-suspention');
      var dialog_elm = ref.find('.confirmation-text-suspention');
-     VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm UNSUSPEND', url);
+     VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm action', url);
 }
 }
 
 
 /*
 /*
@@ -80,7 +80,7 @@ VE.callbacks.click.do_delete = function(evt, elm) {
      var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls');
      var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls');
      var url = $('input[name="delete_url"]', ref).val();
      var url = $('input[name="delete_url"]', ref).val();
      var dialog_elm = ref.find('.confirmation-text-delete');
      var dialog_elm = ref.find('.confirmation-text-delete');
-     VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm DELETE', url);
+     VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm action', url);
 }
 }
 
 
 
 

+ 23 - 0
web/list/services/index.php

@@ -0,0 +1,23 @@
+<?php
+// Init
+error_reporting(NULL);
+session_start();
+$TAB = 'SERVICES';
+include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
+
+// Header
+include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
+
+// Panel
+top_panel($user,$TAB);
+
+// Data
+if ($_SESSION['user'] == 'admin') {
+    exec (VESTA_CMD."v-list-sys-services json", $output, $return_var);
+    $data = json_decode(implode('', $output), true);
+    unset($output);
+    include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/list_services.html');
+}
+
+// Footer
+include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');

+ 22 - 0
web/restart/service/index.php

@@ -0,0 +1,22 @@
+<?php
+// Init
+error_reporting(NULL);
+ob_start();
+session_start();
+include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
+
+if ($_SESSION['user'] == 'admin') {
+    if (!empty($_GET['srv'])) {
+        $v_service = escapeshellarg($_GET['srv']);
+        exec (VESTA_CMD."v-restart-service ".$v_service, $output, $return_var);
+    }
+    if ($return_var != 0) {
+        $error = implode('<br>', $output);
+        if (empty($error)) $error = 'Error: service '.$v_service.' restart failed';
+            $_SESSION['error_srv'] = $error;
+    }
+    unset($output);
+}
+
+header("Location: /list/services/");
+exit;

+ 22 - 0
web/start/service/index.php

@@ -0,0 +1,22 @@
+<?php
+// Init
+error_reporting(NULL);
+ob_start();
+session_start();
+include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
+
+if ($_SESSION['user'] == 'admin') {
+    if (!empty($_GET['srv'])) {
+        $v_service = escapeshellarg($_GET['srv']);
+        exec (VESTA_CMD."v-start-service ".$v_service, $output, $return_var);
+    }
+    if ($return_var != 0) {
+        $error = implode('<br>', $output);
+        if (empty($error)) $error = 'Error: service '.$v_service.' start failed';
+            $_SESSION['error_srv'] = $error;
+    }
+    unset($output);
+}
+
+header("Location: /list/services/");
+exit;

+ 22 - 0
web/stop/service/index.php

@@ -0,0 +1,22 @@
+<?php
+// Init
+error_reporting(NULL);
+ob_start();
+session_start();
+include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
+
+if ($_SESSION['user'] == 'admin') {
+    if (!empty($_GET['srv'])) {
+        $v_service = escapeshellarg($_GET['srv']);
+        exec (VESTA_CMD."v-stop-service ".$v_service, $output, $return_var);
+    }
+    if ($return_var != 0) {
+        $error = implode('<br>', $output);
+        if (empty($error)) $error = 'Error: service '.$v_service.' stop failed';
+            $_SESSION['error_srv'] = $error;
+    }
+    unset($output);
+}
+
+header("Location: /list/services/");
+exit;

+ 152 - 0
web/templates/admin/list_services.html

@@ -0,0 +1,152 @@
+
+                                <table class="sub-menu" style="background: white;">
+                                    <tr>
+                                        <td style="padding: 12px 0 8px 6px">
+                                            <div style="text-align: right; float: right;">
+                                                <form action="/search/" method="get" >
+                                                <input type="text" name="q" style="margin: 2px 2px 0px 0px; width: 250px; padding: 3px;" size="30">
+                                                <input type="submit" value="Search" class="button" style="font-size: 12px; height: 24px;">
+                                                </form>
+                                            </div>
+                                            <div style="float:left; padding-left: 0px;">
+                                                <form action="/bulk/service/" method="post" id="objects">
+                                                <a style="padding: 0 4px 0 12px" class="select-controls" href='javascript:checkedAll("objects");'> toggle all </a>
+                                                <select style="margin:0 2px 0 0px;" name="action">
+                                                    <option>apply to selected</option>
+                                                    <option>stop</option>
+                                                    <option>start</option>
+                                                    <option>restart</option>
+                                                </select>
+                                                <input type="submit" name="ok" value="›" class="button" style="width: 37px; font-size: 12px; height: 24px;">
+                                            </div>
+                                            <?php
+                                                if (!empty($_SESSION['error_srv'])) {
+                                            ?>
+                                            <div>
+                                                <script type="text/javascript">
+                                                    $(function() {
+                                                        $( "#dialog:ui-dialog" ).dialog( "destroy" );
+                                                        $( "#dialog-message" ).dialog({
+                                                            modal: true,
+                                                            buttons: {
+                                                                Ok: function() {
+                                                                    $( this ).dialog( "close" );
+                                                                }
+                                                            }
+                                                        });
+                                                    });
+                                                </script>
+                                                <div id="dialog-message" title="Error">
+                                                    <p><?php echo $_SESSION['error_srv'] ?></p>
+                                                </div>
+                                            </div>
+                                            <?php
+                                                    unset($_SESSION['error_srv']);
+                                                }
+                                            ?>
+                                        </td>
+                                    </tr>
+                                </table>
+                            </td>
+                        </tr>
+                    </table>
+
+                    <div id="vstobjects">
+                        <table class='data'>
+
+                           <?php
+                                foreach ($data as $key => $value) {
+                                    ++$i;
+                                    if ($data[$key]['STATE'] == 'running') {
+                                        $status = 'active';
+                                        $action = 'stop';
+                                    } else {
+                                        $status = 'suspended';
+                                        $action = 'start';
+                                    }
+
+                                    $cpu = $data[$key]['CPU'] / 10;
+                                    $cpu = number_format($cpu, 1);
+                                    if ($cpu == '0.0')  $cpu = 0;
+                                ?>
+
+                            <tr class="data-row">
+                                <td class="data-dotted" style="padding: 0px 10px 0px 0px" width="150">
+                                    <table class="data-col1">
+                                        <tr><td style="padding: 18 0 4 18;"><input type="checkbox" name="service[]" value="<?php echo $key ?>" ></td></tr>
+                                        <tr><td class="data-<?php echo $status ?>"><b><?php echo $data[$key]['STATE'] ?></b></td></tr>
+                                    </table>
+                                </td>
+                                <td class="data-dotted" width="830px" style="vertical-align:top;">
+                                    <table width="830px">
+                                        <tr>
+                                            <td></td>
+                                            <td class="data-controls" width="68px"><a href="/restart/service/?srv=<?php echo $key ?>"><img src="/images/reload.png" width="6px" height="7px"> restart</a></td>
+                                            <td class="data-controls" width="48px"><a href="/<?php echo $action ?>/service/?srv=<?php echo $key ?>"><img src="/images/<?php echo $action ?>.png" width="7px" height="7px"> <?php echo $action ?></a></td>
+                                        </tr>
+                                    </table>
+
+                                    <table class="data-col2" width="830px">
+                                        <tr>
+                                            <td colspan=4 class="domain" style="padding: 0 0 0 4px;">
+                                                <b><?php echo $key ?></b>
+                                            </td>
+                                        </tr>
+                                        <tr>
+                                            <td style="vertical-align:top;" width="200px">
+                                                <table>
+                                                    <tr>
+                                                        <td class="counter-name" style="padding: 2px 0 0 0">
+                                                            <?php echo $data[$key]['SYSTEM'] ?> 
+                                                        </td>
+                                                    </tr>
+                                                </table>
+                                            </td>
+                                            <td style="vertical-align:top;" width="150px">
+                                                <table>
+                                                    <tr>
+                                                        <td class="counter-name">
+                                                            CPU:
+                                                        </td>
+                                                        <td>
+                                                            <a class="counter-value"> <?php echo $cpu ?>%</a>
+                                                        </td>
+                                                    </tr>
+                                                </table>
+                                            </td>
+                                            <td style="vertical-align:top;" width="180px">
+                                                <table>
+                                                    <tr>
+                                                        <td class="counter-name">
+                                                            Memory:
+                                                        </td>
+                                                        <td>
+                                                            <a class="counter-value"><?php echo $data[$key]['MEM'] ?> mb</a>
+                                                        </td>
+                                                    </tr>
+                                                </table>
+                                            </td>
+                                            <td style="vertical-align:top;" >
+                                                <table>
+                                                    <tr>
+                                                        <td class="counter-name">
+                                                            Run Time:
+                                                        </td>
+                                                        <td>
+                                                            <a class="counter-value"><?php echo humanize_time($data[$key]['RTIME']) ?> </a>
+                                                        </td>
+                                                    </tr>
+                                                </table>
+                                            </td>
+                                        </tr>
+                                    </table>
+                                </td>
+                            </tr>
+
+                            <?php
+                                }
+                            ?> 
+                        </table>
+                        </form>
+
+                    </div>

+ 1 - 1
web/templates/header.html

@@ -311,7 +311,7 @@
             .data-suspended {
             .data-suspended {
                 font-size: 8pt;
                 font-size: 8pt;
                 letter-spacing: 0.1em;
                 letter-spacing: 0.1em;
-                color: #de6c5d;
+                color: #de5543;
                 padding: 0 0 13 18;
                 padding: 0 0 13 18;
             }
             }