Sfoglia il codice sorgente

changed simple mac to standart mac in some tables

root 3 mesi fa
parent
commit
fab03eb49b

+ 42 - 0
docs/databases/migrate2psql.sh

@@ -37,6 +37,44 @@ check_root() {
     fi
     fi
 }
 }
 
 
+start_if_exists() {
+    local service="$1"
+    if systemctl cat "$service.service" >/dev/null 2>&1; then
+        systemctl start "$service"
+        return 0
+    fi
+    return 1
+}
+
+stop_if_exists() {
+    local service="$1"
+    if systemctl cat "$service.service" >/dev/null 2>&1; then
+        systemctl stop "$service"
+        return 0
+    fi
+    return 1
+}
+    
+stop_eye() {
+    PHP_VERSION=$(php -v 2>/dev/null | head -n1 | grep -oP '\d+\.\d+' || echo "")
+    if [ -n "${PHP_VERSION}" ]; then
+        stop_if_exists php${PHP_VERSION}-fpm
+        fi
+    for svc in cron eye-statd dhcp-log stat-sync syslog-stat; do
+        stop_if_exists ${svc}
+        done
+}
+
+start_eye() {
+    PHP_VERSION=$(php -v 2>/dev/null | head -n1 | grep -oP '\d+\.\d+' || echo "")
+    if [ -n "${PHP_VERSION}" ]; then
+        start_if_exists php${PHP_VERSION}-fpm
+        fi
+    for svc in cron eye-statd dhcp-log stat-sync syslog-stat; do
+        start_if_exists ${svc}
+        done
+}
+
 # Detect distribution and package manager
 # Detect distribution and package manager
 detect_distro() {
 detect_distro() {
     if [[ -f /etc/os-release ]]; then
     if [[ -f /etc/os-release ]]; then
@@ -512,8 +550,12 @@ if [[ -z "$DB_NAME" || -z "$DB_USER" || -z "$DB_PASS" ]]; then
     exit 1
     exit 1
 fi
 fi
 
 
+stop_eye
+
 eye_migrate2pgsql
 eye_migrate2pgsql
 
 
+start_eye
+
 echo "Maybe need install:"
 echo "Maybe need install:"
 echo "\t AltLinux: apt-get install php8.2-pgsql php8.2-pdo_pgsql"
 echo "\t AltLinux: apt-get install php8.2-pgsql php8.2-pdo_pgsql"
 echo "\t Debian/Ubuntu: apt install php-pgsql"
 echo "\t Debian/Ubuntu: apt install php-pgsql"

+ 1 - 1
html/admin/logs/mac.php

@@ -5,7 +5,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/cidrfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/cidrfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datetimefilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datetimefilter.php");
 
 
-$f_mac = mac_simplify(getParam('mac', $page_url, ''));
+$f_mac = mac_dotted(getParam('mac', $page_url, ''));
 $_SESSION[$page_url]['mac'] = $f_mac;
 $_SESSION[$page_url]['mac'] = $f_mac;
 
 
 print_log_submenu($page_url);
 print_log_submenu($page_url);

+ 1 - 1
html/admin/logs/unknown.php

@@ -85,7 +85,7 @@ foreach ($maclog as $row) {
     print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
     print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
     print "<td class=\"data\">" . $row['device_name'] . "</td>\n";
     print "<td class=\"data\">" . $row['device_name'] . "</td>\n";
     print "<td class=\"data\">" . $row['port'] . "</td>\n";
     print "<td class=\"data\">" . $row['port'] . "</td>\n";
-    print "<td class=\"data\"><a href=/admin/logs/mac.php?mac=" . mac_simplify($row['mac']) . ">" . mac_dotted($row['mac']) . "</a></td>\n";
+    print "<td class=\"data\"><a href=/admin/logs/mac.php?mac=" . mac_dotted($row['mac']) . ">" . mac_dotted($row['mac']) . "</a></td>\n";
     print "<td class=\"data\">" . $row['ts'] . "</td>\n";
     print "<td class=\"data\">" . $row['ts'] . "</td>\n";
     print "</tr>\n";
     print "</tr>\n";
 }
 }

+ 41 - 4
install-eye.sh

@@ -37,6 +37,44 @@ check_root() {
     fi
     fi
 }
 }
 
 
