From 95ed752cf31e26fa5795e856195377d99ad204d5 Mon Sep 17 00:00:00 2001 From: Sandor Semsey Date: Mon, 26 Feb 2024 18:44:52 +0100 Subject: [PATCH 1/6] lib/anal-disk-usage: use sudo --- lib/analytics.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/analytics.sh b/lib/analytics.sh index eeb4c27..0b1e0d7 100644 --- a/lib/analytics.sh +++ b/lib/analytics.sh @@ -15,10 +15,10 @@ anal-disk-usage() { local dir="${1:-.}" local total size dir - total=$(du --summarize --block-size=1 "${dir}" 2>/dev/null | cut -f1) + total=$(sudo du --summarize --block-size=1 "${dir}" 2>/dev/null | cut -f1) while IFS= read -r -d '' line; do read -r size dir <<<"${line}" printf "%3d%% %8s %s\n" "$((size * 100 / total))" "$(numfmt --to=iec "${size}")" "${dir}" - done < <(du --null --block-size=1 -d1 "${dir}" 2>/dev/null | sort -nz) + done < <(sudo du --null --block-size=1 -d1 "${dir}" 2>/dev/null | sort -nz) } From f2e5670d29d3cc15b3ddb7d36ca5cfd939350654 Mon Sep 17 00:00:00 2001 From: Sandor Semsey Date: Mon, 26 Feb 2024 23:20:43 +0100 Subject: [PATCH 2/6] lib/ui: fix print-* functions with multiple arguments --- lib/ui.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/ui.sh b/lib/ui.sh index 824fd7b..9fef472 100644 --- a/lib/ui.sh +++ b/lib/ui.sh @@ -28,7 +28,8 @@ export BACK_BLUE="\e[44m" ######################## print-error() { [[ -n "${ES_PRINT_HUSH:-}" ]] && return 0 - echo -e "${TXT_RED}${TXT_BOLD}${*}${TXT_NORM}" >&2 + # shellcheck disable=SC2086 + echo -e ${TXT_RED}${TXT_BOLD}${*}${TXT_NORM} >&2 } ## Print title @@ -51,7 +52,8 @@ print-title() { for ((i = 0 ; i < padding_left ; i++)); do echo -n " " done - echo -n "${title}" + # shellcheck disable=SC2086 + echo -n ${title} for ((i = 0 ; i < padding_right ; i++)); do echo -n " " done @@ -71,7 +73,8 @@ print-section() { local header="${*}" [[ -n "${ES_PRINT_HUSH:-}" ]] && return 0 echo - echo -e "${BACK_BLUE}${header}${TXT_NORM}" + # shellcheck disable=SC2086 + echo -e ${BACK_BLUE}${header}${TXT_NORM} echo -ne "${BACK_BLUE}" for ((i = 0 ; i < ${#header} ; i++)); do echo -n "~" @@ -85,8 +88,8 @@ print-section() { ####################### print-header() { [[ -n "${ES_PRINT_HUSH:-}" ]] && return 0 - echo - echo -e "${TXT_YELLOW}${*}${TXT_NORM}" + # shellcheck disable=SC2086 + echo -e ${TXT_YELLOW}${*}${TXT_NORM} } ## Print status message @@ -95,7 +98,8 @@ print-header() { ######################## print-status() { [[ -n "${ES_PRINT_HUSH:-}" ]] && return 0 - echo -ne "${TXT_YELLOW}${*}${TXT_NORM}" + # shellcheck disable=SC2086 + echo -ne ${TXT_YELLOW}${*}${TXT_NORM} } ## Print OK message @@ -105,7 +109,8 @@ print-status() { ######################## print-finish() { [[ -n "${ES_PRINT_HUSH:-}" ]] && return 0 - echo -e "${TXT_GREEN}${TXT_BOLD}${*:-Done.}${TXT_NORM}" + # shellcheck disable=SC2086 + echo -e ${TXT_GREEN}${TXT_BOLD}${*:-Done.}${TXT_NORM} } ## Script running time From 5e3f8fb807b7af50733f74f3b904b427bc7b28ff Mon Sep 17 00:00:00 2001 From: Sandor Semsey Date: Tue, 27 Feb 2024 00:22:39 +0100 Subject: [PATCH 3/6] lib/ui: use tput color codes --- lib/ui.sh | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/ui.sh b/lib/ui.sh index 9fef472..443d3fd 100644 --- a/lib/ui.sh +++ b/lib/ui.sh @@ -9,14 +9,26 @@ ## FORMAT CODES ## ################## -export TXT_NORM="\e[0m" -export TXT_BOLD="\e[1m" -export TXT_RED="\e[31m" -export TXT_GREEN="\e[32m" -export TXT_YELLOW="\e[33m" -export TXT_BLUE="\e[34m" -export TXT_PURPLE="\e[35m" -export BACK_BLUE="\e[44m" +if [[ -z "${TERM:-}" ]]; then + export TERM=xterm-256color +fi + +# shellcheck disable=SC2155 +export TXT_NORM=$(tput sgr0) +# shellcheck disable=SC2155 +export TXT_BOLD=$(tput bold) +# shellcheck disable=SC2155 +export TXT_RED=$(tput setaf 1) +# shellcheck disable=SC2155 +export TXT_GREEN=$(tput setaf 2) +# shellcheck disable=SC2155 +export TXT_YELLOW=$(tput setaf 3) +# shellcheck disable=SC2155 +export TXT_BLUE=$(tput setaf 4) +# shellcheck disable=SC2155 +export TXT_PURPLE=$(tput setaf 5) +# shellcheck disable=SC2155 +export BACK_BLUE=$(tput setab 4) ############### ## FUNCTIONS ## From 55a34a2652d229f4345176236df52cab1b0ff74c Mon Sep 17 00:00:00 2001 From: Sandor Semsey Date: Mon, 26 Feb 2024 21:59:44 +0100 Subject: [PATCH 4/6] remove quotes --- bin/backup | 38 +++++++++++++++---------------- bin/benchmark | 42 +++++++++++++++++----------------- bin/clean | 10 ++++----- bin/generate-moduli | 10 ++++----- bin/pass-man | 10 ++++----- bin/sign-kernel-modules | 6 ++--- bin/test-dd-write | 6 ++--- lib/certificate.sh | 44 ++++++++++++++++++------------------ lib/db.sh | 28 +++++++++++------------ lib/dev.sh | 20 ++++++++--------- lib/error.sh | 2 +- lib/files.sh | 10 ++++----- lib/git.sh | 50 ++++++++++++++++++++--------------------- lib/github.sh | 40 ++++++++++++++++----------------- lib/network.sh | 4 ++-- lib/process.sh | 12 +++++----- lib/ssh.sh | 34 ++++++++++++++-------------- lib/text.sh | 8 +++---- lib/ui.sh | 4 ++-- 19 files changed, 189 insertions(+), 189 deletions(-) diff --git a/bin/backup b/bin/backup index 5c4b401..69c78d9 100755 --- a/bin/backup +++ b/bin/backup @@ -20,7 +20,7 @@ ########## _version() { cat </dev/null; then - print-status "Mount backup filesystem..." + print-status Mount backup filesystem... mount "${file_system}" "${mount_point}" print-finish fi @@ -189,13 +189,13 @@ now=$(date "+${date_format}") destination="${mount_point}/${dest_dir}" if [[ ! -e "${destination}" ]]; then - print-status "Create destination dir..." + print-status Create destination dir... mkdir -p "${destination}" print-finish fi # Set rsync targets, options -if [[ "${backup_mode}" == "archive" || "${backup_mode}" == "quick" ]]; then +if [[ "${backup_mode}" == archive || "${backup_mode}" == quick ]]; then target="${destination}/actual" opt=(--delete --inplace) else @@ -204,13 +204,13 @@ else opt=("--link-dest=${last}") fi -print-header "Backup files..." +print-header Backup files... rsync -aAXHEh --info=stats1 --info=progress2 "${opt[@]}" "${exclusion[@]}" "${quiet[@]}" "${source_dir}" "${target}" # Post backup steps case "${backup_mode}" in snapshot) - print-status "Manage links for snapshots..." + print-status Manage links for snapshots... # Remove symlink to previous snapshot rm -f "${last}" # Create new symlink to latest snapshot for the next backup to hardlink @@ -218,24 +218,24 @@ case "${backup_mode}" in print-finish if [[ -n "${expire_date}" ]]; then - print-status "Delete expired snapshots..." + print-status Delete expired snapshots... find "${destination}" -mindepth 1 -maxdepth 1 -mtime "+${expire_date}" -exec rm -rf {} \; print-finish fi ;; archive) if [[ ! -e "${destination}/${archive_dir}" ]]; then - print-status "Create archive dir..." + print-status Create archive dir... mkdir -p "${destination}/${archive_dir}" print-finish fi - print-status "Compress files..." + print-status Compress files... tar -C "${destination}" -I "pigz --fast" --sort=name -cf "${destination}/${archive_dir}/${archive_prefix}${now}.tar.gz" actual/ print-finish if [[ -n "${expire_date}" ]]; then - print-status "Delete expired archives..." + print-status Delete expired archives... find "${destination}/${archive_dir}" -mindepth 1 -maxdepth 1 -mtime "+${expire_date}" -exec rm -rf {} \; print-finish fi @@ -245,11 +245,11 @@ esac # Unmount filesystem if findmnt "${mount_point}" >/dev/null; then - print-status "Unmounting backup filesystem..." + print-status Unmounting backup filesystem... umount "${mount_point}" || true print-finish fi -print-finish "Backup finished" +print-finish Backup finished exit 0 diff --git a/bin/benchmark b/bin/benchmark index 5929b2f..90fc31e 100755 --- a/bin/benchmark +++ b/bin/benchmark @@ -18,7 +18,7 @@ ############ # Version -version=1.2.3 +version=1.2.4 # Individual benchmark time limit (seconds) # Quick benchmark test_run_time_quick=6 @@ -155,9 +155,9 @@ _cpu-app-test() { # shellcheck disable=SC2312 time_aes=$({ TIME="%e seconds" time openssl enc -e -aes-256-cbc -pass pass:12345678 -pbkdf2 >/dev/null &1) - printf "%-20s %s\n" "SHA256-hashing:" "${time_sha}" - printf "%-20s %s\n" "bzip2-compressing:" "${time_bzip}" - printf "%-20s %s\n" "AES-encrypting:" "${time_aes}" + printf "%-20s %s\n" SHA256-hashing: "${time_sha}" + printf "%-20s %s\n" bzip2-compressing: "${time_bzip}" + printf "%-20s %s\n" AES-encrypting: "${time_aes}" rm -f test_file.cpu } @@ -168,7 +168,7 @@ _cpu-app-test() { ## @param $@ Params for benchmark ##################################### _run-benchmark() { - local type="${1?:"Benchmark type missing"}" + local type="${1?:Benchmark type missing}" local params=("--time=${test_run_time}") # Compile params @@ -181,15 +181,15 @@ _run-benchmark() { return 0 ;; *) - echo "Not supported type" >&2 + echo Not supported type >&2 return 1 ;; esac # Run benchmark - [[ "${type}" == "disk" ]] && sysbench "${params[@]}" prepare + [[ "${type}" == disk ]] && sysbench "${params[@]}" prepare sysbench "${params[@]}" run - [[ "${type}" == "disk" ]] && sysbench "${params[@]}" cleanup + [[ "${type}" == disk ]] && sysbench "${params[@]}" cleanup return 0 } @@ -200,8 +200,8 @@ _run-benchmark() { ## @param $2 Raw results ####################################### _filter-results() { - local type="${1?:"Benchmark type missing"}" - local raw="${2?:"Raw results missing"}" + local type="${1?:Benchmark type missing}" + local raw="${2?:Raw results missing}" local filter case "${type}" in @@ -214,7 +214,7 @@ _filter-results() { return 0 ;; *) - echo "Not supported type" >&2 + echo Not supported type >&2 return 1 ;; esac @@ -327,7 +327,7 @@ _print-summary() { printf "%-15s [%-10s] : " "${params[1]}" "${params[0]}" ;; *) - echo "Not supported testname: ${testname}" >&2 + echo Not supported testname: "${testname}" >&2 exit 1 ;; esac @@ -338,7 +338,7 @@ _print-summary() { done # Print CPU application test results - if [[ "${testname}" == "cpu" ]]; then + if [[ "${testname}" == cpu ]]; then printf "\nApplication test\n----------------\n\n%s\n" "${summary[cpu_app]}" fi } @@ -392,7 +392,7 @@ while :; do ;; "") break ;; *) - echo "Not supported option: ${1}" >&2 + echo Not supported option: "${1}" >&2 _usage exit 1 ;; @@ -429,7 +429,7 @@ case "${benchmark_depth}" in ;; *) if [[ -z "${sys_check}" ]]; then - echo "Not supported depth: ${benchmark_depth}" >&2 + echo Not supported depth: "${benchmark_depth}" >&2 _usage exit 1 fi @@ -444,7 +444,7 @@ if [[ -z "${sys_check}" ]]; then required_commands=(dd sha256sum bzip2 openssl lsblk sysbench curl) for cmd in "${required_commands[@]}"; do if ! command -v "${cmd}" >/dev/null 2>&1; then - echo "Missing dependency: ${cmd}" >&2 + echo Missing dependency: "${cmd}" >&2 exit 1 fi done @@ -492,10 +492,10 @@ _print-sysinfo | tee "${output_file}" trap _clean-up EXIT INT TERM # Run Benchmarks -echo "Start Benchmarking..." +echo Start Benchmarking... for type in "${tests[@]}"; do - if [[ "${type}" == "cpu" ]]; then - echo "Running CPU application test..." + if [[ "${type}" == cpu ]]; then + echo Running CPU application test... results=$(_cpu-app-test) summary[cpu_app]=$(_filter-results cpu_app "${results}") fi @@ -506,7 +506,7 @@ for type in "${tests[@]}"; do selector="${type}_${i}" IFS=";" read -r -a params <<<"${run_param}" - echo "Running ${type^^} benchmark #$((i + 1))..." + echo Running "${type^^}" benchmark "#$((i + 1))..." results=$(_run-benchmark "${type}" "${params[@]}") summary[${selector}]=$(_filter-results "${type}" "${results}") @@ -514,7 +514,7 @@ for type in "${tests[@]}"; do done done -echo "Benchmarking finished." +echo Benchmarking finished. echo ## Summary diff --git a/bin/clean b/bin/clean index ab7b904..10919eb 100755 --- a/bin/clean +++ b/bin/clean @@ -16,7 +16,7 @@ ########## _version() { cat <&2 + echo User not exits: "${user}" 1>&2 exit 1 fi - print "Clean-up for ${user}..." + print Clean-up for "${user}..." print -n Empty trash bin... sudo test -d "${homedir}/.local/share/Trash" && sudo find "${homedir}/.local/share/Trash" -mindepth 1 -delete @@ -151,7 +151,7 @@ for user in "${users[@]}"; do sudo test -d "${homedir}/snap/spotify/common/.cache" && sudo find "${homedir}/snap/spotify/common/.cache" -mindepth 1 -delete print Done. - print "Cleanup finished for ${user}." + print Cleanup finished for "${user}." done exit 0 diff --git a/bin/generate-moduli b/bin/generate-moduli index 065877d..177f8bf 100755 --- a/bin/generate-moduli +++ b/bin/generate-moduli @@ -16,8 +16,8 @@ ## @param $2 Output file path ######################################### _generate-DH-primes() { - local bit="${1?:"Bit missing"}" - local output_file="${2?:"Output file name missing"}" + local bit="${1?:Bit missing}" + local output_file="${2?:Output file name missing}" local candidates candidates=$(mktemp --tmpdir DH_candidates.XXXXXXXX) @@ -37,13 +37,13 @@ IFS=$'\n\t' source "${ES_SHELL_LOADER}" # Parse options -IFS=$',' read -r -a bits <<<"${1:-4096,6144,7680,8192}" +IFS=, read -r -a bits <<<"${1:-4096,6144,7680,8192}" results_file="${2:-DH_moduli}" # Validate bits for bit in "${bits[@]}"; do if [[ ! "${bit}" =~ ^[0-9]+$ ]]; then - echo "Only integers as BIT_SIZE." + echo Only integers as BIT_SIZE. exit 1 fi done @@ -66,7 +66,7 @@ done print-finish found=$(wc -l < "${results_file}") -echo "Primes found: $((found - 1))" +echo Primes found: $((found - 1)) print-run-time diff --git a/bin/pass-man b/bin/pass-man index f019644..8c4c1d4 100755 --- a/bin/pass-man +++ b/bin/pass-man @@ -21,7 +21,7 @@ timer=6h _usage() { cat </dev/null 2>&1 } @@ -96,7 +96,7 @@ monitor-proc-memory() { # Print header if [[ "${counter}" -eq 1 ]]; then - printf "%20s %20s %20s\n" "Date" "RSS (KiB)" "MAX RSS (KiB)" + printf "%20s %20s %20s\n" Date "RSS (KiB)" "MAX RSS (KiB)" for ((i = 0 ; i < 62 ; i++)); do echo -n "-" done @@ -112,7 +112,7 @@ monitor-proc-memory() { max_print=$(numfmt --grouping <<<"${max}") printf "%20s %20s %20s\n" "${date}" "${rss_print}" "${max_print}" else - print-error "ps error (propably more than 1 process matched command)" + print-error "ps error (probably more than 1 process matched command)" return 1 fi ;; diff --git a/lib/ssh.sh b/lib/ssh.sh index cff9547..650009b 100644 --- a/lib/ssh.sh +++ b/lib/ssh.sh @@ -13,8 +13,8 @@ ## @default 12 hours ################################# unlock-key() { - local key="${1?:"Path to SSH key missing"}" - local pass_path="${2?:"Path to password missing"}" + local key="${1?:Path to SSH key missing}" + local pass_path="${2?:Path to password missing}" local cache_time="${3:-12h}" local password public_key current_identities @@ -43,7 +43,7 @@ ssh-tunnel-open() { # Check if successful if ! proc-is-running "ssh ${*}"; then - echo "Failed to open tunnel" + echo Failed to open tunnel return 1 fi } @@ -63,7 +63,7 @@ ssh-tunnel-close() { # Check if successful if proc-is-running "ssh ${*}"; then - echo "Failed to close tunnel" + echo Failed to close tunnel return 1 fi } @@ -74,8 +74,8 @@ ssh-tunnel-close() { ## @param $2 Local port ############################ socks5-tunnel-open() { - local remote="${1?:"Remote missing"}" - local port="${2?:"Local port missing"}" + local remote="${1?:Remote missing}" + local port="${2?:Local port missing}" ssh-tunnel-open -fqN -D "${port}" "${remote}" } @@ -85,8 +85,8 @@ socks5-tunnel-open() { ## @param $2 Local port ############################ socks5-tunnel-close() { - local remote="${1?:"Remote missing"}" - local port="${2?:"Local port missing"}" + local remote="${1?:Remote missing}" + local port="${2?:Local port missing}" ssh-tunnel-close -fqN -D "${port}" "${remote}" } @@ -96,8 +96,8 @@ socks5-tunnel-close() { ## @param $2 Comment for key ################################ ssh-create-key() { - local key_name="${1?:"Key name missing"}" - local comment="${2?:"Key comment missing"}" + local key_name="${1?:Key name missing}" + local comment="${2?:Key comment missing}" shift 2 ssh-keygen \ -t ed25519 \ @@ -117,12 +117,12 @@ ssh-create-key() { ## @param $6 Path to user public key - this will be signed ############################################################## ssh-sign-user() { - local validity="${1?:"Validity interval missing"}" - local ca_key_path="${2?:"Path to CA key missing"}" - local identity="${3?:"Key identity missing"}" - local principals="${4?:"Principals missing"}" - local serial="${5?:"Serial number missing"}" - local pubkey_path="${6?:"User public key path missing"}" + local validity="${1?:Validity interval missing}" + local ca_key_path="${2?:Path to CA key missing}" + local identity="${3?:Key identity missing}" + local principals="${4?:Principals missing}" + local serial="${5?:Serial number missing}" + local pubkey_path="${6?:User public key path missing}" shift 6 ssh-keygen \ -V "${validity}" \ @@ -138,7 +138,7 @@ ssh-sign-user() { ## @param $1 Path to certificate #################################### ssh-view-cert() { - local cert="${1?:"Certificate path missing"}" + local cert="${1?:Certificate path missing}" shift ssh-keygen -L -f "${cert}" "${@}" } diff --git a/lib/text.sh b/lib/text.sh index f027db5..c12854f 100644 --- a/lib/text.sh +++ b/lib/text.sh @@ -11,7 +11,7 @@ ## @param $* Items to join ################################## implode() { - local IFS="${1:?"Field separator missing"}" + local IFS="${1:?Field separator missing}" shift echo "${*}" } @@ -22,7 +22,7 @@ implode() { ## @param $2 Section (read only this section) ################################################# read-file-cfg() { - local file="${1:?"File missing"}" + local file="${1:?File missing}" local section="${2:-}" local contents @@ -41,7 +41,7 @@ read-file-cfg() { ## @param $1 String to encode ################################ urlencode() { - local string="${1:?"String missing"}" + local string="${1:?String missing}" local encoded= local pos char enc_char @@ -79,7 +79,7 @@ urldecode() { ## @param $@ Extra args to 'find' #################################### lines-dir() { - local dir="${1:?"Directory missing"}" + local dir="${1:?Directory missing}" shift # shellcheck disable=SC2312 diff --git a/lib/ui.sh b/lib/ui.sh index 443d3fd..8a1298d 100644 --- a/lib/ui.sh +++ b/lib/ui.sh @@ -137,7 +137,7 @@ print-run-time() { min=$((sec / 60)) sec=$((sec % 60)) - echo "Running time:" + echo Running time: printf "%d hour(s) %02d min(s) %02d second(s)\n" "${hour}" "${min}" "${sec}" } @@ -148,7 +148,7 @@ print-run-time() { #################################### confirm() { read -r -p "${*:-Are you sure? (y/n) }" - [[ ${REPLY} == "y" || ${REPLY} == "Y" ]] && return 0 || return 1 + [[ ${REPLY} == y || ${REPLY} == Y ]] } ## Clear console screen From 7d9cacfebb89235f5d38b29c4906a5260925a3f1 Mon Sep 17 00:00:00 2001 From: Sandor Semsey Date: Tue, 27 Feb 2024 00:41:40 +0100 Subject: [PATCH 5/6] bin/backup: print info if task skipped --- bin/backup | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/bin/backup b/bin/backup index 69c78d9..8d33762 100755 --- a/bin/backup +++ b/bin/backup @@ -20,7 +20,7 @@ ########## _version() { cat </dev/null; then - print-status Mount backup filesystem... mount "${file_system}" "${mount_point}" print-finish +else + print-finish Already mounted, skip. fi now=$(date "+${date_format}") destination="${mount_point}/${dest_dir}" +print-status Create destination dir "${destination}..." if [[ ! -e "${destination}" ]]; then - print-status Create destination dir... mkdir -p "${destination}" print-finish +else + print-finish Already created, skip. fi # Set rsync targets, options @@ -224,10 +228,12 @@ case "${backup_mode}" in fi ;; archive) + print-status Create archive dir "${destination}/${archive_dir}..." if [[ ! -e "${destination}/${archive_dir}" ]]; then - print-status Create archive dir... mkdir -p "${destination}/${archive_dir}" print-finish + else + print-finish Already created, skip. fi print-status Compress files... @@ -243,11 +249,12 @@ case "${backup_mode}" in *) ;; esac -# Unmount filesystem +print-status Unmounting "${mount_point}..." if findmnt "${mount_point}" >/dev/null; then - print-status Unmounting backup filesystem... umount "${mount_point}" || true print-finish +else + print-finish Already unmounted, skip. fi print-finish Backup finished From 81459e9081459452dface68e26743a922bd24e6f Mon Sep 17 00:00:00 2001 From: Sandor Semsey Date: Tue, 27 Feb 2024 13:24:55 +0100 Subject: [PATCH 6/6] print error to stderr --- bin/backup | 6 +++--- bin/clean | 4 ++-- lib/ssh.sh | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/backup b/bin/backup index 8d33762..46a61cc 100755 --- a/bin/backup +++ b/bin/backup @@ -128,7 +128,7 @@ while :; do SNAPSHOT) backup_mode=snapshot ;; ARCHIVE) backup_mode=archive ;; *) - echo Not supported mode: "${1}" + echo Not supported mode: "${1}" >&2 _usage exit 1 ;; @@ -141,7 +141,7 @@ while :; do 24H) date_format=%T ;; FULL) date_format=%F_%T ;; *) - echo Not supported format: "${1}" + echo Not supported format: "${1}" >&2 _usage exit 1 ;; @@ -163,7 +163,7 @@ while :; do ;; "") break ;; *) - echo Not supported option: "${1}" + echo Not supported option: "${1}" >&2 _usage exit 1 ;; diff --git a/bin/clean b/bin/clean index 10919eb..8f45133 100755 --- a/bin/clean +++ b/bin/clean @@ -92,7 +92,7 @@ while :; do ;; "") break ;; *) - echo Not supported option: "${1}" + echo Not supported option: "${1}" >&2 _usage exit 1 ;; @@ -125,7 +125,7 @@ print Done. # User caches for user in "${users[@]}"; do if ! homedir=$(getent passwd "${user}" | cut -d: -f6); then - echo User not exits: "${user}" 1>&2 + echo User not exits: "${user}" >&2 exit 1 fi diff --git a/lib/ssh.sh b/lib/ssh.sh index 650009b..b0c3e01 100644 --- a/lib/ssh.sh +++ b/lib/ssh.sh @@ -43,7 +43,7 @@ ssh-tunnel-open() { # Check if successful if ! proc-is-running "ssh ${*}"; then - echo Failed to open tunnel + echo Failed to open tunnel >&2 return 1 fi } @@ -63,7 +63,7 @@ ssh-tunnel-close() { # Check if successful if proc-is-running "ssh ${*}"; then - echo Failed to close tunnel + echo Failed to close tunnel >&2 return 1 fi }