]> Git [git.vados.ru] :: Repos - Mikrotiks/ros.vados.ru.git/commitdiff
Autocommit in repo: ros.vados.ru, generated by owner: root, in 04:54:02 12.03.2026.
authorvados-dev <192440777+vados-dev@users.noreply.github.com>
Thu, 12 Mar 2026 01:54:05 +0000 (04:54 +0300)
committervados-dev <192440777+vados-dev@users.noreply.github.com>
Thu, 12 Mar 2026 01:54:05 +0000 (04:54 +0300)
14 files changed:
Mikrotiks/.bin/bash-progress-indicator/LICENSE [deleted file]
Mikrotiks/.bin/bash-progress-indicator/README.md [deleted file]
Mikrotiks/.bin/bash-progress-indicator/main.sh [deleted file]
Mikrotiks/.bin/bash-progress-indicator/progress.sh [deleted file]
Mikrotiks/.bin/bash-progress-indicator/progress_advanced.sh [deleted file]
Mikrotiks/.bin/bash-progress-indicator/spinner.sh [deleted file]
Mikrotiks/.bin/logs [deleted symlink]
Mikrotiks/.bin/ros-conf/README.md [deleted file]
Mikrotiks/.bin/ros-conf/setup-ssh-keys.sh [deleted file]
Mikrotiks/.bin/ros-conf/sync-script.sh [deleted file]
Mikrotiks/.bin/ros-diff.sh [deleted file]
Mikrotiks/.bin/scripts/mktmpfs.rsc [deleted file]
Mikrotiks/.bin/test.sh [deleted file]
html/AM-GlobalFunc.rsc

