From: vados-dev <192440777+vados-dev@users.noreply.github.com> Date: Thu, 12 Mar 2026 08:58:14 +0000 (+0300) Subject: Autocommit in repo: Mikrotiks, generated by owner: root, in 11:58:14 12.03.2026. X-Git-Url: https://git.vados.ru/gitweb.cgi?a=commitdiff_plain;h=5565851c1b25299eebacf1910d8509d1fd7f1eed;p=Mikrotiks%2FMikrotiks.git Autocommit in repo: Mikrotiks, generated by owner: root, in 11:58:14 12.03.2026. --- diff --git a/bin/Binary.backup b/bin/Binary.backup new file mode 100644 index 0000000..34a09ac Binary files /dev/null and b/bin/Binary.backup differ diff --git a/bin/bash-progress-indicator/main.sh b/bin/bash-progress-indicator/main.sh old mode 100644 new mode 100755 index cf565e7..6698424 --- a/bin/bash-progress-indicator/main.sh +++ b/bin/bash-progress-indicator/main.sh @@ -1,6 +1,14 @@ #!/bin/bash -e # shellcheck disable=SC1091 - +i=1 +sp="⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏" +echo -n ' ' +while true +do + printf "\b${sp:i++%${#sp}:1}" + sleep 0.1 +done +exit 0 declare -rx STEPS=( 'pre-install' 'install' diff --git a/bin/bash-progress-indicator/progress.sh b/bin/bash-progress-indicator/progress.sh old mode 100644 new mode 100755 diff --git a/bin/bash-progress-indicator/progress_advanced.sh b/bin/bash-progress-indicator/progress_advanced.sh old mode 100644 new mode 100755 index ad4f151..eea1d97 --- a/bin/bash-progress-indicator/progress_advanced.sh +++ b/bin/bash-progress-indicator/progress_advanced.sh @@ -1,12 +1,13 @@ #!/bin/bash -e start() { - local MAX_STEPS=${#STEPS[@]} + local MAX_STEPS=${#[@]} local BAR_SIZE="##########" local MAX_BAR_SIZE="${#BAR_SIZE}" local CLEAR_LINE="\\033[K" + echo ${MAX_STEPS} - tput civis -- invisible + tput civis -- for step in "${!STEPS[@]}"; do perc=$((step * 100 / MAX_STEPS)) @@ -23,5 +24,7 @@ start() { done echo "" - tput cnorm -- normal + tput cnorm -- } +sleep 10 & +start \ No newline at end of file diff --git a/bin/bash-progress-indicator/spinner copy.sh b/bin/bash-progress-indicator/spinner copy.sh new file mode 100755 index 0000000..7f33a27 --- /dev/null +++ b/bin/bash-progress-indicator/spinner copy.sh @@ -0,0 +1,82 @@ +#!/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 -- + + 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 -- +} + +set_spinner "$1" diff --git a/bin/bash-progress-indicator/spinner.sh b/bin/bash-progress-indicator/spinner.sh old mode 100644 new mode 100755 index b68cf89..24b1a26 --- a/bin/bash-progress-indicator/spinner.sh +++ b/bin/bash-progress-indicator/spinner.sh @@ -2,7 +2,6 @@ declare -x FRAME declare -x FRAME_INTERVAL - set_spinner() { case $1 in spinner1) @@ -58,7 +57,7 @@ set_spinner() { start() { local step=0 -# tput civis -- invisible + tput civis -- while [ "$step" -lt "${#CMDS[@]}" ]; do ${CMDS[$step]} & pid=$! @@ -76,7 +75,7 @@ start() { step=$((step + 1)) done -# tput cnorm -- normal + tput cnorm -- } set_spinner "$1" diff --git a/bin/ros-diff.sh b/bin/ros-diff.sh index b6cb252..4dc90d2 100755 --- a/bin/ros-diff.sh +++ b/bin/ros-diff.sh @@ -1,4 +1,4 @@ -#!/bin/bash -e +#!/bin/bash # shellcheck disable=SC1091 #set +e -u #o pipefail @@ -56,7 +56,7 @@ DEFAULT_CONNECT_ATTEMPTS=5 DEFAULT_CONNECT_TIMEOUT=5 DEFAULT_SSH_KEY=${HomeDir}"/.ssh/id_rsa" # Set default diff args: -DEFAULT_DIFF_ARGS=("-I \"RouterOS\"") +DEFAULT_DIFF_ARGS="--ignore-matching-lines='by RouterOS'" # # Set debug and log options: DEBUG_OUT=true @@ -116,48 +116,25 @@ section() { echo -e "\n${magenta}................[$(tput rev) $* ${reset}${magenta}]................${reset}\n" } -FRAME=("⠋" "⠙" "⠹" "⠸" "⠼" "⠴" "⠦" "⠧" "⠇" "⠏") -FRAME_INTERVAL=0.1 -spin() { - local step=0 - tput civis -- - 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 -- -} - -show_spinner() +spinstr() { local -r pid="${1}" - local -r delay='0.1' - local spinstr=("⠋" "⠙" "⠹" "⠸" "⠼" "⠴" "⠦" "⠧" "⠇" "⠏") + local delay=0.1 + local spinsym='\|/-' local temp tput civis -- while ps a | awk '{print $1}' | grep -q "${pid}"; do - temp="${spinstr#?}" - printf " [%c] " "${spinstr}" - spinstr=${temp}${spinstr%"${temp}"} + temp="${spinsym#?}" + printf "[ %c ]" "${spinsym}" + spinsym=${temp}${spinsym%"${temp}"} sleep "${delay}" printf "\b\b\b\b\b\b" done - printf " \b\b\b\b" - tput cnorm -- + echo -ne "\\r[ ✔ ]\\n" #" \b\b\b\b" +tput cnorm -- } -sleep 10 & -spin "$!" -exit 0 save_log() { local log="${DEFAULT_LOG}" if [ -n "${LogFile}" ]; then @@ -312,8 +289,9 @@ compare_config() { local diff_file="${3}" local diff_args=${DEFAULT_DIFF_ARGS} local log_msg - + warning "diff ${diff_args} ${config_file} ${precedent_file} > ${diff_file}" diff ${diff_args} ${config_file} ${precedent_file} >${diff_file} + exit 0 if [ "$?" -ne "0" ]; then log_msg="- There is a difference! Create backup..." if [ -t 1 ] && $DEBUG_OUT; then @@ -388,19 +366,19 @@ backup_binary() { local BKPSTR="/system backup save name=${bin_tmp} ${crypt_str}" local T_BKPCLN="/file remove [find name=${bin_tmp}]" - - if ${SSH_STR} ${BKPSTR}; then + ${SSH_STR} "/system backup save name=${bin_tmp} ${crypt_str}" >/dev/null & spinstr "$!" + if [ $? -eq 0 ]; then log_msg="Create binary backup ${bin_tmp} on ${RouterName} success." log_success "${log_msg}" log_msg="- Start download ${bin_tmp} file to ${BackupDir}..." log_info "${log_msg}" - return 0 - if ${SCP_STR}:/${bin_tmp} ${bin_name}; then + + ${SCP_STR}:/${bin_tmp} ${bin_name} & spinstr "$!" + if [ $? -eq 0 ]; then sleep 2 log_msg="- Binary Backup download complete!" log_success "${log_msg}" - return 0 else log_msg="- Error! Download binary backup on ${RoutrName} failed!" log_error "${log_msg}" @@ -410,13 +388,13 @@ backup_binary() { log_error "${log_msg}" fi - log_msg="- Remove ${bin_tmp} file on ${RouterName}." if [ -t 1 ] && $DEBUG_OUT; then section "CLEANUP" fi + log_msg="- Remove ${bin_tmp} file on ${RouterName}." log_info "${log_msg}" - - if ${SSH_STR} ${T_BKPCLN}; then + + if ${SSH_STR} "/file remove [find name=${bin_tmp}]"; then log_msg="- Remove ${bin_tmp} file on ${RouterName} complete succesfully!" log_success "${log_msg}" else