Найти в Дзене
IT, Python, Mikrotik, Linux

Продолжение, то же самое для Linux Ubuntu одним скриптом:

💬 Наш канал: 👉 proit_world #!/bin/bash LOG_FILE="/var/log/install_all.log" # Redirect stdout/stderr to both terminal and log file exec > >(tee -a "$LOG_FILE") 2>&1 echo "===== Script started at $(date) =====" # === Detect active user and Desktop path === ACTIVE_USER=$(logname) # Gets the user who launched the script DESKTOP_PATH="/home/$ACTIVE_USER/Desktop" # Create Desktop path if not exists (just in case) mkdir -p "$DESKTOP_PATH" # Prepare system info file name DATE_NOW=$(date +%Y-%m-%d) SYSINFO_FILE="${DESKTOP_PATH}/${ACTIVE_USER}_$(hostname)_${DATE_NOW}.txt" # --- Robust, locale-independent collectors --- IP_ADDR="$(hostname -I | awk '{print $1}')" OS_VER="$( if command -v lsb_release >/dev/null 2>&1; then lsb_release -d | cut -f2- else awk -F= '/^PRETTY_NAME=/{gsub(/"/,"");print $2}' /etc/os-release fi )" CPU_MODEL="$(awk -F: '/model name/ {gsub(/^ +/,"",$2); print $2; exit}' /proc/cpuinfo)" RAM_TOTAL="$(awk '/MemTotal/ {printf "%.1f GiB", $2/1024/1024}' /proc/meminfo)" D

💬 Наш канал: 👉 proit_world

#!/bin/bash

LOG_FILE="/var/log/install_all.log"

# Redirect stdout/stderr to both terminal and log file

exec > >(tee -a "$LOG_FILE") 2>&1

echo "===== Script started at $(date) ====="

# === Detect active user and Desktop path ===

ACTIVE_USER=$(logname) # Gets the user who launched the script

DESKTOP_PATH="/home/$ACTIVE_USER/Desktop"

# Create Desktop path if not exists (just in case)

mkdir -p "$DESKTOP_PATH"

# Prepare system info file name

DATE_NOW=$(date +%Y-%m-%d)

SYSINFO_FILE="${DESKTOP_PATH}/${ACTIVE_USER}_$(hostname)_${DATE_NOW}.txt"

# --- Robust, locale-independent collectors ---

IP_ADDR="$(hostname -I | awk '{print $1}')"

OS_VER="$(

if command -v lsb_release >/dev/null 2>&1; then

lsb_release -d | cut -f2-

else

awk -F= '/^PRETTY_NAME=/{gsub(/"/,"");print $2}' /etc/os-release

fi

)"

CPU_MODEL="$(awk -F: '/model name/ {gsub(/^ +/,"",$2); print $2; exit}' /proc/cpuinfo)"

RAM_TOTAL="$(awk '/MemTotal/ {printf "%.1f GiB", $2/1024/1024}' /proc/meminfo)"

DISK_SIZE_ROOT="$(df -h / | awk 'NR==2{print $2}')"

# Получаем размер всего диска sda

DISK_SIZE_SDA="$(

if command -v lsblk >/dev/null 2>&1; then

lsblk -bno SIZE /dev/sda 2>/dev/null | awk '{printf "%.1f GiB", $1/1024/1024/1024}'

else

echo "Unknown"

fi

)"

GPU_INFO="$(

if command -v nvidia-smi >/dev/null 2>&1; then

nvidia-smi --query-gpu=name --format=csv,noheader 2>/dev/null

elif command -v lspci >/dev/null 2>&1; then

LANG=C lspci -nn | grep -E "VGA|3D|Display" | awk '{

if (match($0,/\[([^\]]+)\]/,m)) {print m[1]}

else {sub(/^.*controller: /,""); print}

}'

elif command -v lshw >/dev/null 2>&1; then

lshw -C display 2>/dev/null | awk -F: '/product:/ {gsub(/^ +/,"",$2); print $2}'

elif command -v glxinfo >/dev/null 2>&1; then

glxinfo -B 2>/dev/null | awk -F: '/Device:/ {gsub(/^ +/,"",$2); print $2}'

else

echo Unknown

fi | paste -sd ', ' -

)"

{

echo "===== System Information ====="

echo "Hostname: $(hostname)"

echo "IP Address: $IP_ADDR"

echo "OS Version: $OS_VER"

echo "CPU: $CPU_MODEL"

echo "RAM: $RAM_TOTAL"

echo "Disk Size (/): $DISK_SIZE_ROOT"

echo "Disk Size (sda): $DISK_SIZE_SDA"

echo "GPU Model: $GPU_INFO"

echo "Date: $(date)"

echo "================================"

} > "$SYSINFO_FILE"

echo "System information saved to: $SYSINFO_FILE"

# === 2. Check if target IP is reachable ===

TARGET_IP="10.238.66.177"

echo "Checking availability of $TARGET_IP..."

if ! ping -c 2 -W 2 $TARGET_IP > /dev/null; then

echo "IP $TARGET_IP is not reachable. Script will exit."

echo "===== Script ended at $(date) ====="

exit 1

fi

echo "IP $TARGET_IP is reachable."

# === 3. Check if Kaspersky Agent and KESL are installed ===

echo "Checking for Kaspersky Agent..."

if dpkg -l | grep -q klnagent; then

echo "Kaspersky Agent is already installed."

AGENT_INSTALLED=true

else

echo "Kaspersky Agent is not installed."

AGENT_INSTALLED=false

fi

echo "Checking for Kaspersky Endpoint Security (KESL)..."

if dpkg -l | grep -q kesl; then

echo "KESL is already installed."

KESL_INSTALLED=true

else

echo "KESL is not installed."

KESL_INSTALLED=false

fi

# === 4. Install if not already installed ===

if [ "$KESL_INSTALLED" = false ]; then

if [ -f /home/arm_kesl_12.2_deb.sh ]; then

echo "Installing KESL..."

sudo bash /home/arm_kesl_12.2_deb.sh

else

echo "File /home/arm_kesl_12.2_deb.sh not found!"

fi

fi

if [ "$AGENT_INSTALLED" = false ]; then

if [ -f /home/arm_klnagent_12.2_deb.sh ]; then

echo "Installing Kaspersky Agent..."

sudo bash /home/arm_klnagent_12.2_deb.sh

else

echo "File /home/arm_klnagent_12.2_deb.sh not found!"

fi

fi

# === 5. Install certificates ===

CERT_DIR="/usr/local/share/ca-certificates"

echo "Installing certificates..."