diff --git a/Mikrotiks/.bin/bash-progress-indicator/LICENSE b/Mikrotiks/.bin/bash-progress-indicator/LICENSE
deleted file mode 100644 (file)
index 830c241..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2018 Leandro Nunes
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/Mikrotiks/.bin/bash-progress-indicator/README.md b/Mikrotiks/.bin/bash-progress-indicator/README.md
deleted file mode 100644 (file)
index 8bbeb1a..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-# bash-progress-indicator
-Pure Bash script progress indicators
-
-## Usage
-```
-chmod +x main.sh
-./main.sh {progress_indicator_type}
-```
-
-## progress_indicator_type
-#### progress
-![type_progress](https://user-images.githubusercontent.com/2450417/37887129-6a7fafec-3096-11e8-8bc0-7768e958119e.gif)
-
-#### progress_advanced
-![type_progress_advanced](https://user-images.githubusercontent.com/2450417/37887130-6ddce736-3096-11e8-9696-25b86becbce3.gif)
-
-#### spinner1
-![type_spinner1](https://user-images.githubusercontent.com/2450417/37887236-0e8ccf0c-3097-11e8-9c6d-c6f4fc60b712.gif)
-#### spinner2
-![type_spinner2](https://user-images.githubusercontent.com/2450417/37887241-12e1c814-3097-11e8-91b2-e43e96ff8cd0.gif)
-#### spinner3
-![type_spinner3](https://user-images.githubusercontent.com/2450417/37887242-13012e98-3097-11e8-80cb-ebca61da3109.gif)
-
-## I wrote an article about this technique [pt-br]
-[Medium - [Bash] Construindo indicador de progresso](https://medium.com/meninunes/bash-construindo-indicador-de-progresso-8de94c37683)
-
-## License
-[MIT License](LICENSE) © [Leandro Nunes](https://lnfnunes.com.br)
diff --git a/Mikrotiks/.bin/bash-progress-indicator/main.sh b/Mikrotiks/.bin/bash-progress-indicator/main.sh
deleted file mode 100644 (file)
index cf565e7..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/bash -e
-# shellcheck disable=SC1091
-
-declare -rx STEPS=(
-  'pre-install'
-  'install'
-  'post-install'
-)
-declare -rx CMDS=(
-  'sleep 10'
-  'sleep 10'
-  'sleep 10'
-)
-
-case $1 in
-  progress)
-    . 'progress.sh'
-    ;;
-  progress_advanced)
-    . 'progress_advanced.sh'
-    ;;
-  spinner*)
-    . 'spinner.sh'
-    ;;
-  *)
-    echo "Invalid option $1!"
-    exit 1
-esac
-
-start
diff --git a/Mikrotiks/.bin/bash-progress-indicator/progress.sh b/Mikrotiks/.bin/bash-progress-indicator/progress.sh
deleted file mode 100644 (file)
index b5ca26e..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash -e
-
-declare -rx BAR_SIZE="##########"
-declare -rx CLEAR_LINE="\\033[K"
-
-start() {
-  local MAX_STEPS=${#STEPS[@]}
-  local MAX_BAR_SIZE="${#BAR_SIZE}"
-
-  tput civis -- invisible
-
-  echo -ne "\\r[${BAR_SIZE:0:0}] 0 %$CLEAR_LINE"
-  for step in "${!STEPS[@]}"; do
-    ${CMDS[$step]}
-
-    perc=$(((step + 1) * 100 / MAX_STEPS))
-    percBar=$((perc * MAX_BAR_SIZE / 100))
-    echo -ne "\\r[${BAR_SIZE:0:percBar}] $perc %$CLEAR_LINE"
-  done
-  echo ""
-
-  tput cnorm -- normal
-}
diff --git a/Mikrotiks/.bin/bash-progress-indicator/progress_advanced.sh b/Mikrotiks/.bin/bash-progress-indicator/progress_advanced.sh
deleted file mode 100644 (file)
index ad4f151..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/bash -e
-
-start() {
-  local MAX_STEPS=${#STEPS[@]}
-  local BAR_SIZE="##########"
-  local MAX_BAR_SIZE="${#BAR_SIZE}"
-  local CLEAR_LINE="\\033[K"
-
-  tput civis -- invisible
-
-  for step in "${!STEPS[@]}"; do
-    perc=$((step * 100 / MAX_STEPS))
-    percBar=$((perc * MAX_BAR_SIZE / 100))
-    echo -ne "\\r- ${STEPS[step]} [ ]$CLEAR_LINE\\n"
-    echo -ne "\\r[${BAR_SIZE:0:percBar}] $perc %$CLEAR_LINE"
-
-    ${CMDS[$step]}
-
-    perc=$(((step + 1) * 100 / MAX_STEPS))
-    percBar=$((perc * MAX_BAR_SIZE / 100))
-    echo -ne "\\r\\033[1A- ${STEPS[step]} [✔]$CLEAR_LINE\\n"
-    echo -ne "\\r[${BAR_SIZE:0:percBar}] $perc %$CLEAR_LINE"
-  done
-  echo ""
-
-  tput cnorm -- normal
-}
diff --git a/Mikrotiks/.bin/bash-progress-indicator/spinner.sh b/Mikrotiks/.bin/bash-progress-indicator/spinner.sh
deleted file mode 100644 (file)
index b68cf89..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/bin/bash -e
-
-declare -x FRAME
-declare -x FRAME_INTERVAL
-
-set_spinner() {
-  case $1 in
-    spinner1)
-      FRAME=("⠋" "⠙" "⠹" "⠸" "⠼" "⠴" "⠦" "⠧" "⠇" "⠏")
-      FRAME_INTERVAL=0.1
-      ;;
-    spinner2)
-      FRAME=("-" "\\" "|" "/")
-      FRAME_INTERVAL=0.25
-      ;;
-    spinner3)
-      FRAME=("◐" "◓" "◑" "◒")
-      FRAME_INTERVAL=0.5
-      ;;
-    spinner4)
-      FRAME=(":(" ":|" ":)" ":D")
-      FRAME_INTERVAL=0.5
-      ;;
-    spinner5)
-      FRAME=("◇" "◈" "◆")
-      FRAME_INTERVAL=0.5
-      ;;
-    spinner6)
-      FRAME=("⚬" "⚭" "⚮" "⚯")
-      FRAME_INTERVAL=0.25
-      ;;
-    spinner7)
-      FRAME=("░" "▒" "▓" "█" "▓" "▒")
-      FRAME_INTERVAL=0.25
-      ;;
-    spinner8)
-      FRAME=("☉" "◎" "◉" "●" "◉")
-      FRAME_INTERVAL=0.1
-      ;;
-    spinner9)
-      FRAME=("❤" "♥" "♡")
-      FRAME_INTERVAL=0.15
-      ;;
-    spinner10)
-      FRAME=("✧" "☆" "★" "✪" "◌" "✲")
-      FRAME_INTERVAL=0.1
-      ;;
-    spinner11)
-      FRAME=("●" "◕" "☯" "◔" "◕")
-      FRAME_INTERVAL=0.25
-      ;;
-    *)
-      echo "No spinner is defined for $1"
-      exit 1
-  esac
-}
-
-start() {
-  local step=0
-
-#  tput civis -- invisible
-
-  while [ "$step" -lt "${#CMDS[@]}" ]; do
-    ${CMDS[$step]} & pid=$!
-
-    while ps -p $pid &>/dev/null; do
-      echo -ne "\\r[   ] ${STEPS[$step]} ..."
-
-      for k in "${!FRAME[@]}"; do
-        echo -ne "\\r[ ${FRAME[k]} ]"
-        sleep $FRAME_INTERVAL
-      done
-    done
-
-    echo -ne "\\r[ ✔ ] ${STEPS[$step]}\\n"
-    step=$((step + 1))
-  done
-
-#  tput cnorm -- normal
-}
-
-set_spinner "$1"
diff --git a/Mikrotiks/.bin/logs b/Mikrotiks/.bin/logs
deleted file mode 120000 (symlink)
index 927bfe5..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/var/log/Mikrotiks
\ No newline at end of file
diff --git a/Mikrotiks/.bin/ros-conf/README.md b/Mikrotiks/.bin/ros-conf/README.md
deleted file mode 100644 (file)
index 973a2a7..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-# RouterOS Configuration Scripts
-
-Personal RouterOS configuration scripts for home network management.
-
-## Overview
-
-This repository contains RouterOS scripts to configure and diagnose a MikroTik router. Configuration scripts set up router modes (routing, bridging, NAT, DHCP). Check scripts display router settings and diagnostics.
-
-## Quick Start
-
-### Running Scripts
-
-Run scripts on the router using forward slashes:
-
-```routeros
-/system script run config/firewall
-/system script run check/nat
-```
-
-## Network Configuration
-
-The `combo1` port is renamed to `combo1-WAN` for routing mode or `combo1-bridge` for switching mode. The `bridge` interface is used for the internal network.
-
-The WAN interface uses `192.168.200.2/24` with gateway `192.168.200.1`. The bridge interface uses `192.168.88.1/24` as the gateway for the internal network. DHCP serves addresses from `192.168.88.100-192.168.88.199`.
-
-## Hardware
-
-These scripts are tested on CRS106, a MikroTik switch/router.
-
-## Repository Structure
-
-```text
-routeros-config/
-├── scripts/
-│   ├── config/          # Configuration scripts
-│   ├── check/           # Diagnostic scripts
-│   └── README.md        # Format and syntax guidelines
-└── README.md            # This file
-```
-
-For format and syntax guidelines, see [scripts/README.md](scripts/README.md).
diff --git a/Mikrotiks/.bin/ros-conf/setup-ssh-keys.sh b/Mikrotiks/.bin/ros-conf/setup-ssh-keys.sh
deleted file mode 100644 (file)
index 6653373..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-# Setup SSH keys for RouterOS router
-
-ROUTER_IP="10.30.30.81"
-ROUTER_USER="mikro_bak"
-KEY_NAME=$ROUTER_USER"_rsa@"$ROUTER_IP
-KEY_PATH="$HOME/.ssh/$KEY_NAME"
-
-# Check/create .ssh directory
-if [ ! -d "$HOME/.ssh" ]; then
-    mkdir -p "$HOME/.ssh"
-    chmod 700 "$HOME/.ssh"
-fi
-
-# Generate SSH key if it doesn't exist
-if [ ! -f "$KEY_PATH" ]; then
-    ssh-keygen -t rsa -b 2048 -f "$KEY_PATH" -N "" -C "$ROUTER_USER@$ROUTER_IP"
-fi
-
-# Upload and import key on router
-scp "$KEY_PATH.pub" "$ROUTER_USER@$ROUTER_IP -p 2222":/
-ssh "$ROUTER_USER@$ROUTER_IP -p 2222" "/user ssh-keys import public-key-file=$KEY_NAME.pub user=$ROUTER_USER"
-
-# Verify key works
-if ! ssh -i "$KEY_PATH" -o PasswordAuthentication=no "$ROUTER_USER@$ROUTER_IP -p 2222" "/system identity print" >/dev/null 2>&1; then
-    echo "Error: SSH key authentication failed"
-    exit 1
-fi
diff --git a/Mikrotiks/.bin/ros-conf/sync-script.sh b/Mikrotiks/.bin/ros-conf/sync-script.sh
deleted file mode 100644 (file)
index ca4c1de..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-#!/bin/bash
-# Upload all scripts and sync to RouterOS
-
-ROUTER_IP="10.30.30.10"
-ROUTER_USER="mikro_bak"
-SSH_KEY="$HOME/.ssh/mikro_bak_rsa"
-RSC_FILE="import_scripts.rsc"
-
-# Require router-specific SSH key
-if [ ! -f "$SSH_KEY" ]; then
-    echo "Error: SSH key not found at $SSH_KEY"
-    echo "Run ./setup-ssh-keys.sh to generate the key"
-    exit 1
-fi
-
-SSH_OPTS="-i $SSH_KEY -o PasswordAuthentication=no"
-
-# Generate .rsc import file
-echo "Generating import file..."
-
-# Get git commit hash and dirty status
-GIT_HASH=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
-if [ -z "$(git status --porcelain 2>/dev/null)" ]; then
-    GIT_STATUS="$GIT_HASH"
-else
-    GIT_STATUS="$GIT_HASH-dirty"
-fi
-
-# Get current date with timezone offset
-GEN_DATE=$(date '+%Y-%m-%d %H:%M:%S %z')
-
-# Write header
-cat > "$RSC_FILE" << RSC_HEADER
-# RouterOS script import file
-# Generated by sync-script.sh
-# Date: $GEN_DATE
-# Git: $GIT_STATUS
-
-RSC_HEADER
-
-# Write header for creating scripts section
-printf ':put "=== Creating scripts ==="\n' >> "$RSC_FILE"
-printf '\n' >> "$RSC_FILE"
-
-# Create function for script creation
-printf ':global createScriptIfMissing do={\n' >> "$RSC_FILE"
-printf '    :if ([/system script print count-only where name=$scriptName] = 0) do={\n' >> "$RSC_FILE"
-printf '        :put ("Creating script: " . $scriptName);\n' >> "$RSC_FILE"
-printf '        /system script add name=$scriptName\n' >> "$RSC_FILE"
-printf '    }\n' >> "$RSC_FILE"
-printf '}\n\n' >> "$RSC_FILE"
-
-# Write all add commands first
-for SCRIPT_FILE in scripts/config/*.rsc scripts/check/*.rsc; do
-    if [ ! -f "$SCRIPT_FILE" ]; then
-        continue
-    fi
-    
-    SCRIPT_NAME=$(sed -n '1p' "$SCRIPT_FILE" | sed 's/^# //')
-    POLICY=$(sed -n '3p' "$SCRIPT_FILE" | sed -n 's/^# policy=\(.*\)/\1/p')
-    
-    if [ -z "$POLICY" ]; then
-        echo "Error: Missing policy in $SCRIPT_FILE (line 3 should be '# policy=read,write')"
-        exit 1
-    fi
-    
-    # Call function with script name
-    printf '$createScriptIfMissing scriptName="%s"\n' "$SCRIPT_NAME" >> "$RSC_FILE"
-done
-
-# Empty line between sections
-printf '\n' >> "$RSC_FILE"
-printf ':put ""\n' >> "$RSC_FILE"
-printf ':put "=== Updating scripts ==="\n' >> "$RSC_FILE"
-printf '\n' >> "$RSC_FILE"
-
-# Write all set commands
-for SCRIPT_FILE in scripts/config/*.rsc scripts/check/*.rsc; do
-    if [ ! -f "$SCRIPT_FILE" ]; then
-        continue
-    fi
-    
-    SCRIPT_NAME=$(sed -n '1p' "$SCRIPT_FILE" | sed 's/^# //')
-    COMMENT=$(sed -n '2p' "$SCRIPT_FILE" | sed 's/^# //')
-    POLICY=$(sed -n '3p' "$SCRIPT_FILE" | sed -n 's/^# policy=\(.*\)/\1/p')
-    
-    # Escape comment for RouterOS (escape quotes)
-    ESCAPED_COMMENT=$(echo "$COMMENT" | sed 's/"/\\"/g')
-    
-    # Read script content and escape for RouterOS .rsc format
-    # Loop through file line by line, escape special chars, join with \n
-    SCRIPT_CONTENT=""
-    while IFS= read -r line || [ -n "$line" ]; do
-        # Escape backslashes, dollar signs, and quotes
-        line=$(echo "$line" | sed 's/\\/\\\\/g' | sed 's/\$/\\$/g' | sed 's/"/\\"/g')
-        if [ -z "$SCRIPT_CONTENT" ]; then
-            SCRIPT_CONTENT="$line"
-        else
-            SCRIPT_CONTENT="$SCRIPT_CONTENT\\n$line"
-        fi
-    done < "$SCRIPT_FILE"
-    
-    # Write set command directly to file
-    printf ':put "Updating script: %s"; /system script set "%s" source="' "$SCRIPT_NAME" "$SCRIPT_NAME" >> "$RSC_FILE"
-    echo "$SCRIPT_CONTENT" | sed 's/\\n/\\n\\\n    /g' >> "$RSC_FILE"
-    printf '" comment="%s" policy=%s\n\n' "$ESCAPED_COMMENT" "$POLICY" >> "$RSC_FILE"
-done
-
-# Delete the helper function
-printf '\n:set createScriptIfMissing;\n' >> "$RSC_FILE"
-
-# Print all scripts (excluding source/contents)
-printf ':put ""\n:put "=== All system scripts ==="\n/system script print proplist=name,comment,owner,policy,dont-require-permissions,run-count,last-started,invalid\n' >> "$RSC_FILE"
-
-# Show generated .rsc file and ask for confirmation
-echo ""
-echo "=== Generated import file ($RSC_FILE) ==="
-head -20 "$RSC_FILE"
-echo "..."
-echo ""
-read -p "Upload and import this file? (y/N): " -n 1 -r
-echo
-if [[ ! $REPLY =~ ^[Yy]$ ]]; then
-    echo "Aborted"
-    rm -f "$RSC_FILE"
-    exit 1
-fi
-
-# Upload .rsc file
-echo "Uploading import file..."
-scp $SSH_OPTS "$RSC_FILE" "$ROUTER_USER@$ROUTER_IP":/
-
-# Import on router
-echo "Importing scripts..."
-ssh $SSH_OPTS "$ROUTER_USER@$ROUTER_IP" "/import file-name=$RSC_FILE"
-
-# Cleanup
-rm -f "$RSC_FILE"
-echo "Done!"
diff --git a/Mikrotiks/.bin/ros-diff.sh b/Mikrotiks/.bin/ros-diff.sh
deleted file mode 100755 (executable)
index a6b9f63..0000000
+++ /dev/null
@@ -1,665 +0,0 @@
-#!/bin/bash
-#set +e -u
-#o pipefail
-# Add to cron
-# crontab -e 
-#*/20 * * * * /var/www/ros.vados.ru/Mikrotiks/.bin/ros-diff.sh
-#set +eo pipefail
-#set -x
-#GEN_DATE=$(date '+%Y-%m-%d %H:%M:%S %z')
-#GEN_DATE_TIME=$(date '+%d.%m.%Y %T %Z')
-#
-#ASK_NEXT=true
-#ask_forNext() {
-#    local ask $1
-#    local item $2
-#    echo -n $ask
-#read item
-#case "$item" in
-#    y|Y) echo "Ввели «y», продолжаем..."
-#        ;;
-#    n|N) echo "Ввели «n», завершаем..."
-#       exit 0
-#        ;;
-#    *) echo "Ничего не ввели. Выполняем действие по умолчанию..."
-#        ;;
-#esac
-#}
-#${CMD_SSH} ${SSH_OPTS} ${SSHuser}@${SSHhost} system script run MkTmpfs;
-#
-#### Utils #############################################################################################
-CMD_FIND=$(which find)
-CMD_MV=$(which mv)
-CMD_GZ=$(which gzip)
-CMD_CHO=$(which chown)
-CMD_CHM=$(which chmod)
-CMD_MKD=$(which mkdir)" -p "
-CMD_RM=$(which rm)
-CMD_DATE=$(date +%Y%m%d_%H%M) # date in format YYYYMMDD_HHmm
-CMD_SSL=$(which openssl)
-CMD_SSH=$(which ssh)
-CMD_SCP=$(which scp)
-CMD_SFTP=$(which sftp)
-
-ScriptName=$(basename -- "$0")
-# HomeDir=$HOME
-HomeDir="/var/www/ros.vados.ru/Mikrotiks"
-HostsFile=${HomeDir}"/.config/.mikrotiks"
-BinDir=${HomeDir}"/.bin"
-GitDir=${HomeDir}"/backups"
-
-# Set SSH defaults:
-DEFAULT_SSH_PORT="22"
-DEFAULT_SSH_USER="admin"
-DEFAULT_CONNECT_ATTEMPTS=5
-DEFAULT_CONNECT_TIMEOUT=5
-DEFAULT_SSH_KEY=${HomeDir}"/.ssh/id_rsa"
-# Set default diff args:
-DEFAULT_DIFF_ARGS=("-I \"RouterOS\"")
-#
-# Set debug and log options:
-DEBUG_OUT=true
-SAVE_LOG=true
-# Set default LogFile:
-DEFAULT_LOG="/var/log/Mikrotiks/ros-diff.log"
-#
-# Default backup variables:
-DEFAULT_BIN_CRYPT=true
-DEFAULT_BINPWD="BinPwd123"
-DEFAULT_EXP_CRYPT=false
-DEFAULT_EXPPWD="ExpPwd321"
-
-# Handy tput commands:
-#tput bold - Bold effect    #'\033[1m'
-#tput rev - Display inverse colors
-#tput sgr0 - Reset everything    #'\033[0m'
-#tput setaf {CODE}- Set foreground color, see color {CODE} below
-#tput setab {CODE}- Set background color, see color {CODE} below
-# Colors:
-#0    Black
-#1    Red    #'\033[1;31m'
-#2    Green    #'\033[1;32m'
-#3    Yellow    #'\033[1;33m'
-#4    Blue    # '\033[1;34m'
-#5    Magenta    # '\033[1;35m'
-#6    Cyan    # '\033[1;36m'
-#7    White    # '\033[1;37m'
-if [ -t 1 ] && $DEBUG_OUT; then
-    reset=$(tput sgr0)
-    bold=$(tput bold)
-    red=$(tput setaf 1)
-    green=$(tput setaf 2)
-    yellow=$(tput setaf 3)
-    blue=$(tput setaf 4)
-    magenta=$(tput setaf 5)
-    cyan=$(tput setaf 6)
-    white=$(tput setaf 7)
-    toend=$(tput hpa $(tput cols))$(tput cub 6)
-else
-    reset='' bold='' red='' green='' yellow='' blue='' magenta='' cyan='' white='' toend=''
-fi
-
-info() {
-    echo -e "\n${blue}ℹ  $*${reset}"
-}
-success() {
-    echo -e "\n${green}✅  $*${reset}"
-}
-error() {
-    echo -e "\n${red}❌ $*${reset}" >&2
-}
-warning() {
-    echo -e "${yellow}⚠  $*${reset}" >&2
-}
-section() {
-    echo -e "\n${magenta}................[$(tput rev) $* ${reset}${magenta}]................${reset}\n"
-}
-
-FRAME=("⠋" "⠙" "⠹" "⠸" "⠼" "⠴" "⠦" "⠧" "⠇" "⠏")
-FRAME_INTERVAL=0.1
-
-start() {
-  local step=0
-  while [ "$step" -lt "${#CMDS[@]}" ]; do
-    ${CMDS[$step]} & pid=$!
-    while ps -p $pid &>/dev/null; do
-      echo -ne "\\r[   ] ${STEPS[$step]} ..."
-      for k in "${!FRAME[@]}"; do
-        echo -ne "\\r[ ${FRAME[k]} ]"
-        sleep $FRAME_INTERVAL
-      done
-    done
-    echo -ne "\\r[ ✔ ] ${STEPS[$step]}\\n"
-    step=$((step + 1))
-  done
-}
-#echo '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'
-spinner()
-{
-    local pid=$!
-    local delay=0.75
-    local spinstr='|/-\'
-    #'⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'
-    while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
-        local temp=${spinstr#?}
-        printf " [%c] " "${spinstr}"
-        local spinstr=$temp${spinstr%"$temp"}
-        sleep $delay
-        printf "\b\b\b\b\b\b"
-    done
-    printf "    \b\b\b\b"
-}
-
-save_log() {
-    local log="${DEFAULT_LOG}"
-    if [ -n "${LogFile}" ]; then
-        log="${LogFile}"
-    fi
-    if ${SAVE_LOG}; then
-        echo "$(date '+%b %d %T') - $*" >> ${log}
-        return 0
-    else
-        return 1
-    fi
-}
-
-get_connections_str() {
-    local opts
-    local log_msg
-    local host
-    local ssh_str
-    local scp_str
-
-# Require router-specific SSH key
-    if [ -n "$DEFAULT_SSH_KEY" ]; then
-        opts=("-i ${DEFAULT_SSH_KEY}" "-o PasswordAuthentication=no")
-    else
-    log_msg="- Error: SSH key not found at $DEFAULT_SSH_KEY\nRun ./setup-ssh-keys.sh to generate the key"
-        if [ -t 1 ] && ${DEBUG_OUT}; then
-            error "${RouterName} ${log_msg}"
-        fi
-    save_log "${log_msg}"
-    exit 1
-    fi
-#    if [ -n "$DEFAULT_CONNECT_ATTEMPTS" ]; then
-#        opts+=("-o ConnectionAttempts=${DEFAULT_CONNECT_ATTEMPTS}")
-#    fi
-#    if [ -n "$DEFAULT_CONNECT_TIMEOUT" ]; then
-#        opts+=("-o ConnectTimeout=${DEFAULT_CONNECT_TIMEOUT}")
-#    fi
-    #opts+=("-o PreferredAuthentications=publickey" "-o StrictHostKeyChecking=no" "-o UserKnownHostsFile=/dev/null" \
-    #"-o GlobalKnownHostsFile=/dev/null" "-o CheckHostIP=no")
-SSH_OPTS="${opts[*]}"
-
-# Require router host IP
-    if [ -n "${SSHhost}" ]; then
-        host="${SSHhost}"
-    else
-        log_msg="- Error! SSH Host not found. Exit 1."
-        if [ -t 1 ] && ${DEBUG_OUT}; then
-            error "${RouterName} ${log_msg}"
-        fi
-        save_log "${log_msg}"
-        exit 1
-    fi
-
-    ssh_str=("$CMD_SSH" "-2" "-4")    
-    scp_str=("${CMD_SCP}" "-2" "-4" "-B ${SSH_OPTS}")
-    
-    if [ -n "${SSHport}" ]; then
-        ssh_str+=("-p ${SSHport}")
-        scp_str+=("-P ${SSHport}")
-    else
-        ssh_str+=("-p ${DEFAULT_SSH_PORT}")
-        scp_str+=("-P ${DEFAULT_SSH_PORT}")
-    fi
-    
-    if [ -n "${SSHuser}" ]; then
-        ssh_str+=("-l ${SSHuser}")
-        scp_str+=("${SSHuser}@${host}")
-    else
-        ssh_str+=("-l ${DEFAULT_SSH_USER}")
-        scp_str+=("${DEFAULT_SSH_USER}@${host}")
-    fi
-
-    ssh_str+=("${host}")
-
-ssh_str+=("${SSH_OPTS}")
-SSH_STR="${ssh_str[*]}"
-SCP_STR="${scp_str[*]}"
-#SFTP_STR="${sftp_str[*]}"
-#SFTP_OPTS="-i ${DEFAULT_SSH_KEY} -o PasswordAuthentication=no -oPort=${SSHport}"
-}
-
-#>/dev/null 2>&1
-###############################
-# Backup listing 
-###############################
-# Get Names Addresses and Ports in $HostsFile
-#declare -rx STEPS=(
-#  'download'
-#  'check'
-#  'backup'
-#)
-#IFS=$'\n'
-run_ssh_cmd() {
-    local run="${1}"
-    warning "${run}"
-    if ${SSH_STR} ${run}; then
-        return 0
-    else
-        return 1
-    fi
-}
-
-download_config() {
-    local conf="${1}"
-    local log_msg
-
-    if ${SSH_STR} export >${conf}; then
-        log_msg="- Config download success!"
-        if [ -t 1 ] && $DEBUG_OUT; then
-            success "${RouterName} ${log_msg}"
-        fi
-        save_log "${log_msg}"
-        return 0
-    else
-        log_msg="- Config download ${conf} error! Exit Error 1."
-        if [ -t 1 ] && $DEBUG_OUT; then
-            error "${RouterName} ${log_msg}"
-        fi
-        save_log "${log_msg}"
-        exit 1
-    fi
-}
-
-compare_config() {
-    local config_file="${1}"
-    local precedent_file="${2}" 
-    local diff_file="${3}"
-    local diff_args=${DEFAULT_DIFF_ARGS}
-    local log_msg
-
-    diff ${diff_args} ${config_file} ${precedent_file} >${diff_file}
-    if [ "$?" -ne "0" ]; then
-        log_msg="- There is a difference! Create backup..."
-        if [ -t 1 ] && $DEBUG_OUT; then
-            section " CREATE BACKUP "
-            sleep 1
-            info "${RouterName} ${log_msg}"
-        fi
-        save_log "${log_msg}"
-        return 0
-    else
-        log_msg="- The files are identical. No backup is required."
-        if [ -t 1 ] && $DEBUG_OUT; then
-            section " START CLEANUP "
-            sleep 1
-            info "${RouterName} ${log_msg}"
-        fi
-        save_log "${log_msg}"
-        log_msg="- Remove ${diff_file} file."
-        if [ -t 1 ] && $DEBUG_OUT; then
-            info "${RouterName} ${log_msg}"
-        fi
-        save_log "${log_msg}"
-        ${CMD_RM} -f ${diff_file}
-        log_msg="- Remove ${config_file} file."
-        if [ -t 1 ] && $DEBUG_OUT; then
-            info "${RouterName} ${log_msg}"
-        fi
-        save_log "${log_msg}"
-        ${CMD_RM} -f ${config_file}
-
-        return 1
-    fi
-}
-
-check_directory() {
-    local chk_dir="${1}"
-    local log_msg
-
- if [[ -d ${chk_dir} && -r ${chk_dir} ]]
-  then
-   return 0
-  else
-    if $CMD_MKD ${chk_dir}; then
-        log_msg="- Direcory ${chk_dir} created."
-        if [ -t 1 ] && $DEBUG_OUT; then
-            success "${RouterName} ${log_msg}"
-        fi
-        save_log "${log_msg}"
-        return 0
-    else
-        log_msg="- Error create direcory ${chk_dir}! Exit 1."
-        if [ -t 1 ] && $DEBUG_OUT; then
-            error "${RouterName} ${log_msg}"
-        fi
-        save_log "${log_msg}"
-        exit 1
-    fi
-# This script must be run by a special user in his home directory.
-# Therefore, the following lines are not needed.
-#   $CMD_CHO root:root $dir
-#   $CMD_CHM 755 $ST_FULL
- fi
-}
-
-#${SSH_STR} /system script environment get [find name=BackupPassword] value;
-#exit 0
-backup_binary() {
-    local bin_name="${1}"
-    local crypt="${DEFAULT_BIN_CRYPT}"
-    local bin_pass="${DEFAULT_BINPWD}"
-    local log_msg
-    local crypt_str
-    #${SSH_STR} :put [/system script environment get [find name=BackupPassword] value];
-
-    if ${SSH_STR} /system/script environment find where name=BackupEncrypt && ${SSH_STR} /system/script environment find where name=BackupPassword; then
-        
-        bin_pass=${SSH_STR} /system/script/environment/get ([ /system/script/environment find name='BackupPassword' ]->value);
-        crypt_str="dont-encrypt=no password=${bin_pass}"
-        warning "${crypt_str}"
-    else
-        if [ -n ${crypt} ] && [ -n {passwd} ]; then
-            crypt_str="dont-encrypt=no password=${passwd}"
-        else
-            crypt_str="dont-encrypt=yes"
-        fi
-
-    fi
- #   if [ -n $]; then
-
-#    local BKPSTR="system backup save name=${bin_name} dont-encrypt=no password=$BKP_BINPWD"
-# T_BKPCLN="file remove [find name=$TGT_BKPNAME_BIN]"
-}
-
-readarray -t lines < $HostsFile
-#declare -r STEPS=($lines)
-#declare -r MAX_STEPS=${#lines[@]}
-#declare -r BAR_SIZE="##########"
-#declare -r MAX_BAR_SIZE=${#BAR_SIZE}
-
-for HR in "${lines[@]}"; do
-#  perc=$(((HR + 1) * 100 / MAX_STEPS))
-#  percBar=$((perc * MAX_BAR_SIZE / 100))
-# declare -rx CMDS=(
-#  "${CMD_SSH} ${SSH_OPTS} ${SSHuser}@${SSHhost} export >$current_config"
-#  'sleep 10'
-#  'sleep 1'
-#)
-while IFS=$' ' read -a HR ; do
-#|| [ -n "$HR" ]; do
-[[ -z ${HR[0]} ]] && continue
-
-DStamp=$(date '+%Y%m%d')
-DTStamp=$(date '+%Y%m%d%H%M%S')
-
-RouterName=${HR[0]}
-SSHhost=${HR[1]}
-SSHport=${HR[2]}
-SSHuser=${HR[3]}
-SSHpassword=${HR[4]}
-
-get_connections_str
-backup_binary "BinaryTest.backup"
-
-exit 0
-#warning "SSH_STR = ${SSH_STR}"
-#warning "SCP_STR = ${SCP_STR}"
-#exit 0
-
-BaseDir=${HomeDir}"/backups/${RouterName}/"
-TempDir=${BaseDir}"tmp/"
-HistoryDir=${BaseDir}"history/"
-LogFile="/var/log/Mikrotiks/${RouterName}.log"
-log_msg="undefined"
-
-log_msg="- Start backup script ${ScriptName} for ${RouterName}"
-if [ -t 1 ] && $DEBUG_OUT; then
-    info "${RouterName} ${log_msg}"
-    echo
-fi
-save_log "${log_msg}"
-
-log_msg="- Check and creatre services directories for ${RouterName} if not exsist..."
-if [ -t 1 ] && $DEBUG_OUT; then
-    section " CHECK DIRS "
-    info "${RouterName} ${log_msg}"
-fi
-save_log "${log_msg}"
-
-CheckDirs=("${BaseDir}" "${TempDir}" "${HistoryDir}")
-for dir in "${CheckDirs[@]}"; do
-(check_directory "${dir[@]}")
-done
-
-log_msg="All Directories for ${RouterName} was created sucessfully!"
-if [ -t 1 ] && $DEBUG_OUT; then
-    success "${log_msg}"
-fi
-save_log "- ${log_msg}"
-
-log_msg="Set variables for ${RouterName}..."
-if [ -t 1 ] && $DEBUG_OUT; then
-    info "${log_msg}"
-fi
-save_log "- ${log_msg}"
-
-precedent_config=${BaseDir}"Precedent-Config.rsc"
-current_config=${TempDir}"Config.rsc"
-diff_config=${TempDir}"Diff-Config.rsc"
-current_backup="Binary.backup"
-
-log_msg="Set variables for ${RouterName} success!"
-if [ -t 1 ] && $DEBUG_OUT; then
-    success "${log_msg}"
-fi
-save_log "- ${log_msg}"
-
-section " CHECK CONFIG "
-log_msg="- Download ${current_config} file to Temp Directory..."
-if [ -t 1 ] && $DEBUG_OUT; then
-    info "${RouterName} ${log_msg}"
-fi
-save_log "- ${log_msg}"
-
-download_config "${current_config}"
-
-log_msg="- Comparing with the previous config..."
-if [ -t 1 ] && $DEBUG_OUT; then
-    info "${RouterName} ${log_msg}"
-fi
-save_log "- ${log_msg}"
-
-if compare_config ${current_config} ${precedent_config} ${diff_config} ${RouterName} ${LogFile}; then
-    BackupDir=${BaseDir}"${DStamp}/"
-    ${CMD_MKD} ${BackupDir}
-
-    save_config=${BackupDir}"${DTStamp}-Config.rsc"
-    save_backup=${BackupDir}"${DTStamp}-Binary.backup"
-
-    log_msg="- Copy ${current_config} file to ${BackupDir} directory..."
-    if [ -t 1 ] && $DEBUG_OUT; then
-        info "${RouterName} ${log_msg}"
-    fi
-    save_log "- ${log_msg}"
-
-    cp ${current_config} ${save_config}
-
-    ${CMD_RM} -f ${precedent_config}
-
-    ${CMD_MV} -f ${current_config} ${precedent_config}
-
-    log_msg="- Copy configuration to ${BackupDir}/${save_config} and ${precedent_config} success."
-    if [ -t 1 ] && $DEBUG_OUT; then
-        success "${RouterName} ${log_msg}"
-    fi
-    save_log "- ${log_msg}"
-
-    log_msg="Create ${current_backup} file on ${RouterName}..."
-    if [ -t 1 ] && $DEBUG_OUT; then
-        info "${log_msg}"
-    fi
-    save_log "- ${log_msg}"
-#   if [ $? -eq 0 ]; then
-    if ${SSH_STR} system backup save name=${current_backup}; then
-        log_msg="Create binary backup ${current_backup} on ${RouterName} success."
-        if [ -t 1 ] && $DEBUG_OUT; then
-            success "${log_msg}"
-        fi
-        save_log "- ${log_msg}"
-
-        log_msg="- Start download ${current_backup} file to ${BackupDir}..."
-        if [ -t 1 ] && $DEBUG_OUT; then
-            info "${RouterName} ${log_msg}"
-        fi
-        save_log "- ${log_msg}"
-
-#       if ${SFTP_STR}:$current_backup; then
-        #   ${CMD_SFTP} ${SFTP_OPTS} ${SSHuser}@${SSHhost}:$current_backup
-        if ${SCP_STR}:/${current_backup} ${save_backup}; then
-            sleep 2
-            log_msg="- Binary Backup download complete!"
-            if [ -t 1 ] && $DEBUG_OUT; then
-                success "${RouterName} ${log_msg}"
-            fi
-            save_log "${log_msg}"
-        else
-            log_msg="- Error! Save binary backup on ${RoutrName} failed!"
-            if [ -t 1 ] && $DEBUG_OUT; then
-                error "${log_msg}"
-            fi
-            save_log "${log_msg}"
-        fi
-    else
-        log_msg="Error create binary backup ${current_backup} on ${RouterName}!"
-        if [ -t 1 ] && $DEBUG_OUT; then
-            error "${log_msg}"
-        fi
-        save_log "- ${log_msg}"
-    fi
-
-    log_msg="- Remove ${current_backup} file on ${RouterName}."
-    if [ -t 1 ] && $DEBUG_OUT; then
-        section "CLEANUP"
-        info "${log_msg}"
-    fi
-    save_log "- ${log_msg}"
-
-    if ${SSH_STR} /file remove ${current_backup}; then
-        log_msg="- Remove ${current_backup} file on ${RouterName} complete succesfully!"
-        if [ -t 1 ] && $DEBUG_OUT; then
-            success "${RouterName} ${log_msg}"
-        fi
-    save_log "${log_msg}"
-    else
-        log_msg="- Error Remove ${current_backup} file on ${RouterName}!"
-        if [ -t 1 ] && $DEBUG_OUT; then
-            error "${RouterName} ${log_msg}"
-        fi
-        save_log "${log_msg}"
-    fi
-
-    cd "${BaseDir}"
-
-    CurrentHistoryDir=${HistoryDir}"${DStamp}/"
-    ${CMD_MKD} -p ${CurrentHistoryDir}
-    diff_config_history=${CurrentHistoryDir}"${DTStamp}-Diff-Config.rsc"
-    log_msg="- Move ${diff_config} file to ${CurrentHistoryDir}."
-    if [ -t 1 ] && $DEBUG_OUT; then
-        info "${RouterName} ${log_msg}"
-    fi
-    save_log "${log_msg}"
-    
-    if ${CMD_MV} -f ${diff_config} ${diff_config_history}; then
-        log_msg="- Move ${diff_config} file to ${CurrentHistoryDir} complete succesfully!"
-        if [ -t 1 ] && $DEBUG_OUT; then
-            success "${RouterName} ${log_msg}"
-        fi
-        save_log "${log_msg}"
-    else
-        log_msg="- Error move ${diff_config} file to ${CurrentHistoryDir}!"
-        if [ -t 1 ] && $DEBUG_OUT; then
-            error "${RouterName} ${log_msg}"
-        fi
-        save_log "${log_msg}"
-    fi
-
-    log_msg="- Go to Git directory (${GitDir}), add backups files and commit him."
-    if [ -t 1 ] && $DEBUG_OUT; then
-        section " COMMIT "
-        info "${RouterName} ${log_msg}"
-    fi
-    save_log "${log_msg}"
-    cd "${GitDir}/"
-    git add .
-    log_msg="- Git add commit..."
-    if [ -t 1 ] && $DEBUG_OUT; then
-        info "${RouterName} ${log_msg}"
-    fi
-    save_log "${log_msg}"
-    if git commit -m "Backup for ${RouterName} sucessfully creatd at $(date '+%b %d %T')."; then
-        log_msg=" - Git add commit success."
-        if [ -t 1 ] && $DEBUG_OUT; then
-            success "${RouterName} ${log_msg}"
-        fi
-        save_log "${log_msg}"
-    else
-        log_msg="- Git add commit Error!"
-        if [ -t 1 ] && $DEBUG_OUT; then
-            error "${RouterName} ${log_msg}"
-        fi
-        save_log "${log_msg}"
-    fi
-    log_msg="- Git push commit..."
-    if [ -t 1 ] && $DEBUG_OUT; then
-        info "${RouterName} ${log_msg}"
-    fi
-    save_log "${log_msg}"
-    if git push origin main; then
-        log_msg=" - Git push commit success."
-        if [ -t 1 ] && $DEBUG_OUT; then
-            success "${RouterName} ${log_msg}"
-        fi
-        save_log "${log_msg}"
-    else
-        log_msg="- Git push commit Error!"
-        if [ -t 1 ] && $DEBUG_OUT; then
-            error "${RouterName} ${log_msg}"
-        fi
-        save_log "${log_msg}"
-    fi
-else
-    log_msg="- ${RouterName} backup complete!"
-    if [ -t 1 ] && $DEBUG_OUT; then
-        info "${RouterName} ${log_msg}"
-    fi
-        save_log "${log_msg}"
-fi
-
-log_msg="- Remove Temp directory."
-if [ -t 1 ] && $DEBUG_OUT; then
-    info "${RouterName} ${log_msg}"
-fi
-    save_log "${log_msg}"
-
-${CMD_RM} -d ${TempDir}
-log_msg="- backup complete!"
-if [ -t 1 ] && $DEBUG_OUT; then
-    success "${RouterName} ${log_msg}"
-fi
-save_log "${log_msg}"
-
-done <<<"$(echo -e $HR)"
-LogFile="${DEFAULT_LOG}"
-#  echo -ne "\\r[${BAR_SIZE:0:percBar}] $perc %"
-#echo "[] $perc %"
-done
-log_msg="All Done! Exit 0."
-if [ -t 1 ] && $DEBUG_OUT; then
-    section " DONE "
-    success "${log_msg}"
-fi
-save_log "${log_msg}"
-exit 0
diff --git a/Mikrotiks/.bin/scripts/mktmpfs.rsc b/Mikrotiks/.bin/scripts/mktmpfs.rsc
deleted file mode 100644 (file)
index dbe979c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-:global MkDir;
-:put [($MkDir /usb1/tmpfs)];
-:log warning ("\$MkDir = " . $MkDir . ".");
diff --git a/Mikrotiks/.bin/test.sh b/Mikrotiks/.bin/test.sh
deleted file mode 100644 (file)
index 67b9dd5..0000000
+++ /dev/null
@@ -1,237 +0,0 @@
-#!/bin/bash
-# Add to cron
-# crontab -e 
-#*/20 * * * * /var/www/ros.vados.ru/Mikrotiks/.bin/ros-diff.sh
-#set +eo pipefail
-#set -x
-#
-DEBUG_OUT=true
-if [ -t 1 ] && $DEBUG_OUT; then
-    reset='\033[0m'
-    bold=$(tput bold)
-    #'\033[1m'
-    red=$(tput setaf 7)$(tput setab 1)
-    #'\033[1;31m'
-    green=$(tput setaf 4)$(tput setab 7)$(tput bold)
-    #'\033[1;32m'
-    yellow='\033[1;33m'
-    blue='\033[1;34m'
-    magenta='\033[1;35m'
-    cyan='\033[1;36m'
-    white='\033[1;37m'
-else
-    reset='' bold='' red='' green='' yellow='' blue='' cyan='' magenta='' white=''
-fi
-
-info() {
-    if $DEBUG_OUT; then    
-    echo -e "${blue}ℹ $*${reset}"
-    fi    
-}
-success() {
-    if $DEBUG_OUT; then
-    echo -e "${bold}${green}✅ $*${reset}"
-    fi
-}
-error() {
-    if $DEBUG_OUT; then
-    echo -e "${red}❌ Error: $*${reset}" >&2
-    fi
-}
-warning() {
-    if $DEBUG_OUT; then
-    echo -e "${yellow}⚠ $*${reset}" >&2
-    fi
-}
-section() {
-    if $DEBUG_OUT; then
-    echo -e "\n${magenta}====$*====${reset}"
-    fi
-}
-toend=$(tput hpa $(tput cols))$(tput cub 6)
-toend_ok() {
-    if $DEBUG_OUT; then
-    echo -n "${toend}${white}[${green}OK${white}]"
-    fi
-}
-toend_error() {
-    if $DEBUG_OUT; then
-    echo -n "${toend}${white}[${red}ERROR${white}]"
-    fi
-}
-BR() {
-    if $DEBUG_OUT; then
-    echo -e "\n"
-    fi
-}
-
-error "error"
-success "success"
-exit 0
-
-# HomeDir=$HOME
-HomeDir="/var/www/ros.vados.ru/Mikrotiks"
-HostsFile=${HomeDir}"/.config/.mikrotiks"
-BinDir=${HomeDir}"/.bin"
-GitDir=${HomeDir}"/backups"
-
-SSH_KEY=${HomeDir}"/.ssh/id_rsa"
-# Require router-specific SSH key
-if [ ! -f "$SSH_KEY" ]; then
-    error "Error: SSH key not found at $SSH_KEY"
-    error "Run ./setup-ssh-keys.sh to generate the key"
-    exit 1
-fi
-
-###############################
-# Backup listing 
-###############################
-# Get Names Addresses and Ports in $HostsFile
-
-readarray -t lines < $HostsFile
-
-for HR in "${lines[@]}"; do
-while IFS=$' ' read -a HR ; do
-#|| [ -n "$HR" ]; do
-[[ -z ${HR[0]} ]] && continue
-
-#GEN_DATE=$(date '+%Y-%m-%d %H:%M:%S %z')
-GEN_DATE=$(date '+%d.%m.%Y')
-GEN_TIME=$(date '+%b %d %T')
-GEN_DATE_TIME=$(date '+%d.%m.%Y %T %Z')
-DStamp=$(date '+%Y%m%d')
-
-RouterName=${HR[0]}
-SSHhost=${HR[1]}
-SSHport=${HR[2]}
-SSHuser=${HR[3]}
-SSHpassword=${HR[4]}
-
-BaseDir=${HomeDir}"/backups/"${RouterName}
-TempDir=${BaseDir}"/tmp"
-HistoryDir=${BaseDir}"/history"
-LogFile="/var/log/Mikrotiks/"${RouterName}".log"
-
-SSH_OPTS="-i $SSH_KEY -o PasswordAuthentication=no -p ${SSHport}"
-SFTP_OPTS="-i $SSH_KEY -o PasswordAuthentication=no -oPort=${SSHport}"
-echo "${GEN_DATE_TIME} - Start backup script ${ARGV[0]} for ${RouterName}" >> ${LogFile}
-section "Create dirs"
-info "Create servise directories for ${RouterName}..."
-echo "${GEN_TIME} - Create services directories for ${RouterName}..." >> ${LogFile}
-mkdir -p ${BaseDir}
-mkdir -p ${TempDir}
-mkdir -p ${HistoryDir}
-echo "${GEN_TIME} - All Directories for ${RouterName} was created sucessfully!" >> ${LogFile}
-success "All directories for ${RouterName} was created sucessfully!"
-echo "${GEN_TIME} - Set variables for ${RouterName}..." >> ${LogFile}
-info "Set variables for ${RouterName}..."
-precedent_config=${BaseDir}"/Precedent-Config.rsc"
-current_config="Config.rsc"
-current_backup="Binary.backup"
-diff_config=${TempDir}"/Diff-Config.rsc"
-echo "${GEN_TIME} - Set variables for ${RouterName} success!" >> ${LogFile}
-success "Set variables for ${RouterName} success!"
-#ssh ${SSH_OPTS} ${SSHuser}@${SSHhost} system script run MkTmpfs;
-cd ${TempDir}
-section ""
-BR 
-section "Start checkout process"
-info "Download ${current_config} file to Temp Directory..."
-echo "${GEN_TIME} - Download ${current_config} file to ${TempDir}" >> ${LogFile}
-ssh ${SSH_OPTS} ${SSHuser}@${SSHhost} export >$current_config
-if [ $? -eq 0 ]; then
-echo
-toend_ok
-echo
-echo "${GEN_TIME} - Download complete!" >> ${LogFile}
-else
-echo
-toend_error
-echo
-echo "${GEN_TIME} - Download ${current_config} failed!" >> ${LogFile}
-exit 1
-fi
-info "Comparing with the previous config..."
-echo "${GEN_TIME} - Comparing with the previous config..." >> ${LogFile}
-diff -I "RouterOS" ${current_config} ${precedent_config} >${diff_config}
-if [ "$?" -ne "0" ]; then
-echo "${GEN_TIME} - There is a difference! Create backup..." >> ${LogFile}
-section "Create backup for ${RouterName}"
-BackupDir=${BaseDir}"/"${DStamp}
-mkdir -p ${BackupDir}
-DTStamp=$(date '+%Y%m%d%H%M%S')
-save_config=${DTStamp}"-Config.rsc"
-save_backup=${DTStamp}"-Binary.backup"
-diff_config_history=${DTStamp}"-Diff-Config.rsc"
-echo "${GEN_TIME} - Copy ${current_config} file to ${BackupDir} directory..." >> ${LogFile}
-cd ${TempDir}
-rm -f ${precedent_config}
-cp ${current_config} ${BackupDir}"/"${save_config}
-mv -f ${current_config} ${precedent_config}
-echo "${GEN_TIME} - Copy configuration to ${BackupDir}/${save_config} and ${precedent_config} success." >> ${LogFile}
-success "Copy configuration to ${BackupDir}/${save_config} and ${precedent_config} success."
-info "Create ${current_backup} file on ${RouterName}..."
-echo "${GEN_TIME} - Create ${current_backup} file on ${RouterName}..." >> ${LogFile}
-ssh ${SSH_OPTS} ${SSHuser}@${SSHhost} system backup save name=${current_backup}
-if [ $? -eq 0 ]; then
-echo
-toend_ok
-echo
-echo "${GEN_TIME} - Create binary backup ${current_backup} on ${RouterName} success." >> ${LogFile}
-info "Start download ${current_backup} file to ${BackupDir}..."
-echo "${GEN_TIME} - Start download ${current_backup} file to ${BackupDir}..." >> ${LogFile}
-sftp ${SFTP_OPTS} ${SSHuser}@${SSHhost}:$current_backup
-sleep 1
-success "Download complete!"
-echo "${GEN_TIME} - Download complete!" >> ${LogFile}
-cd ${BackupDir}
-sleep 2
-mv -f ${TempDir}"/"${current_backup} ${save_backup}
-echo "${GEN_TIME} - Remove ${current_backup} file on ${RouterName}." >> ${LogFile}
-ssh ${SSH_OPTS} ${SSHuser}@${SSHhost} /file remove ${current_backup}
-else
-echo
-toend_error
-echo
-echo "${GEN_TIME} - Create binary backup ${current_backup} failed!" >> ${LogFile}
-ssh ${SSH_OPTS} ${SSHuser}@${SSHhost} /file remove $current_backup
-exit 1
-fi
-cd ${TempDir}
-CurrentHistoryDir=${HistoryDir}"/"${DStamp}
-mkdir -p ${CurrentHistoryDir}
-echo "${GEN_TIME} - Move ${diff_config} file to ${CurrentHistoryDir}." >> ${LogFile}
-mv -f ${diff_config} ${CurrentHistoryDir}"/"${diff_config_history}
-echo "${GEN_TIME} - Move ${diff_config} file to ${CurrentHistoryDir} complete." >> ${LogFile}
-echo "${GEN_TIME} - Go to Git directory (${GitDir}), add backups files and commit him." >> ${LogFile}
-rm -d ${TempDir}
-cd ${GitDir}
-git add .
-echo "${GEN_TIME} - Git add commit..." >> ${LogFile}
-git commit -m "Backup for ${RouterName} sucessfully creatd at ${GEN_TIME}."
-echo "${GEN_TIME} - Done." >> ${LogFile}
-echo "${GEN_TIME} - Git push..." >> ${LogFile}
-git push origin main
-echo "${GEN_TIME} - Done." >> ${LogFile}
-echo "${GEN_TIME} - ${RouterName} backup complete!"  >> ${LogFile}
-success "${RouterName} backup complete!"
-fi
-section "The files are identical. No backup is required."
-echo "${GEN_TIME} - The files are identical. No backup is required." >> ${LogFile}
-echo "${GEN_TIME} - Remove ${diff_config} file." >> ${LogFile}
-info "Remove ${diff_config} file."
-rm -f ${diff_config}
-echo "${GEN_TIME} - Remove ${current_config} file." >> ${LogFile}
-info "Remove ${current_config} file."
-rm -f ${current_config}
-echo "${GEN_TIME} - Remove Temp directory." >> ${LogFile}
-info "Remove Temp directory."
-rm -d ${TempDir}
-section ""
-success "${RouterName} backup complete!"
-echo "${GEN_TIME} - ${RouterName} backup complete!" >> ${LogFile}
-done <<<"$(echo -e $HR)"
-done
-section "All Done!"
-echo "All Done!" >> ${LogFile}
-exit 0
index 4b0de87f1c435278d52083b88f9d1d9f920a094e..82159458bdf05c6e12be3b90187eba79158eb4f7 100644 (file)
@@ -16,9 +16,9 @@
 :global GlobalFuncReady false;
 
 # Git commit id & info, expected configuration version
-:global CommitId "main/167/eeff9aa5";
+:global CommitId "main/168/a988fcea";
 :global CommitTAG "unknown";
-:global CommitInfo "Autocommit in repo: ros.vados.ru, generated by owner: root, in 04:24:04 12.03.2026.";
+:global CommitInfo "Autocommit in repo: ros.vados.ru, generated by owner: root, in 04:54:05 12.03.2026.";
 
 # The variables are received right here.
 :global GlobalConfVersion 138;