From 3152e35e74dffb6b4547bd4bd65cf5681a29429c Mon Sep 17 00:00:00 2001 From: X_GIT_USER_NAME_X Date: Sun, 8 Dec 2024 09:50:31 +0000 Subject: [PATCH 1/6] refact: optimize --- src/core/rsync-lib | 25 ++++---- src/linux-fs/linux-fs-cifs-mount | 5 +- src/rsync/rsync-clone-dir-list-delta | 62 ------------------- ...ne-dir-send-root => rsync-clone-dir-local} | 12 ++-- ...one-dir-send-user => rsync-copy-dir-local} | 14 +++-- 5 files changed, 32 insertions(+), 86 deletions(-) delete mode 100755 src/rsync/rsync-clone-dir-list-delta rename src/rsync/{rsync-clone-dir-send-root => rsync-clone-dir-local} (87%) rename src/rsync/{rsync-clone-dir-send-user => rsync-copy-dir-local} (84%) diff --git a/src/core/rsync-lib b/src/core/rsync-lib index 1383c63..61c3cec 100755 --- a/src/core/rsync-lib +++ b/src/core/rsync-lib @@ -3,7 +3,7 @@ ####################################### # RSync / Lib # -# Version: 2.0.0 +# Version: 2.1.0 # ####################################### # Copyright [2024] [serdigital64@gmail.com] @@ -26,7 +26,11 @@ # # shellcheck disable=SC2015,SC2154 source-path=SCRIPTDIR/../../lib/bl64 -source "${S64_CORE_PATH_BL64}/bashlib64-module-ui.bash" && +source "${S64_CORE_PATH_BL64}/bashlib64-module-fs.bash" && + source "${S64_CORE_PATH_BL64}/bashlib64-module-txt.bash" && + source "${S64_CORE_PATH_BL64}/bashlib64-module-xsv.bash" && + source "${S64_CORE_PATH_BL64}/bashlib64-module-fmt.bash" && + source "${S64_CORE_PATH_BL64}/bashlib64-module-ui.bash" && source "${S64_CORE_PATH_BL64}/bashlib64-module-bsh.bash" || { echo 'Error: unable to load bashlib64' && exit 1; } @@ -37,20 +41,15 @@ source "${S64_CORE_PATH_BL64}/bashlib64-module-ui.bash" && # shellcheck disable=SC2034 { declare S64_RSYNC_PATH_CLI="${S64_RSYNC_PATH_CLI:-}" + declare S64_RSYNC_OPTIONS_COMMON='' S64_RSYNC_OPTIONS_COMMON+=' --one-file-system' - S64_RSYNC_OPTIONS_COMMON+=' --human-readable' - S64_RSYNC_OPTIONS_COMMON+=' --progress' - S64_RSYNC_OPTIONS_COMMON+=' --stats' - S64_RSYNC_OPTIONS_COMMON+=' --recursive' S64_RSYNC_OPTIONS_COMMON+=' --checksum' - S64_RSYNC_OPTIONS_COMMON+=' --links' - S64_RSYNC_OPTIONS_COMMON+=' --delete' S64_RSYNC_OPTIONS_COMMON+=' --mkpath' - S64_RSYNC_OPTIONS_COMMON+=' --verbose' - S64_RSYNC_OPTIONS_COMMON+=' --perms' - S64_RSYNC_OPTIONS_COMMON+=' --checksum' - S64_RSYNC_OPTIONS_COMMON+=' --compress' + + declare S64_RSYNC_OPTIONS_LOCAL='' + S64_RSYNC_OPTIONS_LOCAL+=' --links' + S64_RSYNC_OPTIONS_LOCAL+=' --perms' } # @@ -68,7 +67,7 @@ function s64_rsync_lib_setup() { function s64_rsync_lib_run_rsync() { bl64_dbg_app_show_function "$@" - local verbose_flag='--verbose' + local verbose_flag='--human-readable --verbose --stats' bl64_msg_app_verbose_enabled || verbose_flag=' ' bl64_dbg_app_trace_start # shellcheck disable=SC2086 diff --git a/src/linux-fs/linux-fs-cifs-mount b/src/linux-fs/linux-fs-cifs-mount index 5234784..a69f6f5 100755 --- a/src/linux-fs/linux-fs-cifs-mount +++ b/src/linux-fs/linux-fs-cifs-mount @@ -3,7 +3,7 @@ ####################################### # Linux / FS / CIFS / Mount # -# Version: 1.0.1 +# Version: 1.0.2 # ####################################### # Copyright [2024] [serdigital64@gmail.com] @@ -40,7 +40,8 @@ function initialize() { bl64_check_privilege_root && bl64_check_parameter 'CIFS_SERVER_IP' && bl64_check_parameter 'CIFS_SHARE_NAME' && - bl64_check_parameter 'MOUNT_PATH' + bl64_check_parameter 'MOUNT_PATH' && + bl64_check_directory "$MOUNT_PATH" && s64_linux_lib_setup } diff --git a/src/rsync/rsync-clone-dir-list-delta b/src/rsync/rsync-clone-dir-list-delta deleted file mode 100755 index b2f755f..0000000 --- a/src/rsync/rsync-clone-dir-list-delta +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env bash -# template-one: 2.0.0 -####################################### -# RSync / Clone / Dir / List / Delta -# -# Version: 1.0.1 -# -####################################### -# Copyright [2024] [serdigital64@gmail.com] -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -####################################### - -# -# Imports -# - -declare S64_CORE_PATH_ROOT="${S64_CORE_PATH_ROOT:-/opt/sysop64}" -# shellcheck disable=SC2015 source-path=SCRIPTDIR/.. -source "${S64_CORE_PATH_ROOT}/core/core-lib" && source "${S64_CORE_PATH_ROOT}/core/rsync-lib" || { echo "Error: unable to load module library" && exit 1; } -# shellcheck disable=SC2015,SC2154 source-path=SCRIPTDIR/../../lib/bl64 -source "${S64_CORE_PATH_BL64}/bashlib64-core.bash" || { echo 'Error: unable to load bashlib64' && exit 1; } - -# -# Functions -# - -function initialize() { - bl64_dbg_app_show_function - s64_rsync_lib_setup && - bl64_check_parameter 'RSYNC_CLONE_FROM' && - bl64_check_parameter 'RSYNC_CLONE_TO' && - bl64_check_directory "$RSYNC_CLONE_FROM" -} - -# -# Main -# - -declare RSYNC_CLONE_FROM="${1:-}" -declare RSYNC_CLONE_TO="${2:-}" - -bl64_dbg_set_level "$S64_CORE_SET_DEBUG" && bl64_msg_set_level "$S64_CORE_SET_VERBOSE" && initialize || exit $? -bl64_msg_show_batch_start "$BL64_SCRIPT_ID" -bl64_msg_show_task "Show delta between source and destination (${RSYNC_CLONE_FROM} -> ${RSYNC_CLONE_TO})" -# shellcheck disable=SC2086 -s64_rsync_lib_run_rsync \ - $S64_RSYNC_OPTIONS_COMMON \ - --dry-run \ - "$RSYNC_CLONE_FROM" \ - "$RSYNC_CLONE_TO" -bl64_msg_show_batch_finish $? "$BL64_SCRIPT_ID" diff --git a/src/rsync/rsync-clone-dir-send-root b/src/rsync/rsync-clone-dir-local similarity index 87% rename from src/rsync/rsync-clone-dir-send-root rename to src/rsync/rsync-clone-dir-local index 1762532..b891009 100755 --- a/src/rsync/rsync-clone-dir-send-root +++ b/src/rsync/rsync-clone-dir-local @@ -1,9 +1,9 @@ #!/usr/bin/env bash # template-one: 2.0.0 ####################################### -# RSync / Clone / Dir / Send / Root +# RSync / Clone / Dir / Local # -# Version: 1.0.1 +# Version: 1.0.2 # ####################################### # Copyright [2024] [serdigital64@gmail.com] @@ -38,10 +38,10 @@ source "${S64_CORE_PATH_BL64}/bashlib64-core.bash" || { echo 'Error: unable to l function initialize() { bl64_dbg_app_show_function bl64_check_privilege_root && - s64_rsync_lib_setup && bl64_check_parameter 'RSYNC_CLONE_FROM' && bl64_check_parameter 'RSYNC_CLONE_TO' && - bl64_check_directory "$RSYNC_CLONE_FROM" + bl64_check_directory "$RSYNC_CLONE_FROM" && + s64_rsync_lib_setup } # @@ -53,10 +53,14 @@ declare RSYNC_CLONE_TO="${2:-}" bl64_dbg_set_level "$S64_CORE_SET_DEBUG" && bl64_msg_set_level "$S64_CORE_SET_VERBOSE" && initialize || exit $? bl64_msg_show_batch_start "$BL64_SCRIPT_ID" +bl64_msg_show_info 'Copy files from Linux path to Linux path. Operation is privileged, source file ownership is kept.' # shellcheck disable=SC2086 bl64_ui_ask_confirmation "Warning: destination content will be replaced (${RSYNC_CLONE_FROM} -> ${RSYNC_CLONE_TO})" && s64_rsync_lib_run_rsync \ $S64_RSYNC_OPTIONS_COMMON \ + $S64_RSYNC_OPTIONS_LOCAL \ + --recursive \ + --delete \ --owner \ --group \ --times \ diff --git a/src/rsync/rsync-clone-dir-send-user b/src/rsync/rsync-copy-dir-local similarity index 84% rename from src/rsync/rsync-clone-dir-send-user rename to src/rsync/rsync-copy-dir-local index 20c9adc..ce9af6d 100755 --- a/src/rsync/rsync-clone-dir-send-user +++ b/src/rsync/rsync-copy-dir-local @@ -1,9 +1,9 @@ #!/usr/bin/env bash # template-one: 2.0.0 ####################################### -# RSync / Clone / Dir / Send / User +# RSync / Copy / Dir / Local # -# Version: 1.0.1 +# Version: 1.0.2 # ####################################### # Copyright [2024] [serdigital64@gmail.com] @@ -37,10 +37,10 @@ source "${S64_CORE_PATH_BL64}/bashlib64-core.bash" || { echo 'Error: unable to l function initialize() { bl64_dbg_app_show_function - s64_rsync_lib_setup && - bl64_check_parameter 'RSYNC_CLONE_FROM' && + bl64_check_parameter 'RSYNC_CLONE_FROM' && bl64_check_parameter 'RSYNC_CLONE_TO' && - bl64_check_directory "$RSYNC_CLONE_FROM" + bl64_check_directory "$RSYNC_CLONE_FROM" && + s64_rsync_lib_setup } # @@ -52,10 +52,14 @@ declare RSYNC_CLONE_TO="${2:-}" bl64_dbg_set_level "$S64_CORE_SET_DEBUG" && bl64_msg_set_level "$S64_CORE_SET_VERBOSE" && initialize || exit $? bl64_msg_show_batch_start "$BL64_SCRIPT_ID" +bl64_msg_show_info 'Copy files from Linux path to Linux path. Operation is non-privileged, source file ownership is not kept.' # shellcheck disable=SC2086 bl64_ui_ask_confirmation "Warning: destination content will be replaced (${RSYNC_CLONE_FROM} -> ${RSYNC_CLONE_TO})" && s64_rsync_lib_run_rsync \ $S64_RSYNC_OPTIONS_COMMON \ + $S64_RSYNC_OPTIONS_LOCAL \ + --recursive \ + --delete \ "$RSYNC_CLONE_FROM" \ "$RSYNC_CLONE_TO" bl64_msg_show_batch_finish $? "$BL64_SCRIPT_ID" From 5320369c9426e5250877185ca5504da316b33463 Mon Sep 17 00:00:00 2001 From: X_GIT_USER_NAME_X Date: Sun, 8 Dec 2024 09:50:38 +0000 Subject: [PATCH 2/6] feat: add cifs --- CHANGELOG.md | 18 +++++++++ src/rsync/rsync-copy-dir-cifs | 71 +++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100755 src/rsync/rsync-copy-dir-cifs diff --git a/CHANGELOG.md b/CHANGELOG.md index bfb2412..c61ea87 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.17.0] + +### Added + +- RSync + - rsync-copy-dir-cifs + +### Changed + +- RSync + - rsync-clone-dir-send-root -> rsync-clone-dir-local + - rsync-clone-dir-send-user -> rsync-copy-dir-local + +### Removed + +- RSync + - rsync-clone-dir-list-delta + ## [0.16.0] ### Added diff --git a/src/rsync/rsync-copy-dir-cifs b/src/rsync/rsync-copy-dir-cifs new file mode 100755 index 0000000..ae71451 --- /dev/null +++ b/src/rsync/rsync-copy-dir-cifs @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +# template-one: 2.0.0 +####################################### +# RSync / Copy / Dir / CIFS +# +# Version: 1.0.0 +# +####################################### +# Copyright [2024] [serdigital64@gmail.com] +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################### + +# +# Imports +# + +declare S64_CORE_PATH_ROOT="${S64_CORE_PATH_ROOT:-/opt/sysop64}" +# shellcheck disable=SC2015 source-path=SCRIPTDIR/.. +source "${S64_CORE_PATH_ROOT}/core/core-lib" && source "${S64_CORE_PATH_ROOT}/core/rsync-lib" || { echo "Error: unable to load module library" && exit 1; } +# shellcheck disable=SC2015,SC2154 source-path=SCRIPTDIR/../../lib/bl64 +source "${S64_CORE_PATH_BL64}/bashlib64-core.bash" || { echo 'Error: unable to load bashlib64' && exit 1; } + +# +# Functions +# + +function initialize() { + bl64_dbg_app_show_function + s64_rsync_lib_setup && + bl64_check_parameter 'RSYNC_CLONE_FROM' && + bl64_check_parameter 'RSYNC_CLONE_TO' && + bl64_check_directory "$RSYNC_CLONE_FROM" +} + +# +# Main +# + +declare RSYNC_CLONE_FROM="${1:-}" +declare RSYNC_CLONE_TO="${2:-}" + +bl64_dbg_set_level "$S64_CORE_SET_DEBUG" && bl64_msg_set_level "$S64_CORE_SET_VERBOSE" && initialize || exit $? +bl64_msg_show_batch_start "$BL64_SCRIPT_ID" +bl64_msg_show_info 'Copy files from Linux path to CIFS path. The operation will try to adapt linux files attributes and names to CIFS equivalents.' +# shellcheck disable=SC2086 +bl64_ui_ask_confirmation "Warning: destination content will be replaced (${RSYNC_CLONE_FROM} -> ${RSYNC_CLONE_TO})" && + s64_rsync_lib_run_rsync \ + $S64_RSYNC_OPTIONS_COMMON \ + --recursive \ + --delete \ + --no-links \ + --no-perms \ + --no-acls \ + --no-owner \ + --no-group \ + --no-devices \ + --numeric-ids \ + "$RSYNC_CLONE_FROM" \ + "$RSYNC_CLONE_TO" +bl64_msg_show_batch_finish $? "$BL64_SCRIPT_ID" From db714c6cbb5f2d2239e41a4d85fd0207ca8b2217 Mon Sep 17 00:00:00 2001 From: X_GIT_USER_NAME_X Date: Sun, 8 Dec 2024 10:35:12 +0000 Subject: [PATCH 3/6] refact: replace yq for bl64 --- src/aws-eks/aws-eks-addons-show | 5 ++--- src/core/aws-lib | 5 +++-- src/core/core-lib | 6 ++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/aws-eks/aws-eks-addons-show b/src/aws-eks/aws-eks-addons-show index c3da964..f649581 100755 --- a/src/aws-eks/aws-eks-addons-show +++ b/src/aws-eks/aws-eks-addons-show @@ -3,7 +3,7 @@ ####################################### # AWS / EKS / AddOns / Show # -# Version: 1.1.0 +# Version: 1.1.1 # ####################################### # Copyright [2024] [serdigital64@gmail.com] @@ -43,7 +43,7 @@ function aws_eks_addons_list() { list-addons \ $BL64_AWS_SET_FORMAT_JSON \ --cluster-name "$cluster_name" | - "$S64_CORE_PATH_JQ" \ + bl64_xsv_run_jq \ -r '.addons[]' } @@ -63,7 +63,6 @@ function aws_eks_addons_show() { function initialize() { bl64_dbg_app_show_function bl64_check_parameter 'CLUSTER_NAME' && - bl64_check_command_search_path "$S64_CORE_PATH_JQ" && s64_aws_lib_setup } diff --git a/src/core/aws-lib b/src/core/aws-lib index 238570c..5cbaa39 100755 --- a/src/core/aws-lib +++ b/src/core/aws-lib @@ -3,7 +3,7 @@ ####################################### # AWS / Lib # -# Version: 2.0.0 +# Version: 2.1.0 # ####################################### # Copyright [2024] [serdigital64@gmail.com] @@ -26,7 +26,8 @@ # # shellcheck disable=SC2015,SC2154 source-path=SCRIPTDIR/../../lib/bl64 -source "${S64_CORE_PATH_BL64}/bashlib64-module-bsh.bash" || +source "${S64_CORE_PATH_BL64}/bashlib64-module-xsv.bash" || + source "${S64_CORE_PATH_BL64}/bashlib64-module-bsh.bash" || source "${S64_CORE_PATH_BL64}/bashlib64-module-fmt.bash" && source "${S64_CORE_PATH_BL64}/bashlib64-module-txt.bash" && source "${S64_CORE_PATH_BL64}/bashlib64-module-fs.bash" && diff --git a/src/core/core-lib b/src/core/core-lib index 6e9f910..9bfff18 100755 --- a/src/core/core-lib +++ b/src/core/core-lib @@ -3,7 +3,7 @@ ####################################### # Core / Lib # -# Version: 1.2.0 +# Version: 2.0.0 # ####################################### # Copyright [2024] [serdigital64@gmail.com] @@ -34,9 +34,7 @@ # Default debut level declare S64_CORE_SET_DEBUG="${S64_CORE_SET_DEBUG:-NONE}" + # Default verbose level declare S64_CORE_SET_VERBOSE="${S64_CORE_SET_VERBOSE:-ALL}" - - # Default JQuery tool path - declare S64_CORE_PATH_JQ="${S64_CORE_PATH_JQ:-/usr/bin/jq}" } From 48027349ab92b3909c1a97f6126ae00a0aba4a92 Mon Sep 17 00:00:00 2001 From: X_GIT_USER_NAME_X Date: Sun, 8 Dec 2024 10:38:34 +0000 Subject: [PATCH 4/6] refact: replace yq for bl64 --- src/core/aws-lib | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/aws-lib b/src/core/aws-lib index 5cbaa39..d950082 100755 --- a/src/core/aws-lib +++ b/src/core/aws-lib @@ -58,7 +58,8 @@ source "${S64_CORE_PATH_BL64}/bashlib64-module-xsv.bash" || # function s64_aws_lib_setup() { - bl64_aws_setup && + bl64_xsv_setup && + bl64_aws_setup && s64_aws_lib_access_check } From 4048ff00411d61c4840826fc53f927e1f7387b8a Mon Sep 17 00:00:00 2001 From: X_GIT_USER_NAME_X Date: Sun, 8 Dec 2024 14:06:22 +0000 Subject: [PATCH 5/6] feat: add logging --- src/core/core-lib | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/core/core-lib b/src/core/core-lib index 9bfff18..f7db2ae 100755 --- a/src/core/core-lib +++ b/src/core/core-lib @@ -27,14 +27,26 @@ # shellcheck disable=SC2034 { - # Default SysOp64 install path - declare S64_CORE_PATH_ROOT="${S64_CORE_PATH_ROOT:-/opt/sysop64}" - # Default BL64 install path - declare S64_CORE_PATH_BL64="${S64_CORE_PATH_BL64:-/opt/bl64}" + # Default SysOp64 install path + declare S64_CORE_PATH_ROOT="${S64_CORE_PATH_ROOT:-/opt/sysop64}" - # Default debut level - declare S64_CORE_SET_DEBUG="${S64_CORE_SET_DEBUG:-NONE}" + # Default BL64 install path + declare S64_CORE_PATH_BL64="${S64_CORE_PATH_BL64:-/opt/bl64}" - # Default verbose level - declare S64_CORE_SET_VERBOSE="${S64_CORE_SET_VERBOSE:-ALL}" + # Default log repository + declare S64_CORE_PATH_LOGS="${S64_CORE_PATH_LOGS:-${HOME}/logs-sysop64}" + + # Default debut level + declare S64_CORE_SET_DEBUG="${S64_CORE_SET_DEBUG:-NONE}" + + # Default verbose level + declare S64_CORE_SET_VERBOSE="${S64_CORE_SET_VERBOSE:-ALL}" +} + +# +# Functions +# + +function s64_core_lib_setup_logging() { + : } From 228d8d9ce73d51a8ce2846d612384da3f2da62e1 Mon Sep 17 00:00:00 2001 From: X_GIT_USER_NAME_X Date: Sun, 8 Dec 2024 14:06:27 +0000 Subject: [PATCH 6/6] refact: optimize --- src/core/aws-lib | 1 + src/core/rsync-lib | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/aws-lib b/src/core/aws-lib index d950082..9402604 100755 --- a/src/core/aws-lib +++ b/src/core/aws-lib @@ -58,6 +58,7 @@ source "${S64_CORE_PATH_BL64}/bashlib64-module-xsv.bash" || # function s64_aws_lib_setup() { + bl64_dbg_app_show_function bl64_xsv_setup && bl64_aws_setup && s64_aws_lib_access_check diff --git a/src/core/rsync-lib b/src/core/rsync-lib index 61c3cec..614ef7e 100755 --- a/src/core/rsync-lib +++ b/src/core/rsync-lib @@ -26,7 +26,8 @@ # # shellcheck disable=SC2015,SC2154 source-path=SCRIPTDIR/../../lib/bl64 -source "${S64_CORE_PATH_BL64}/bashlib64-module-fs.bash" && +source "${S64_CORE_PATH_BL64}/bashlib64-module-log.bash" && + source "${S64_CORE_PATH_BL64}/bashlib64-module-fs.bash" && source "${S64_CORE_PATH_BL64}/bashlib64-module-txt.bash" && source "${S64_CORE_PATH_BL64}/bashlib64-module-xsv.bash" && source "${S64_CORE_PATH_BL64}/bashlib64-module-fmt.bash" &&