+start_if_exists() {
+    local service="$1"
+    if systemctl cat "$service.service" >/dev/null 2>&1; then
+        systemctl start "$service"
+        return 0
+    fi
+    return 1
+}
+
+stop_if_exists() {
+    local service="$1"
+    if systemctl cat "$service.service" >/dev/null 2>&1; then
+        systemctl stop "$service"
+        return 0
+    fi
+    return 1
+}
+
+stop_eye() {
+    PHP_VERSION=$(php -v 2>/dev/null | head -n1 | grep -oP '\d+\.\d+' || echo "")
+    if [ -n "${PHP_VERSION}" ]; then
+        stop_if_exists php${PHP_VERSION}-fpm
+        fi
+    for svc in cron eye-statd dhcp-log stat-sync syslog-stat; do
+        stop_if_exists ${svc}
+        done
+}
+
+start_eye() {
+    PHP_VERSION=$(php -v 2>/dev/null | head -n1 | grep -oP '\d+\.\d+' || echo "")
+    if [ -n "${PHP_VERSION}" ]; then
+        start_if_exists php${PHP_VERSION}-fpm
+        fi
+    for svc in cron eye-statd dhcp-log stat-sync syslog-stat; do
+        start_if_exists ${svc}
+        done
+}
+
 # Detect distribution and package manager
 # Detect distribution and package manager
 detect_distro() {
 detect_distro() {
     if [[ -f /etc/os-release ]]; then
     if [[ -f /etc/os-release ]]; then
@@ -1737,15 +1775,14 @@ eye_upgrade() {
     echo -e "${GREEN}===========================================${NC}"
     echo -e "${GREEN}===========================================${NC}"
     echo ""
     echo ""
 
 
-    systemctl stop eye-statd dhcp-log stat-sync syslog-stat
+    stop_eye
 
 
     check_root
     check_root
     detect_distro
     detect_distro
 
 
     backup_current_installation || {
     backup_current_installation || {
         echo "CRITICAL: Backup failed. Aborting upgrade."
         echo "CRITICAL: Backup failed. Aborting upgrade."
-    
-    systemctl start eye-statd dhcp-log stat-sync syslog-stat
+        start_eye
         exit 1
         exit 1
     }
     }
 
 
@@ -1756,7 +1793,7 @@ eye_upgrade() {
 
 
     /opt/Eye/scripts/updates/upgrade.pl
     /opt/Eye/scripts/updates/upgrade.pl
 
 
-    systemctl start eye-statd dhcp-log stat-sync syslog-stat
+    start_eye
 
 
     show_final_upgrade
     show_final_upgrade
 }
 }

+ 2 - 2
scripts/fetch_new_arp.pl

@@ -495,7 +495,7 @@ foreach my $device (@device_list) {
                 my $unknown_rec;
                 my $unknown_rec;
                 $unknown_rec->{port_id} = $port_id;
                 $unknown_rec->{port_id} = $port_id;
                 $unknown_rec->{device_id} = $dev_id;
                 $unknown_rec->{device_id} = $dev_id;
-                $unknown_rec->{mac} = $simple_mac;
+                $unknown_rec->{mac} = mac_dotted($simple_mac);
                 insert_record($dbh, 'unknown_mac', $unknown_rec);
                 insert_record($dbh, 'unknown_mac', $unknown_rec);
             }
             }
         }
         }
@@ -514,7 +514,7 @@ foreach my $mac (keys %mac_history) {
     my $history_rec;
     my $history_rec;
     $history_rec->{device_id} = $h_dev_id;
     $history_rec->{device_id} = $h_dev_id;
     $history_rec->{port_id}   = $h_port_id;
     $history_rec->{port_id}   = $h_port_id;
-    $history_rec->{mac}       = $mac;
+    $history_rec->{mac}       = mac_dotted($mac);
     $history_rec->{ip}        = $h_ip if ($h_ip);
     $history_rec->{ip}        = $h_ip if ($h_ip);
     $history_rec->{auth_id}   = $h_auth_id;
     $history_rec->{auth_id}   = $h_auth_id;
     insert_record($dbh, 'mac_history', $history_rec);
     insert_record($dbh, 'mac_history', $history_rec);

+ 2 - 2
scripts/garbage.pl

@@ -252,7 +252,7 @@ $users_sql = "SELECT mac FROM user_auth WHERE deleted = 0";
 @users_auth = get_records_sql($dbh, $users_sql);
 @users_auth = get_records_sql($dbh, $users_sql);
 foreach my $row (@users_auth) {
 foreach my $row (@users_auth) {
     next if (!$row->{mac});
     next if (!$row->{mac});
-    do_sql($dbh, "DELETE FROM unknown_mac WHERE mac = ?", mac_simplify($row->{mac}));
+    do_sql($dbh, "DELETE FROM unknown_mac WHERE mac = ?", mac_dotted($row->{mac}));
 }
 }
 
 
 # Clean old detailed traffic records (based on global $history setting)
 # Clean old detailed traffic records (based on global $history setting)
@@ -327,7 +327,7 @@ my %auth_table;
 my @auth_full_list = get_records_sql($dbh, $auth_sql);
 my @auth_full_list = get_records_sql($dbh, $auth_sql);
 foreach my $auth (@auth_full_list) {
 foreach my $auth (@auth_full_list) {
     next if (!$auth);
     next if (!$auth);
-    my $auth_mac = mac_simplify($auth->{mac});
+    my $auth_mac = mac_dotted($auth->{mac});
     next if (exists $auth_table{$auth_mac});
     next if (exists $auth_table{$auth_mac});
     next if (!exists $connections{$auth->{id}});
     next if (!exists $connections{$auth->{id}});