diff --git a/objects.tar.gz b/objects.tar.gz index e1f167c97..aba4b83c1 100644 Binary files a/objects.tar.gz and b/objects.tar.gz differ diff --git a/sherpa-manager.tar.gz b/sherpa-manager.tar.gz index 2905106f7..736de6fb2 100644 Binary files a/sherpa-manager.tar.gz and b/sherpa-manager.tar.gz differ diff --git a/support/build-manager.sh b/support/build-manager.sh index bb1e4dbcf..8bb42aa2d 100755 --- a/support/build-manager.sh +++ b/support/build-manager.sh @@ -6,8 +6,13 @@ a=$support_path/$management_source_file b=$support_path/$management_file SwapTags "$a" "$b" -Squeeze "$b" "$b" +if grep -q '' "$b"; then + ColourTextBrightRed "'$b' contains unswapped tags, can't continue"; echo + exit 1 +fi + +Squeeze "$b" "$b" [[ -e $b ]] && chmod 554 "$b" exit 0 diff --git a/support/build-objects.sh b/support/build-objects.sh index 6b76f7207..82b21073f 100755 --- a/support/build-objects.sh +++ b/support/build-objects.sh @@ -8,24 +8,24 @@ target=$support_path/$objects_file # These are used internally by sherpa. Must maintain separate lists for sherpa internal-use, and what user has requested. # ordered -PACKAGE_TIERS=(independent auxiliary dependent) +r_package_tiers=(independent auxiliary dependent) # sorted -QPKG_IS_STATES=(active backedup downloaded enabled installable installed missing signed upgradable) -QPKG_ISNT_STATES=(active backedup downloaded enabled installable installed missing signed upgradable) -QPKG_IS_GROUPS=(all canbackup canclean canrestarttoupdate dependent hasdependents independent) -QPKG_ISNT_GROUPS=(canclean) -QPKG_STATES_TRANSIENT=(restarting slow starting stopping unknown) -QPKG_SERVICE_RESULTS=(failed ok) +r_qpkg_is_states=(active backedup downloaded enabled installable installed missing signed upgradable) +r_qpkg_isnt_states=(active backedup downloaded enabled installable installed missing signed upgradable) +r_qpkg_is_groups=(all canbackup canclean canrestarttoupdate dependent hasdependents independent) +r_qpkg_isnt_groups=(canclean) +r_qpkg_states_transient=(restarting slow starting stopping unknown) +r_qpkg_service_results=(failed ok) # ordered -QPKG_ACTIONS=(status list rebuild reassign download backup deactivate disable uninstall upgrade reinstall install enableau disableau sign restore clean enable activate reactivate) -IPK_ACTIONS=(downgrade download uninstall upgrade install) -PIP_ACTIONS=(uninstall upgrade install) +r_qpkg_actions=(status list rebuild reassign download backup deactivate disable uninstall upgrade reinstall install enableau disableau sign restore clean enable activate reactivate) +r_ipk_actions=(downgrade download uninstall upgrade install) +r_pip_actions=(uninstall upgrade install) # These actions may be specified by the user. # sorted -USER_QPKG_ACTIONS=(activate backup clean deactivate disable disableau enable enableau install list reactivate reassign rebuild reinstall restore sign status uninstall upgrade) +r_user_qpkg_actions=(activate backup clean deactivate disable disableau enable enableau install list reactivate reassign rebuild reinstall restore sign status uninstall upgrade) AddFlagObj() { @@ -123,54 +123,54 @@ echo $public_function_name':Add() } [[ -e $target ]] && rm -f "$target" -echo "OBJECTS_VER=''" > "$target" +echo "r_objects_version=''" > "$target" echo "#* " >> "$target" # package action flag objects. -for action in "${USER_QPKG_ACTIONS[@]}"; do - for state in "${QPKG_IS_STATES[@]}"; do +for action in "${r_user_qpkg_actions[@]}"; do + for state in "${r_qpkg_is_states[@]}"; do AddFlagObj QPKGs.AC"$action".IS"$state" done - for state in "${QPKG_ISNT_STATES[@]}"; do + for state in "${r_qpkg_isnt_states[@]}"; do AddFlagObj QPKGs.AC"$action".ISNT"$state" done - for group in "${QPKG_IS_GROUPS[@]}"; do + for group in "${r_qpkg_is_groups[@]}"; do AddFlagObj QPKGs.AC"$action".GR"$group" done - for group in "${QPKG_ISNT_GROUPS[@]}"; do + for group in "${r_qpkg_isnt_groups[@]}"; do AddFlagObj QPKGs.AC"$action".GRNT"$group" done done # session list objects. -for action in "${QPKG_ACTIONS[@]}"; do +for action in "${r_qpkg_actions[@]}"; do for prefix in to ok er sk so se sa dn; do # to-do, done ok, done error, skipped, skipped-but-ok, skipped-with-error, skipped-with-abort, done (all processed QPKGs are placed in the 'done' list, as-well as the regular exit status lists). AddListObj "QPKGs-AC${action}-${prefix}" done done -for state in "${QPKG_IS_STATES[@]}" "${QPKG_STATES_TRANSIENT[@]}" "${QPKG_SERVICE_RESULTS[@]}"; do +for state in "${r_qpkg_is_states[@]}" "${r_qpkg_states_transient[@]}" "${r_qpkg_service_results[@]}"; do AddListObj QPKGs-IS"$state" done -for state in "${QPKG_ISNT_STATES[@]}" "${QPKG_STATES_TRANSIENT[@]}" "${QPKG_SERVICE_RESULTS[@]}"; do +for state in "${r_qpkg_isnt_states[@]}" "${r_qpkg_states_transient[@]}" "${r_qpkg_service_results[@]}"; do AddListObj QPKGs-ISNT"$state" done -for group in "${QPKG_IS_GROUPS[@]}"; do +for group in "${r_qpkg_is_groups[@]}"; do AddListObj QPKGs-GR"$group" done -for group in "${QPKG_ISNT_GROUPS[@]}"; do +for group in "${r_qpkg_isnt_groups[@]}"; do AddListObj QPKGs-GRNT"$group" done -for action in "${IPK_ACTIONS[@]}"; do +for action in "${r_ipk_actions[@]}"; do [[ $action != list ]] || continue for prefix in to ok er sk; do @@ -178,7 +178,7 @@ for action in "${IPK_ACTIONS[@]}"; do done done -for action in "${PIP_ACTIONS[@]}"; do +for action in "${r_pip_actions[@]}"; do [[ $action != list ]] || continue for prefix in to ok er; do @@ -194,8 +194,13 @@ else fi SwapTags "$target" "$target" -Squeeze "$target" "$target" +if grep -q '' "$target"; then + ColourTextBrightRed "'$target' contains unswapped tags, can't continue"; echo + exit 1 +fi + +Squeeze "$target" "$target" [[ -f $target ]] && chmod 444 "$target" exit 0 diff --git a/support/check-syntax.sh b/support/check-syntax.sh index cb7033731..86f915ced 100755 --- a/support/check-syntax.sh +++ b/support/check-syntax.sh @@ -7,7 +7,7 @@ declare -a b declare -i i=0 a+=("$support_path/$management_source_file") -b+=(1090,1117,2012,2015,2016,2018,2019,2030,2031,2034,2086,2119,2120,2128,2155,2178,2181,2194,2206,2207,2209,2254,2317) +b+=(1090,1117,2012,2015,2016,2018,2019,2030,2031,2034,2086,2119,2120,2128,2154,2155,2178,2181,2194,2206,2207,2209,2254,2317) # a+=("$support_path/*.sh") # b+=(1036,1090,1091,2001,2006,2012,2016,2028,2034,2054,2086,2154,2155) diff --git a/support/sherpa-manager.source b/support/sherpa-manager.source index 240156c89..3304d5bce 100755 --- a/support/sherpa-manager.source +++ b/support/sherpa-manager.source @@ -19,13 +19,13 @@ # functions: 'CamelCase' # asynchronous functions: '_CamelCaseWithLeadingAndTrailingUnderscores_' # utility interceptors: (same as original) -# variables: 'lowercase_with_inline_underscores' +# variables: 'snakecase' # flag "object" methods: 'Capitalised.CamelCase.With.Inline.Periods.And.Colon.Before:Method' # flag "object" tests: 'Capitalised.CamelCase.With.Inline.Periods.And.Period.Before.Test' # list "object" methods: 'Capitalised-CamelCase-With-Inline-Hyphens-And-Colon-Before:Method' # list "object" tests: 'Capitalised-CamelCase-With-Inline-Hyphens-And-Period-Before.Test' -# "object" properties: '_lowercase_with_leading_and_inline_and_trailing_underscores_' (these should be managed ONLY by the object's methods) -# constants: 'UPPERCASE_WITH_INLINE_UNDERSCORES' (and set as readonly) +# "object" properties: '_snakecase_with_leading_and_trailing_underscores_' (these should be managed ONLY by the object's methods) +# constants: 'r_snakecase_with_leading_r_underscore' (set as readonly ASAP) # indents: 1 x tab char (= 4 space chars) # # Notes: @@ -36,7 +36,7 @@ set -o nounset -o pipefail shopt -s extglob [[ $- != *m* ]] || set +m # Disable job control if-enabled (only needed for QTS 4.2.6). ln -fns /proc/self/fd /dev/fd # KLUDGE: `/dev/fd` isn't always created by QTS. -readonly ARGS_RAW=$* +readonly r_args_raw=$* Init() { @@ -109,7 +109,7 @@ ShowResults() if [[ $generate_list_report = true ]]; then if [[ ${packages_loaded:=false} = true ]]; then - for a in "${QPKG_IS_STATES[@]}"; do + for a in "${r_qpkg_is_states[@]}"; do case $a in downloaded|signed) : # No reports required for these. @@ -175,7 +175,7 @@ ShowResults() DebugInfoMinSepr DebugScript finished "$(ConvertNowToFullDate)" - DebugScript 'elapsed time' "$(ConvertSecondsToDuration "$(($(ConvertNowToSeconds)-SCRIPT_STARTSECONDS))")" + DebugScript 'elapsed time' "$(ConvertSecondsToDuration "$(($(ConvertNowToSeconds)-r_script_startseconds))")" DebugInfoMajSepr [[ $title_shown = true ]] && Display # Final on-screen linespace. @@ -191,16 +191,16 @@ DebugLogInit() { DebugInfoMajSepr - DebugScript started "$(ConvertSecondsToFullDate "$SCRIPT_STARTSECONDS")" + DebugScript started "$(ConvertSecondsToFullDate "$r_script_startseconds")" DebugScript PID "$$" DebugInfoMinSepr DebugInfo 'Markers: (**) detected, (II) information, (WW) warning, (EE) error, (LL) log file, (--) processing,' DebugInfo '(==) done, (>>) f entry, (<<) f exit, (aa) array name & values, (vv) variable name & value,' DebugInfo '($1) positional argument value' DebugInfoMinSepr - DebugVar THIS_PACKAGE_VER - DebugVar THIS_SCRIPT_VER - DebugVar LOADER_SCRIPT_VER + DebugVar r_this_package_ver + DebugVar r_this_script_ver + DebugVar LOADER_SCRIPT_VERSION } @@ -208,86 +208,89 @@ LoadConsts() { # QPKG actions. - readonly QPKG_DISABLE_TIMEOUT_SECONDS=10 - readonly QPKG_ENABLE_TIMEOUT_SECONDS=10 - readonly QPKG_RESTART_TIMEOUT_SECONDS=1800 # 30 minutes - readonly QPKG_START_TIMEOUT_SECONDS=1500 # 25 minutes - readonly QPKG_STATUS_CHECK_TIMEOUT_SECONDS=15 - readonly QPKG_STOP_TIMEOUT_SECONDS=300 # 5 minutes - - # Report formatting. - readonly ACTION_RESULT_INDENT=6 - readonly COLUMN_SPACING=2 - readonly FILE_BYTES_COL_WIDTH=16 - readonly FILE_CHANGE_DATE_COL_WIDTH=60 - readonly FOOTER_NAME_COL_WIDTH=14 - readonly HELP_DESC_INDENT=3 - readonly HELP_SYNTAX_INDENT=6 - - readonly STD_COL_WIDTH=28 # Use this width for all report columns when GNU `awk` isn't available. - readonly PACKAGE_ABBS_COL_WIDTH=84 - readonly PACKAGE_ACTION_COL_WIDTH=27 - readonly PACKAGE_ACTIVE_TEST_BUILTIN_COL_WIDTH=11 - readonly PACKAGE_APP_VER_COL_WIDTH=22 - readonly PACKAGE_ARCH_COL_WIDTH=15 - readonly PACKAGE_AUTHOR_COL_WIDTH=40 - readonly PACKAGE_AUTO_UPDATE_COL_WIDTH=10 - readonly PACKAGE_COMPATIBLE_COL_WIDTH=9 - readonly PACKAGE_DEPENDENCIES_COL_WIDTH=29 - readonly PACKAGE_DESCRIPTION_COL_WIDTH=10 - readonly PACKAGE_ENABLED_COL_WIDTH=10 - readonly PACKAGE_INSTALL_DATE_COL_WIDTH=20 - readonly PACKAGE_INSTALLED_COL_WIDTH=12 - readonly PACKAGE_MANAGED_COL_WIDTH=10 - readonly PACKAGE_MAX_OS_COL_WIDTH=10 - readonly PACKAGE_MIN_OS_COL_WIDTH=10 - readonly PACKAGE_MIN_RAM_COL_WIDTH=14 - readonly PACKAGE_NAME_COL_WIDTH=21 - readonly FILE_NAME_COL_WIDTH=$((PACKAGE_NAME_COL_WIDTH+14)) - readonly PACKAGE_PATH_COL_WIDTH=48 - readonly PACKAGE_REPO_COL_WIDTH=40 - readonly PACKAGE_STATUS_COL_WIDTH=23 - readonly PACKAGE_SUPPORTS_BACKUP_COL_WIDTH=10 - readonly PACKAGE_SUPPORTS_CLEAN_COL_WIDTH=11 - readonly PACKAGE_SUPPORTS_START_TO_UPDATE_COL_WIDTH=11 - readonly PACKAGE_TIER_COL_WIDTH=8 - readonly PACKAGE_VER_COL_WIDTH=15 - - # For reports and onscreen display. - readonly CHARS_ALERT='! ' - readonly CHARS_ATTENTION='* ' - readonly CHARS_BLANK=' ' - readonly CHARS_BULLET='• ' - readonly CHARS_DROPEND='└─ ' - readonly CHARS_ELLIPSIS='...' - readonly CHARS_NORMAL='- ' - readonly CHARS_NOTE='* ' - readonly CHARS_REGULAR_PROMPT='$ ' - readonly CHARS_SUDO_PROMPT="${CHARS_REGULAR_PROMPT}sudo " - readonly CHARS_RESULTS='= ' - readonly CHAR_SPACER=' ' - readonly CHARS_SUPER_PROMPT='# ' - - readonly DEBUG_LOG_DATAWIDTH=101 - readonly DEBUG_LOG_FIRST_COL_WIDTH=9 - readonly DEBUG_LOG_SECOND_COL_WIDTH=22 - readonly DEBUG_LOG_THIRD_COL_WIDTH=$((DEBUG_LOG_DATAWIDTH-DEBUG_LOG_FIRST_COL_WIDTH-DEBUG_LOG_SECOND_COL_WIDTH-4)) + + readonly r_qpkg_disable_timeout_seconds=10 + readonly r_qpkg_enable_timeout_seconds=10 + readonly r_qpkg_restart_timeout_seconds=1800 # 30 minutes + readonly r_qpkg_start_timeout_seconds=1500 # 25 minutes + readonly r_qpkg_status_check_timeout_seconds=15 + readonly r_qpkg_stop_timeout_seconds=300 # 5 minutes + + # Fixed-widths for report columns when GNU `awk` isn't available. + + readonly r_report_qpkg_abbreviations_column_width=84 + readonly r_report_qpkg_action_column_width=27 + readonly r_report_qpkg_active_test_builtin_column_width=11 + readonly r_report_qpkg_appl_version_column_width=22 + readonly r_report_qpkg_arch_column_width=15 + readonly r_report_qpkg_author_column_width=40 + readonly r_report_qpkg_auto_update_column_width=10 + readonly r_report_qpkg_dependencies_column_width=29 + readonly r_report_qpkg_description_column_width=10 + readonly r_report_qpkg_install_date_column_width=20 + readonly r_report_qpkg_is_compatible_column_width=9 + readonly r_report_qpkg_is_enabled_column_width=10 + readonly r_report_qpkg_is_installed_column_width=12 + readonly r_report_qpkg_is_managed_column_width=10 + readonly r_report_qpkg_max_os_version_column_width=10 + readonly r_report_qpkg_min_os_version_column_width=10 + readonly r_report_qpkg_min_ram_column_width=14 + readonly r_report_qpkg_name_column_width=21 + readonly r_report_qpkg_path_column_width=48 + readonly r_report_qpkg_repo_column_width=40 + readonly r_report_qpkg_status_column_width=23 + readonly r_report_qpkg_supports_backup_column_width=10 + readonly r_report_qpkg_supports_clean_column_width=11 + readonly r_report_qpkg_supports_start_to_update_column_width=11 + readonly r_report_qpkg_tier_column_width=8 + readonly r_report_qpkg_version_column_width=15 + readonly r_report_lazy_column_width=28 # Use this when can't be bothered calculating required fixed column width. + + # Report, help and debug formatting. + + readonly r_debug_log_full_width=101 + readonly r_debug_log_first_column_width=9 + readonly r_debug_log_second_column_width=22 + readonly r_debug_log_third_column_width=$((r_debug_log_full_width-r_debug_log_first_column_width-r_debug_log_second_column_width-4)) + readonly r_help_desc_indent=3 + readonly r_help_syntax_indent=6 + readonly r_report_action_result_indent=6 + readonly r_report_column_spacing=2 + readonly r_report_file_bytes_column_width=16 + readonly r_report_file_change_date_column_width=60 + readonly r_report_file_name_column_width=$((r_report_qpkg_name_column_width+14)) + readonly r_report_footer_name_column_width=14 + + # For reports and onscreen messages. + + readonly r_chars_alert='! ' + readonly r_chars_attention='* ' + readonly r_chars_blank=' ' + readonly r_chars_bullet='• ' + readonly r_chars_dropend='└─ ' + readonly r_chars_ellipsis='...' + readonly r_chars_normal='- ' + readonly r_chars_note='* ' + readonly r_chars_regular_prompt='$ ' + readonly r_chars_sudo_prompt="${r_chars_regular_prompt}sudo " + readonly r_chars_results='= ' + readonly r_chars_super_prompt='# ' if OsIsSupportSudo; then if [[ $(UserGetSudoUID) = undefined ]]; then - readonly HELP_SYNTAX_PREFIX=$CHARS_SUPER_PROMPT - readonly HELP_SYNTAX_SUDO_PREFIX=$CHARS_SUPER_PROMPT + readonly r_help_syntax_prefix=$r_chars_super_prompt + readonly r_help_syntax_sudo_prefix=$r_chars_super_prompt else - readonly HELP_SYNTAX_PREFIX=$CHARS_REGULAR_PROMPT - readonly HELP_SYNTAX_SUDO_PREFIX=$CHARS_SUDO_PROMPT + readonly r_help_syntax_prefix=$r_chars_regular_prompt + readonly r_help_syntax_sudo_prefix=$r_chars_sudo_prompt fi else - readonly HELP_SYNTAX_PREFIX=$CHARS_SUPER_PROMPT - readonly HELP_SYNTAX_SUDO_PREFIX=$CHARS_SUPER_PROMPT + readonly r_help_syntax_prefix=$r_chars_super_prompt + readonly r_help_syntax_sudo_prefix=$r_chars_super_prompt fi - readonly FILE_CHANGE_THRESHOLD_MINUTES=60 - readonly LOG_TAIL_LINES=5000 + readonly r_file_change_threshold_minutes=60 + readonly r_log_tail_lines=5000 } @@ -316,13 +319,13 @@ LoadVars() qpkg_timeouts_increased=false report_footer_default=true run_package_actions=false - show_backuploc=false show_action_results_failed=false show_action_results_ok=false show_action_results_skipped=false + show_action_results_zero=false + show_backuploc=false show_suggest_raise_issue=false show_title=true - show_action_results_zero=false switch_branch=false switch_colour=false switch_report_footer=false @@ -501,7 +504,7 @@ LocateSQLiteBinary() [[ -e $sqlite_pathfile ]] && sqlite_cmd=$sqlite_pathfile fi - if [[ -z $sqlite_cmd ]] && QpkgIsInstalled ArchiwareP5; then # untested + if [[ -z $sqlite_cmd ]] && QpkgIsInstalled ArchiwareP5; then # untested. sqlite_pathfile=$(QpkgGetInstalledPath ArchiwareP5)/binaries/Linux/unknown/64/sqlite3 [[ -e $sqlite_pathfile ]] && sqlite_cmd=$sqlite_pathfile fi @@ -510,7 +513,7 @@ LocateSQLiteBinary() # container-station = `Container Station` if [[ -z $sqlite_cmd ]]; then - for a in container-station HD_Station; do # 'HD_Station' is untested + for a in container-station HD_Station; do # 'HD_Station' is untested. if QpkgIsInstalled "$a"; then sqlite_pathfile=$(QpkgGetInstalledPath "$a")/usr/bin/sqlite3 [[ -e $sqlite_pathfile ]] || continue @@ -562,98 +565,99 @@ LoadEnv() ShowAsProc env qpkg_name=sherpa - readonly CERT_DB_PATHFILE=/etc/config/nas_sign_qpkg.db - readonly CPU_CORES=$(HardwareGetCPUCores) - readonly CONCURRENCY=$CPU_CORES # Maximum concurrent package actions to run. Should probably make this account for CPU speed too. - readonly ENTWARE_VER=$(QpkgGetEntwareType) - readonly KERNEL_PAGE_SIZE=$(OsGetKernelPageSize) - readonly NAS_ARCH=$(OsGetArch) - readonly NAS_FIRMWARE_BUILD=$(OsGetFirmwareBuild) - readonly NAS_FIRMWARE_DATE=$(OsGetFirmwareDate) - readonly NAS_FIRMWARE_VER=$(OsGetFirmwareVer) - readonly NAS_PLATFORM=$(HardwareGetPlatform) - readonly NAS_QPKG_ARCH=$(QpkgGetArch) - readonly NAS_RAM_KB=$(HardwareGetInstalledRAM) - readonly NAS_UPSTATE=$(OsGetUpState) + readonly r_cert_db_pathfile=/etc/config/nas_sign_qpkg.db + readonly r_cpu_cores=$(HardwareGetCPUCores) + readonly r_concurrency=$r_cpu_cores # Maximum concurrent package actions to run. Should probably make this account for CPU speed too. + readonly r_entware_version=$(QpkgGetEntwareType) + readonly r_kernel_page_size=$(OsGetKernelPageSize) + readonly r_nas_arch=$(OsGetArch) + readonly r_nas_firmware_build=$(OsGetFirmwareBuild) + readonly r_nas_firmware_date=$(OsGetFirmwareDate) + readonly r_nas_firmware_version=$(OsGetFirmwareVer) + readonly r_nas_platform=$(HardwareGetPlatform) + readonly r_nas_qpkg_arch=$(QpkgGetArch) + readonly r_nas_ram_kb=$(HardwareGetInstalledRAM) + readonly r_nas_upstate=$(OsGetUpState) + readonly r_this_package_ver=$(QpkgGetInstalledVer) OsIsSupportSecureDownload || CURL_CMD+=' --insecure' readonly CURL_CMD args=() # Command-line argument array. args_incomplete=() - qpkg_index=0 qpkg_default_index=0 + qpkg_index=0 useropt_branch=$(UserGetGitBranch) - readonly OBJECTS_ARCHIVE_URL=''/$useropt_branch/objects.tar.gz - readonly PACKAGES_ARCHIVE_URL=''/$useropt_branch/packages.tar.gz - readonly QPKG_BU_PATH=$(UserGetDefVol)/.qpkg_config_backup - readonly THIS_PACKAGE_PATH=$(QpkgGetInstalledPath) - if [[ -z $THIS_PACKAGE_PATH || $THIS_PACKAGE_PATH = undefined || ! -d $THIS_PACKAGE_PATH ]]; then + readonly r_objects_archive_url=''/$useropt_branch/objects.tar.gz + readonly r_packages_archive_url=''/$useropt_branch/packages.tar.gz + readonly r_this_script_ver=''-$useropt_branch + readonly r_qpkg_bu_path=$(UserGetDefVol)/.qpkg_config_backup + readonly r_this_package_path=$(QpkgGetInstalledPath) + if [[ -z $r_this_package_path || $r_this_package_path = undefined || ! -d $r_this_package_path ]]; then ShowAsError "$(ShowAsTitleName) installation path not found. Please reinstall the $(ShowAsTitleName) QPKG" return 1 fi - readonly CACHE_PATH=$THIS_PACKAGE_PATH/cache - readonly ACTION_TIMES_PATH=$CACHE_PATH/action.times - readonly ASYNC_PROCS_PATH=$CACHE_PATH/proc - readonly DEPENDENT_QPKGS_LIST_PATHFILE=$CACHE_PATH/dependents - readonly DISPLAY_INHIBIT_PATHFILE=$CACHE_PATH/display.inhibit - readonly INDEPENDENT_QPKGS_LIST_PATHFILE=$CACHE_PATH/independents - readonly IPK_CACHE_PATH=$CACHE_PATH/IPKs - readonly IPK_DL_PATH=$IPK_CACHE_PATH/downloads - readonly IPK_DOWNGRADE_PATH=$IPK_CACHE_PATH/downgrade - readonly PREV_IPK_LIST=$IPK_CACHE_PATH/ipk.list.save - readonly PIP_CACHE_PATH=$CACHE_PATH/PIPs - readonly PREV_PIP_LIST=$PIP_CACHE_PATH/pip.list.save - readonly OBJECTS_ARCHIVE_PATHFILE=$CACHE_PATH/objects.tar.gz - readonly OBJECTS_PATHFILE=$CACHE_PATH/objects - readonly PACKAGES_ARCHIVE_PATHFILE=$CACHE_PATH/packages.tar.gz - readonly PACKAGES_PATHFILE=$CACHE_PATH/packages - readonly QPKG_CACHE_PATH=$CACHE_PATH/QPKGs - readonly QPKG_DL_PATH=$QPKG_CACHE_PATH/downloads - readonly LOGS_PATH=$THIS_PACKAGE_PATH/logs - readonly OOM_LOG_PATHFILE=$LOGS_PATH/oom.log - readonly RAM_FREEUSED_PATHFILE=$LOGS_PATH/ram.freeused - readonly RAMFS_FREESPACE_PATHFILE=$LOGS_PATH/ramfs.freespace - readonly SCREEN_SESSIONS_PATHFILE=$LOGS_PATH/screen.sessions - readonly SESS_ACTION_RESULTS_PATHFILE=$LOGS_PATH/session.action.results.log - readonly SESS_ARCHIVE_PATHFILE=$LOGS_PATH/session.archive.log - readonly SESS_LAST_PATHFILE=$LOGS_PATH/session.last.log - readonly SESS_TAIL_PATHFILE=$LOGS_PATH/session.tail.log - sess_active_pathfile=$THIS_PACKAGE_PATH/session.$$.active.log - - # Ephemeral - readonly ACTION_FORKS_COUNT=/var/run/sherpa/actions/forks - readonly ACTION_LOGS_PATH=/var/log/sherpa/actions/logs - readonly QPKG_STATES_PATH=/var/run/sherpa/packages/states - readonly ACTION_ABORT_PATHFILE=$QPKG_STATES_PATH/abort.action - readonly ACTION_MSG_PIPE=$QPKG_STATES_PATH/action.messages.pipe - readonly REPORT_COLS_PATH=/var/run/sherpa/report/columns - readonly REPORT_FLAGS_PATH=/var/run/sherpa/report/flags - readonly REPORTS_PATH=/var/log/sherpa/reports - readonly REPORT_OUTPUT_PATHFILE=$REPORTS_PATH/report.ansi - readonly RUN_LOGS_PATH=/var/run/sherpa/run.logs - - readonly THIS_PACKAGE_VER=$(QpkgGetInstalledVer) - readonly THIS_SCRIPT_VER=''-$useropt_branch + readonly r_cache_path=$r_this_package_path/cache + readonly r_action_times_path=$r_cache_path/action.times + readonly r_async_procs_path=$r_cache_path/proc + readonly r_dependent_qpkgs_list_pathfile=$r_cache_path/dependents + readonly r_display_inhibit_pathfile=$r_cache_path/display.inhibit + readonly r_independent_qpkgs_list_pathfile=$r_cache_path/independents + readonly r_ipk_cache_path=$r_cache_path/IPKs + readonly r_ipk_downgrade_path=$r_ipk_cache_path/downgrade + readonly r_ipk_download_path=$r_ipk_cache_path/downloads + readonly r_prev_ipk_list_pathfile=$r_ipk_cache_path/ipk.list.save + readonly r_objects_archive_pathfile=$r_cache_path/objects.tar.gz + readonly r_objects_pathfile=$r_cache_path/objects + readonly r_packages_archive_pathfile=$r_cache_path/packages.tar.gz + readonly r_packages_pathfile=$r_cache_path/packages + readonly r_pip_cache_path=$r_cache_path/PIPs + readonly r_prev_pip_list_pathfile=$r_pip_cache_path/pip.list.save + readonly r_qpkg_cache_path=$r_cache_path/QPKGs + readonly r_qpkg_download_path=$r_qpkg_cache_path/downloads + readonly r_logs_path=$r_this_package_path/logs + readonly r_oom_log_pathfile=$r_logs_path/oom.log + readonly r_ram_freeused_pathfile=$r_logs_path/ram.freeused + readonly r_ramfs_freespace_pathfile=$r_logs_path/ramfs.freespace + readonly r_screen_sessions_pathfile=$r_logs_path/screen.sessions + readonly r_session_action_results_pathfile=$r_logs_path/session.action.results.log + readonly r_session_archive_pathfile=$r_logs_path/session.archive.log + readonly r_session_last_pathfile=$r_logs_path/session.last.log + readonly r_session_tail_pathfile=$r_logs_path/session.tail.log + sess_active_pathfile=$r_this_package_path/session.$$.active.log + + # Ephemeral files. + + readonly r_action_forks_count=/var/run/sherpa/actions/forks + readonly r_action_logs_path=/var/log/sherpa/actions/logs + readonly r_qpkg_states_path=/var/run/sherpa/packages/states + readonly r_action_abort_pathfile=$r_qpkg_states_path/abort.action + readonly r_action_msg_pipe=$r_qpkg_states_path/action.messages.pipe + readonly r_report_columns_path=/var/run/sherpa/report/columns + readonly r_report_flags_path=/var/run/sherpa/report/flags + readonly r_reports_path=/var/log/sherpa/reports + readonly r_report_output_pathfile=$r_reports_path/report.ansi + readonly r_run_logs_path=/var/run/sherpa/run.logs # Entware - readonly EXTERNAL_PACKAGES_ARCHIVE_PATHFILE=/opt/var/opkg-lists/entware - readonly EXTERNAL_PACKAGES_PATHFILE=$CACHE_PATH/Packages + + readonly r_external_packages_archive_pathfile=/opt/var/opkg-lists/entware + readonly r_external_packages_pathfile=$r_cache_path/Packages # KLUDGE: just in-case `python` has disappeared again ... ¯\_(ツ)_/¯ [[ -e $PYTHON3_CMD && ! -L $PYTHON_CMD ]] && ln -s "$PYTHON3_CMD" "$PYTHON_CMD" - rm -f "$REPORT_OUTPUT_PATHFILE" "$RAMFS_FREESPACE_PATHFILE" "$DISPLAY_INHIBIT_PATHFILE" 2> /dev/null + rm -f "$r_report_output_pathfile" "$r_ramfs_freespace_pathfile" "$r_display_inhibit_pathfile" 2> /dev/null if [[ -e $GNU_STTY_CMD && -t 0 ]]; then local terminal_dimensions=$($GNU_STTY_CMD size) - readonly SESS_ROWS=${terminal_dimensions% *} - readonly SESS_COLS=${terminal_dimensions#* } + readonly r_sess_rows=${terminal_dimensions% *} + readonly r_sess_columns=${terminal_dimensions#* } else - readonly SESS_ROWS=40 - readonly SESS_COLS=156 + readonly r_sess_rows=40 + readonly r_sess_columns=156 fi } @@ -665,47 +669,50 @@ LoadLists() # These are used internally by sherpa. # ordered - PACKAGE_TIERS=(independent auxiliary dependent) + + r_package_tiers=(independent auxiliary dependent) # sorted - QPKG_IS_STATES=(active backedup downloaded enabled installable installed missing signed upgradable) - QPKG_ISNT_STATES=(active backedup downloaded enabled installable installed missing signed upgradable) - QPKG_IS_GROUPS=(all canbackup canclean canrestarttoupdate dependent hasdependents independent) - QPKG_ISNT_GROUPS=(canclean) - QPKG_STATES_TRANSIENT=(restarting slow starting stopping unknown) - QPKG_SERVICE_RESULTS=(failed ok) + + r_qpkg_is_states=(active backedup downloaded enabled installable installed missing signed upgradable) + r_qpkg_isnt_states=(active backedup downloaded enabled installable installed missing signed upgradable) + r_qpkg_is_groups=(all canbackup canclean canrestarttoupdate dependent hasdependents independent) + r_qpkg_isnt_groups=(canclean) + r_qpkg_states_transient=(restarting slow starting stopping unknown) + r_qpkg_service_results=(failed ok) # ordered - QPKG_ACTIONS=(status list rebuild reassign download backup deactivate disable uninstall upgrade reinstall install enableau disableau sign restore clean enable activate reactivate) - IPK_ACTIONS=(downgrade download uninstall upgrade install) - PIP_ACTIONS=(uninstall upgrade install) + + r_qpkg_actions=(status list rebuild reassign download backup deactivate disable uninstall upgrade reinstall install enableau disableau sign restore clean enable activate reactivate) + r_ipk_actions=(downgrade download uninstall upgrade install) + r_pip_actions=(uninstall upgrade install) # These actions may be specified by the user. # sorted - USER_QPKG_ACTIONS=(activate backup clean deactivate disable disableau enable enableau install list reactivate reassign rebuild reinstall restore sign status uninstall upgrade) + + r_user_qpkg_actions=(activate backup clean deactivate disable disableau enable enableau install list reactivate reassign rebuild reinstall restore sign status uninstall upgrade) # KLUDGE: for some reason, setting `readonly` while populating arrays causes their scope to become local, so need to set as `readonly` afterward to ensure global scope. GNU Bash, version 3.2.57(1)-release (aarch64-QNAP-linux-gnu) - readonly PACKAGE_TIERS - readonly QPKG_IS_STATES - readonly QPKG_ISNT_STATES - readonly QPKG_IS_GROUPS - readonly QPKG_ISNT_GROUPS - readonly QPKG_STATES_TRANSIENT - readonly QPKG_SERVICE_RESULTS + readonly r_package_tiers - readonly IPK_STATES + readonly r_qpkg_is_states + readonly r_qpkg_isnt_states + readonly r_qpkg_is_groups + readonly r_qpkg_isnt_groups + readonly r_qpkg_states_transient + readonly r_qpkg_service_results - readonly QPKG_ACTIONS - readonly IPK_ACTIONS - readonly PIP_ACTIONS + readonly r_qpkg_actions + readonly r_ipk_actions + readonly r_pip_actions - readonly USER_QPKG_ACTIONS + readonly r_user_qpkg_actions local action='' - for action in "${QPKG_ACTIONS[@]}" check debug downgrade update; do - readonly "$(Uppercase "$action")"_LOG_FILE=$action.log + for action in "${r_qpkg_actions[@]}" check debug downgrade update; do + readonly r_"$(Lowercase "$action")"_log_file=$action.log done lists_loaded=true @@ -715,26 +722,26 @@ LoadLists() CreatePaths() { - ClearPath "$CACHE_PATH" "$ASYNC_PROCS_PATH" - ClearPath "$CACHE_PATH" "$IPK_CACHE_PATH" - ClearPath "$CACHE_PATH" "$IPK_DL_PATH" - ClearPath "$CACHE_PATH" "$PIP_CACHE_PATH" - ClearPath /var/run/sherpa/report "$REPORT_COLS_PATH" - ClearPath /var/run/sherpa/report "$REPORT_FLAGS_PATH" + ClearPath "$r_cache_path" "$r_async_procs_path" + ClearPath "$r_cache_path" "$r_ipk_cache_path" + ClearPath "$r_cache_path" "$r_ipk_download_path" + ClearPath "$r_cache_path" "$r_pip_cache_path" + ClearPath /var/run/sherpa/report "$r_report_columns_path" + ClearPath /var/run/sherpa/report "$r_report_flags_path" - MakePath "$ACTION_TIMES_PATH" 'action times' || return - MakePath "$ASYNC_PROCS_PATH" 'asynchronous process tracking' || return - MakePath "$CACHE_PATH" cache || return - MakePath "$IPK_CACHE_PATH" 'IPK cache' || return - MakePath "$IPK_DL_PATH" 'IPK download' || return - MakePath "$IPK_DOWNGRADE_PATH" 'IPK downgrade' || return - MakePath "$LOGS_PATH" logs || return - MakePath "$PIP_CACHE_PATH" 'PIP cache' || return - MakePath "$REPORT_COLS_PATH" 'report columns' || return - MakePath "$REPORT_FLAGS_PATH" 'report flags' || return - MakePath "$REPORTS_PATH" reports || return - MakePath "$QPKG_BU_PATH" 'QPKG backup' || return - MakePath "$QPKG_DL_PATH" 'QPKG download' || return + MakePath "$r_action_times_path" 'action times' || return + MakePath "$r_async_procs_path" 'asynchronous process tracking' || return + MakePath "$r_cache_path" cache || return + MakePath "$r_ipk_cache_path" 'IPK cache' || return + MakePath "$r_ipk_download_path" 'IPK download' || return + MakePath "$r_ipk_downgrade_path" 'IPK downgrade' || return + MakePath "$r_logs_path" logs || return + MakePath "$r_pip_cache_path" 'PIP cache' || return + MakePath "$r_report_columns_path" 'report columns' || return + MakePath "$r_report_flags_path" 'report flags' || return + MakePath "$r_reports_path" reports || return + MakePath "$r_qpkg_bu_path" 'QPKG backup' || return + MakePath "$r_qpkg_download_path" 'QPKG download' || return } @@ -751,39 +758,39 @@ DebugLogEnv() DebugInfoMinSepr DebugHardware ok model "$(get_display_name)" DebugHardware ok CPU "$(HardwareGetCPUInfo)" - DebugHardware ok 'CPU cores' "$CPU_CORES" - DebugHardware ok 'CPU architecture' "$NAS_ARCH" - DebugHardware ok RAM "$(FormatAsThous "$NAS_RAM_KB")kiB" + DebugHardware ok 'CPU cores' "$r_cpu_cores" + DebugHardware ok 'CPU architecture' "$r_nas_arch" + DebugHardware ok RAM "$(FormatAsThous "$r_nas_ram_kb")kiB" DebugFirmware ok OS "$(OsGetQnapOS)" if OsIsSupported; then - DebugFirmware ok version "$NAS_FIRMWARE_VER.$NAS_FIRMWARE_BUILD" + DebugFirmware ok version "$r_nas_firmware_version.$r_nas_firmware_build" else - DebugFirmware warning version "$NAS_FIRMWARE_VER" + DebugFirmware warning version "$r_nas_firmware_version" fi if OsIsCompatibleWithSigned; then - DebugFirmware ok 'build date' "$NAS_FIRMWARE_DATE" + DebugFirmware ok 'build date' "$r_nas_firmware_date" else - DebugFirmware warning 'build date' "$NAS_FIRMWARE_DATE" + DebugFirmware warning 'build date' "$r_nas_firmware_date" fi DebugFirmware ok 'kernel version' "$(OsGetKernelVersion)" if OsIsStdKernelPageSize; then - DebugFirmware ok 'kernel page size' "${KERNEL_PAGE_SIZE}B" + DebugFirmware ok 'kernel page size' "${r_kernel_page_size}B" else - DebugFirmware warning 'kernel page size' "${KERNEL_PAGE_SIZE}B" + DebugFirmware warning 'kernel page size' "${r_kernel_page_size}B" fi - DebugFirmware ok platform "$NAS_PLATFORM" + DebugFirmware ok platform "$r_nas_platform" - case $NAS_UPSTATE in + case $r_nas_upstate in starting-up|shutting-down) - DebugFirmware warning 'OS state' "$NAS_UPSTATE" + DebugFirmware warning 'OS state' "$r_nas_upstate" ;; *) - DebugFirmware ok 'OS state' "$NAS_UPSTATE" + DebugFirmware ok 'OS state' "$r_nas_upstate" esac DebugFirmware ok 'OS uptime' "$(OsGetUptime)" @@ -818,15 +825,15 @@ DebugLogEnv() DebugUserspace warning "'$public_share' share" 'not present' fi - if [[ ${#PATH} -le $DEBUG_LOG_THIRD_COL_WIDTH ]]; then + if [[ ${#PATH} -le $r_debug_log_third_column_width ]]; then DebugUserspace ok '$PATH' "$PATH" else - DebugUserspace ok '$PATH (LHS-only)' "${PATH:0:$((DEBUG_LOG_THIRD_COL_WIDTH-${#CHARS_ELLIPSIS}))}${CHARS_ELLIPSIS}" + DebugUserspace ok '$PATH (LHS-only)' "${PATH:0:$((r_debug_log_third_column_width-${#r_chars_ellipsis}))}${r_chars_ellipsis}" fi DebugScript 'git branch' "$useropt_branch" - DebugScript 'logs path' "$LOGS_PATH" - DebugScript 'action concurrency' "$CONCURRENCY" + DebugScript 'logs path' "$r_logs_path" + DebugScript 'action concurrency' "$r_concurrency" if OsIsSupportUnofficialPackages; then if OsIsAllowUnofficialPackages; then @@ -848,8 +855,8 @@ DebugLogEnv() DebugQpkg detect 'allow unsigned' N/A fi - DebugQpkg detect architecture "$NAS_QPKG_ARCH" - DebugQpkg detect "$(ShowAsPackageName Entware) type" "$ENTWARE_VER" + DebugQpkg detect architecture "$r_nas_qpkg_arch" + DebugQpkg detect "$(ShowAsPackageName Entware) type" "$r_entware_version" DebugQpkg detect "$(ShowAsPackageName Entware) install date" "$(QpkgGetInstalledDate Entware)" if QpkgIsInstalled SortMyQPKGs; then @@ -873,13 +880,13 @@ DebugLogEnv() fi DebugInfoMinSepr - RunAndLog "$DF_CMD -h | $GREP_CMD '^Filesystem\|^none\|^tmpfs\|ram'" "$RAMFS_FREESPACE_PATHFILE" + RunAndLog "$DF_CMD -h | $GREP_CMD '^Filesystem\|^none\|^tmpfs\|ram'" "$r_ramfs_freespace_pathfile" DebugInfoMinSepr - RunAndLog "$SCREEN_CMD -ls" "$SCREEN_SESSIONS_PATHFILE" '' 1 + RunAndLog "$SCREEN_CMD -ls" "$r_screen_sessions_pathfile" '' 1 DebugInfoMinSepr - RunAndLog '/usr/bin/free' "$RAM_FREEUSED_PATHFILE" '' 1 + RunAndLog '/usr/bin/free' "$r_ram_freeused_pathfile" '' 1 DebugInfoMinSepr - RunAndLog "$GREP_CMD -i 'out of memory\|oom-killer' /mnt/HDA_ROOT/.logs/kmsg" "$OOM_LOG_PATHFILE" '' 1 + RunAndLog "$GREP_CMD -i 'out of memory\|oom-killer' /mnt/HDA_ROOT/.logs/kmsg" "$r_oom_log_pathfile" '' 1 DebugInfoMinSepr FuncExit @@ -919,34 +926,34 @@ CheckTasks() else LoadPackages - for action in "${USER_QPKG_ACTIONS[@]}"; do + for action in "${r_user_qpkg_actions[@]}"; do if QPKGs-AC${action}-to.IsAny; then build_states=true break fi - for group in "${QPKG_IS_GROUPS[@]}"; do + for group in "${r_qpkg_is_groups[@]}"; do if QPKGs.AC${action}.GR${group}.IsSet; then build_states=true break 2 fi done - for group in "${QPKG_ISNT_GROUPS[@]}"; do + for group in "${r_qpkg_isnt_groups[@]}"; do if QPKGs.AC${action}.GRNT${group}.IsSet; then build_states=true break 2 fi done - for state in "${QPKG_IS_STATES[@]}"; do + for state in "${r_qpkg_is_states[@]}"; do if QPKGs.AC${action}.IS${state}.IsSet; then build_states=true break 2 fi done - for state in "${QPKG_ISNT_STATES[@]}"; do + for state in "${r_qpkg_isnt_states[@]}"; do if QPKGs.AC${action}.ISNT${state}.IsSet; then build_states=true break 2 @@ -983,7 +990,7 @@ CheckEnv() fi if QpkgIsInstalled Entware; then - if [[ $ENTWARE_VER != none ]]; then + if [[ $r_entware_version != none ]]; then _UpdateEntwarePackageList_ & # Let's try launching this early. else DebugAsWarn "$(ShowAsPackageName Entware) appears to be installed but is inactive. Please consider starting the $(ShowAsPackageName Entware) QPKG." @@ -1009,7 +1016,7 @@ CheckEnv() # Decide if specific IPKs should be uninstalled/downgraded. - case $NAS_QPKG_ARCH in + case $r_nas_qpkg_arch in a41) # These must be downgraded on armv7 when QTS has a non-standard kernel page size. # https://forum.qnap.com/viewtopic.php?p=850945#p850945 @@ -1022,7 +1029,7 @@ CheckEnv() if [[ ${installed_version//.} -gt 238 ]]; then ipks_downgrade=true - ShowAsNote "various IPKs will be downgraded to suit ${KERNEL_PAGE_SIZE}B kernel page size" + ShowAsNote "various IPKs will be downgraded to suit ${r_kernel_page_size}B kernel page size" IPKs-ACdowngrade-to:Add "$target_packages" else IPKs-ACdowngrade-sk:Add "$target_packages" @@ -1085,7 +1092,7 @@ QPKGsAssignToActions() if QpkgIsInstalled Entware; then local entware_install_date=$(QpkgGetInstalledDate Entware) - if [[ $entware_install_date = undefined || ${entware_install_date//[!0-9]/} -le 20240809 ]] && [[ $NAS_ARCH != armv5tel ]]; then + if [[ $entware_install_date = undefined || ${entware_install_date//[!0-9]/} -le 20240809 ]] && [[ $r_nas_arch != armv5tel ]]; then ShowAsNote "the $(TextBrightOrange Entware) QPKG will be auto-reinstalled (Entware packages were updated early in August 2024)" QPKGs-ACreinstall-to:Add Entware fi @@ -1326,7 +1333,7 @@ ProcActions() local state='' local -i tier_index=0 - rm -f "$SESS_ACTION_RESULTS_PATHFILE" 2> /dev/null + rm -f "$r_session_action_results_pathfile" 2> /dev/null # -> Package preparation phase <- @@ -1335,12 +1342,12 @@ ProcActions() if [[ $useropt_show_status = false ]]; then ShowAsProc 'assign QPKGs by state' # Update action lists based-on QPKG `status`. - for action in "${USER_QPKG_ACTIONS[@]}"; do - for state in "${QPKG_IS_STATES[@]}"; do + for action in "${r_user_qpkg_actions[@]}"; do + for state in "${r_qpkg_is_states[@]}"; do QPKGs.AC${action}.IS${state}.IsSet && QPKGs-AC${action}-to:Add "$(QPKGs-IS${state}:Array)" done - for state in "${QPKG_ISNT_STATES[@]}"; do + for state in "${r_qpkg_isnt_states[@]}"; do QPKGs.AC${action}.ISNT${state}.IsSet && QPKGs-AC${action}-to:Add "$(QPKGs-ISNT${state}:Array)" done done @@ -1355,8 +1362,8 @@ ProcActions() if QPKGs-ACdownload-er.IsNone && QPKGs-ACdownload-se.IsNone && QPKGs-ACdownload-sa.IsNone; then # -> Package removal phase <- - for ((tier_index=${#PACKAGE_TIERS[@]}-1; tier_index>=0; tier_index--)); do # Process tiers in-reverse - tier=${PACKAGE_TIERS[$tier_index]} + for ((tier_index=${#r_package_tiers[@]}-1; tier_index>=0; tier_index--)); do # Process tiers in-reverse + tier=${r_package_tiers[$tier_index]} case $tier in ?(in)dependent) @@ -1377,7 +1384,7 @@ ProcActions() # -> Package installation phase <- - for tier in "${PACKAGE_TIERS[@]}"; do + for tier in "${r_package_tiers[@]}"; do case $tier in ?(in)dependent) ProcAction upgrade $tier QPKG upgrade upgraded @@ -1449,8 +1456,8 @@ ProcAction() # $5 = past action verb e.g. `activated` ... # Inputs: (global) - # $ACTION_ABORT_PATHFILE - # $ASYNC_PROCS_PATH + # $r_action_abort_pathfile + # $r_async_procs_path # $fail_count # $ok_count # $skip_abort_count @@ -1482,8 +1489,9 @@ ProcAction() FuncInit - local -r ACTION_PAST=${5:?${FUNCNAME[0]}'()': undefined action past} - local -r ACTION_PRESENT_MSG=${4:?${FUNCNAME[0]}'()': undefined action present} + local -r r_action=${1:?${FUNCNAME[0]}'()': undefined action} + local -r r_action_past_msg=${5:?${FUNCNAME[0]}'()': undefined action past} + local -r r_action_present_msg=${4:?${FUNCNAME[0]}'()': undefined action present} local group='' local msg1_key='' local msg1_value='' @@ -1492,27 +1500,26 @@ ProcAction() local original_colourful=$useropt_colourful local package='' local -i package_index=0 - local -r PACKAGE_TYPE=${3:?${FUNCNAME[0]}'()': undefined package type} + local -r r_package_type=${3:?${FUNCNAME[0]}'()': undefined package type} local re='' local state='' - local -r TARGET_ACTION=${1:?${FUNCNAME[0]}'()': undefined action} local -a target_packages=() - local -r TIER=${2:?${FUNCNAME[0]}'()': undefined tier} + local -r r_tier=${2:?${FUNCNAME[0]}'()': undefined tier} total_count=0 - DebugVar TARGET_ACTION - DebugVar TIER - DebugVar PACKAGE_TYPE + DebugVar r_action + DebugVar r_tier + DebugVar r_package_type - case $PACKAGE_TYPE in + case $r_package_type in QPKG) - TARGET_OBJECT_NAME=AC${TARGET_ACTION}-to + target_object_name=AC${r_action}-to - if [[ $TIER = all ]]; then # Process all tiers. - target_packages=($(${PACKAGE_TYPE}s-$TARGET_OBJECT_NAME:Array)) + if [[ $r_tier = all ]]; then # Process all tiers. + target_packages=($(${r_package_type}s-$target_object_name:Array)) else # Process a single tier only. - for package in $(${PACKAGE_TYPE}s-$TARGET_OBJECT_NAME:Array); do - ${PACKAGE_TYPE}s-GR${TIER}.Exist "$package" && target_packages+=("$package") + for package in $(${r_package_type}s-$target_object_name:Array); do + ${r_package_type}s-GR${r_tier}.Exist "$package" && target_packages+=("$package") done fi @@ -1526,30 +1533,30 @@ ProcAction() fi if [[ $total_count -eq 1 ]]; then - fork_progress_prefix="$ACTION_PRESENT_MSG $(TextBrightOrange "${target_packages[0]}") $PACKAGE_TYPE" + fork_progress_prefix="$r_action_present_msg $(TextBrightOrange "${target_packages[0]}") $r_package_type" else - fork_progress_prefix="$ACTION_PRESENT_MSG $([[ $TIER != all ]] && echo "$TIER ")$(Uppercase "$PACKAGE_TYPE")$(Pluralise "$total_count")" + fork_progress_prefix="$r_action_present_msg $([[ $r_tier != all ]] && echo "$r_tier ")$(Uppercase "$r_package_type")$(Pluralise "$total_count")" fi - SetMaxForks "$TARGET_ACTION" + SetMaxForks "$r_action" InitForkCounts OpenActionMsgPipe re=\\bEntware\\b # Bash 3.2 regex with word boundaries: https://stackoverflow.com/a/9793094 - if [[ $TARGET_ACTION = uninstall && ${target_packages[*]} =~ $re ]]; then + if [[ $r_action = uninstall && ${target_packages[*]} =~ $re ]]; then ShowKeystrokes # Enable this before removing Entware & GNU `stty`. fi - pidfile=$($MKTEMP_CMD "$ASYNC_PROCS_PATH"/bgproc_XXXXXX) # Set $pidfile here, before launching async process so it's inherited by that process. + pidfile=$($MKTEMP_CMD "$r_async_procs_path"/bgproc_XXXXXX) # Set $pidfile here, before launching async process so it's inherited by that process. - _ExecOneActionWithManyForks_ "_${PACKAGE_TYPE}:${TARGET_ACTION}_" "${target_packages[@]}" & + _ExecOneActionWithManyForks_ "_${r_package_type}:${r_action}_" "${target_packages[@]}" & echo "$!" > "$pidfile" # Read message pipe and process QPKGs and actions as-per requests contained within. - while [[ ${#target_packages[@]} -gt 0 && ! -e $ACTION_ABORT_PATHFILE ]]; do + while [[ ${#target_packages[@]} -gt 0 && ! -e $r_action_abort_pathfile ]]; do ReadFromActionMsgPipe msg1_key msg1_value msg2_key msg2_value case $msg1_key in @@ -1559,7 +1566,7 @@ ProcAction() ;; change) # Change the state of a single QPKG in the parent shell. while true; do - for state in "${QPKG_IS_STATES[@]}" "${QPKG_STATES_TRANSIENT[@]}"; do + for state in "${r_qpkg_is_states[@]}" "${r_qpkg_states_transient[@]}"; do case $msg1_value in "IS${state}") [[ $(type -t QPKGs-ISNT${state}:Init) = function ]] && QPKGs-ISNT${state}:Remove "$msg2_value" @@ -1568,7 +1575,7 @@ ProcAction() esac done - for state in "${QPKG_ISNT_STATES[@]}" "${QPKG_STATES_TRANSIENT[@]}"; do + for state in "${r_qpkg_isnt_states[@]}" "${r_qpkg_states_transient[@]}"; do case $msg1_value in "ISNT${state}") [[ $(type -t QPKGs-IS${state}:Init) = function ]] && QPKGs-IS${state}:Remove "$msg2_value" @@ -1577,7 +1584,7 @@ ProcAction() esac done - for group in "${QPKG_IS_GROUPS[@]}"; do + for group in "${r_qpkg_is_groups[@]}"; do case $msg1_value in "GR${group}") [[ $(type -t QPKGs-GRNT${group}:Init) = function ]] && QPKGs-GRNT${group}:Remove "$msg2_value" @@ -1586,7 +1593,7 @@ ProcAction() esac done - for group in "${QPKG_ISNT_GROUPS[@]}"; do + for group in "${r_qpkg_isnt_groups[@]}"; do case $msg1_value in "GRNT${group}") [[ $(type -t QPKGs-GR${group}:Init) = function ]] && QPKGs-GR${group}:Remove "$msg2_value" @@ -1602,33 +1609,33 @@ ProcAction() ;; status) # Update the status of a single action fork in the parent shell. case $msg1_value in - ok) # Completed OK (wonderful!). - [[ $TARGET_ACTION != status ]] && ((ok_count++)) # No-need to count result of `status` checks. + ok) # Completed OK (wonderful!) + [[ $r_action != status ]] && ((ok_count++)) # No-need to count result of `status` checks. ;; - so) # Action was skipped, but this is normal (no-big-deal). + so) # Action was skipped, but this is normal (no-big-deal) ((skip_ok_count++)) ;; - sk) # Action was skipped (and there's a good reason for it). + sk) # Action was skipped (and there's a good reason for it) ((skip_count++)) ;; - se) # Action was skipped due to error prior to action being attempted (might be a big-deal). + se) # Action was skipped due to error prior to action being attempted (might be a big-deal) ((skip_error_count++)) ;; - sa) # Action was skipped and must immediately abort (don't attempt this action again). + sa) # Action was skipped and must immediately abort (don't attempt this action again) ((skip_abort_count++)) - /bin/touch "$ACTION_ABORT_PATHFILE" + /bin/touch "$r_action_abort_pathfile" ;; - er) # Action failed (uh-oh). + er) # Action failed (uh-oh) ((fail_count++)) esac case $msg1_value in ok|so|sk|se|sa|er) - [[ $(type -t QPKGs-AC${TARGET_ACTION}-to:Init) = function ]] && QPKGs-AC${TARGET_ACTION}-to:Remove "$msg2_value" - [[ $(type -t QPKGs-AC${TARGET_ACTION}-${msg1_value}:Init) = function ]] && QPKGs-AC${TARGET_ACTION}-${msg1_value}:Add "$msg2_value" + [[ $(type -t QPKGs-AC${r_action}-to:Init) = function ]] && QPKGs-AC${r_action}-to:Remove "$msg2_value" + [[ $(type -t QPKGs-AC${r_action}-${msg1_value}:Init) = function ]] && QPKGs-AC${r_action}-${msg1_value}:Add "$msg2_value" # Also add to 'done' list. - [[ $(type -t QPKGs-AC${TARGET_ACTION}-dn:Init) = function ]] && QPKGs-AC${TARGET_ACTION}-dn:Add "$msg2_value" + [[ $(type -t QPKGs-AC${r_action}-dn:Init) = function ]] && QPKGs-AC${r_action}-dn:Add "$msg2_value" ;; ex) # Action is about to exit. for package_index in "${!target_packages[@]}"; do @@ -1647,7 +1654,7 @@ ProcAction() DebugAsWarn "unidentified key in message queue: '$msg1_key'" esac - [[ -e $ACTION_ABORT_PATHFILE ]] && break + [[ -e $r_action_abort_pathfile ]] && break done [[ $fail_count -gt 0 ]] && show_action_results_failed=true @@ -1660,10 +1667,10 @@ ProcAction() # TODO: Process unactioned QPKGs here (if-any), and mark them as aborted. -# for package in $(QPKGs-AC${TARGET_ACTION}-to:Array); do -# if ! QPKGs-AC${TARGET_ACTION}-dn.Exist "$package"; then -# QPKGs-AC${TARGET_ACTION}-sa:Add "$package" -# QPKGs-AC${TARGET_ACTION}-dn:Add "$package" +# for package in $(QPKGs-AC${r_action}-to:Array); do +# if ! QPKGs-AC${r_action}-dn.Exist "$package"; then +# QPKGs-AC${r_action}-sa:Add "$package" +# QPKGs-AC${r_action}-dn:Add "$package" # fi # done @@ -1672,7 +1679,7 @@ ProcAction() IPK|PIP) if [[ $ipks_downgrade = true || $ipks_install = true || $ipks_upgrade = true || $pips_install = true ]]; then InitForkCounts - ${PACKAGE_TYPE}s:${TARGET_ACTION} # Only process these packages in groups, not individually. + ${r_package_type}s:${r_action} # Only process these packages in groups, not individually. fi esac @@ -1689,8 +1696,8 @@ OpenActionMsgPipe() # Create a message pipe, so action forks can send data back to parent. - [[ -p $ACTION_MSG_PIPE ]] && rm -f "$ACTION_MSG_PIPE" 2> /dev/null - [[ ! -p $ACTION_MSG_PIPE ]] && mknod "$ACTION_MSG_PIPE" p + [[ -p $r_action_msg_pipe ]] && rm -f "$r_action_msg_pipe" 2> /dev/null + [[ ! -p $r_action_msg_pipe ]] && mknod "$r_action_msg_pipe" p # Create a file descriptor to store original stdin FD. backup_stdin_fd=$(FindNextFD) @@ -1704,7 +1711,7 @@ OpenActionMsgPipe() DebugVar action_msg_pipe_fd # Open a 2-way channel to message pipe. - [[ $action_msg_pipe_fd != none ]] && eval "exec $action_msg_pipe_fd<>$ACTION_MSG_PIPE" + [[ $action_msg_pipe_fd != none ]] && eval "exec $action_msg_pipe_fd<>$r_action_msg_pipe" } @@ -1725,7 +1732,7 @@ CloseActionMsgPipe() [[ -n ${action_msg_pipe_fd:-} && $action_msg_pipe_fd != none ]] && eval "exec $action_msg_pipe_fd>&-" # Delete message pipe. - [[ -n ${ACTION_MSG_PIPE:-} && -p $ACTION_MSG_PIPE ]] && rm -f "$ACTION_MSG_PIPE" 2> /dev/null + [[ -n ${r_action_msg_pipe:-} && -p $r_action_msg_pipe ]] && rm -f "$r_action_msg_pipe" 2> /dev/null } @@ -1736,14 +1743,14 @@ SetMaxForks() # $1 = action # Inputs: (global) - # $CONCURRENCY + # $r_concurrency # $useropt_debug # $useropt_verbose # Outputs: (global) # $max_forks - max_forks=$CONCURRENCY + max_forks=$r_concurrency local reason='' if [[ $useropt_verbose = true ]]; then # No-point running async actions in verbose mode: stdout will be a confusing mess. @@ -1788,7 +1795,7 @@ PrepareArgs() # scriptname [action] [groups] [options] # Inputs: (global) - # $ARGS_RAW + # $r_args_raw # Outputs: (global) # $arg_problem @@ -1797,13 +1804,13 @@ PrepareArgs() ShowAsProc args - local a=$(Lowercase "${ARGS_RAW//,/ }") + local a=$(Lowercase "${r_args_raw//,/ }") args=(${a/--/}) arg_problem=false DebugArray args "${args[*]:-}" #devdebug - [[ -z $ARGS_RAW ]] && useropt_help_basic=true + [[ -z $r_args_raw ]] && useropt_help_basic=true } @@ -3018,12 +3025,12 @@ AllocPackGroupsToAcs() local action='' local group='' - for action in "${USER_QPKG_ACTIONS[@]}"; do + for action in "${r_user_qpkg_actions[@]}"; do # Process group-based user-actions. # Positive groups. - for group in "${QPKG_IS_GROUPS[@]}"; do + for group in "${r_qpkg_is_groups[@]}"; do if QPKGs.AC${action}.GR${group}.IsSet; then QPKGs-AC${action}-to:Add "$(QPKGs-GR${group}:Array)" @@ -3037,7 +3044,7 @@ AllocPackGroupsToAcs() # Negative groups. - for group in "${QPKG_ISNT_GROUPS[@]}"; do + for group in "${r_qpkg_isnt_groups[@]}"; do if QPKGs.AC${action}.GRNT${group}.IsSet; then QPKGs-AC${action}-to:Add "$(QPKGs-GRNT${group}:Array)" @@ -3065,12 +3072,12 @@ AllocPackStatesToAcs() local check_later=false local state='' - for action in "${USER_QPKG_ACTIONS[@]}"; do + for action in "${r_user_qpkg_actions[@]}"; do # Process state-based user-actions. # Positive states. - for state in "${QPKG_IS_STATES[@]}"; do + for state in "${r_qpkg_is_states[@]}"; do check_later=false if QPKGs.AC${action}.IS${state}.IsSet; then @@ -3092,7 +3099,7 @@ AllocPackStatesToAcs() # Negative states. - for state in "${QPKG_ISNT_STATES[@]}"; do + for state in "${r_qpkg_isnt_states[@]}"; do check_later=false if QPKGs.AC${action}.ISNT${state}.IsSet; then @@ -3120,8 +3127,8 @@ AllocPackStatesToAcs() ResetArchivedLogs() { - if [[ -n $LOGS_PATH && -d $LOGS_PATH ]]; then - ClearPath "$THIS_PACKAGE_PATH" "$LOGS_PATH" + if [[ -n $r_logs_path && -d $r_logs_path ]]; then + ClearPath "$r_this_package_path" "$r_logs_path" echo 'log reset' > "$sess_active_pathfile" ShowAsDone 'logs cleared' fi @@ -3133,8 +3140,8 @@ ResetArchivedLogs() ResetCachePath() { - if [[ -n $CACHE_PATH && -d $CACHE_PATH ]]; then - ClearPath "$THIS_PACKAGE_PATH" "$CACHE_PATH" + if [[ -n $r_cache_path && -d $r_cache_path ]]; then + ClearPath "$r_this_package_path" "$r_cache_path" ShowAsDone 'package cache cleared' fi @@ -3145,8 +3152,8 @@ ResetCachePath() ResetReportsPath() { - if [[ -n $REPORTS_PATH && -d $REPORTS_PATH ]]; then - ClearPath /var/log/sherpa "$REPORTS_PATH" + if [[ -n $r_reports_path && -d $r_reports_path ]]; then + ClearPath /var/log/sherpa "$r_reports_path" ShowAsDone 'reports cleared' fi @@ -3187,24 +3194,24 @@ Quiz() PatchEntwareService() { - local -r TAB=$'\t' - local -r PREFIX='# the following line was inserted by sherpa: https://git.io/sherpa' - local -r PACKAGE_INIT_PATHFILE=$(QpkgGetInstalledServicePathFile Entware) + local -r r_tab_char=$'\t' + local -r r_prefix='# the following line was inserted by sherpa: https://git.io/sherpa' + local -r r_package_init_pathfile=$(QpkgGetInstalledServicePathFile Entware) local find='' local insert='' - if $GREP_CMD -q 'opt.orig' "$PACKAGE_INIT_PATHFILE"; then + if $GREP_CMD -q 'opt.orig' "$r_package_init_pathfile"; then DebugInfo 'patch: do the "/opt shuffle" - already done' else # Ensure existing files are moved out of the way before creating /opt symlink. find='# sym-link $QPKG_DIR to /opt' insert='opt_path="/opt"; opt_backup_path="/opt.orig"; [[ -d "$opt_path" \&\& ! -L "$opt_path" \&\& ! -e "$opt_backup_path" ]] \&\& mv "$opt_path" "$opt_backup_path"' - $SED_CMD -i "s|$find|$find\n\n${TAB}${PREFIX}\n${TAB}${insert}\n|" "$PACKAGE_INIT_PATHFILE" + $SED_CMD -i "s|$find|$find\n\n${r_tab_char}${r_prefix}\n${r_tab_char}${insert}\n|" "$r_package_init_pathfile" # ... then restored after creating /opt symlink. find='/bin/ln -sf $QPKG_DIR /opt' insert='[[ -L "$opt_path" \&\& -d "$opt_backup_path" ]] \&\& cp "$opt_backup_path"/* --target-directory "$opt_path" \&\& rm -r "$opt_backup_path"' - $SED_CMD -i "s|$find|$find\n\n${TAB}${PREFIX}\n${TAB}${insert}\n|" "$PACKAGE_INIT_PATHFILE" + $SED_CMD -i "s|$find|$find\n\n${r_tab_char}${r_prefix}\n${r_tab_char}${insert}\n|" "$r_package_init_pathfile" DebugAsDone 'patch: do the "opt shuffle"' fi @@ -3224,16 +3231,16 @@ _UpdateEntwarePackageList_() return 1 fi - [[ ${ENTWARE_PACKAGE_LIST_UPTODATE:-false} = false ]] || return + [[ ${r_entware_package_list_uptodate:-false} = false ]] || return local -i z=0 # If Entware package list was recently updated, don't update again. - if ! IsThisFileRecent "$EXTERNAL_PACKAGES_ARCHIVE_PATHFILE" "$FILE_CHANGE_THRESHOLD_MINUTES" || [[ ! -f $EXTERNAL_PACKAGES_ARCHIVE_PATHFILE || $useropt_check = true ]]; then + if ! IsThisFileRecent "$r_external_packages_archive_pathfile" "$r_file_change_threshold_minutes" || [[ ! -f $r_external_packages_archive_pathfile || $useropt_check = true ]]; then DebugAsProc "updating $(ShowAsPackageName Entware) package list" - RunAndLog "$OPKG_CMD update" "$LOGS_PATH/Entware.$UPDATE_LOG_FILE" log:failure-only + RunAndLog "$OPKG_CMD update" "$r_logs_path/Entware.$r_update_log_file" log:failure-only z=$? if [[ $z -eq 0 ]]; then @@ -3244,11 +3251,11 @@ _UpdateEntwarePackageList_() # no-big-deal fi else - DebugInfo "$(ShowAsPackageName Entware) package list was updated less-than $FILE_CHANGE_THRESHOLD_MINUTES minutes ago: skipping update" + DebugInfo "$(ShowAsPackageName Entware) package list was updated less-than $r_file_change_threshold_minutes minutes ago: skipping update" fi - [[ -f $EXTERNAL_PACKAGES_ARCHIVE_PATHFILE && ! -f $EXTERNAL_PACKAGES_PATHFILE ]] && OpenIpkArchive - readonly ENTWARE_PACKAGE_LIST_UPTODATE=true + [[ -f $r_external_packages_archive_pathfile && ! -f $r_external_packages_pathfile ]] && OpenIpkArchive + readonly r_entware_package_list_uptodate=true return 0 @@ -3274,11 +3281,11 @@ IsThisFileRecent() SaveIpkAndPipList() { - $PIP_CMD freeze | cut -d'=' -f1 > "$PREV_PIP_LIST" - [[ -e $PREV_PIP_LIST ]] && DebugAsDone "saved current PIP list to $(ShowAsFileName "$PREV_PIP_LIST")" + $PIP_CMD freeze | cut -d'=' -f1 > "$r_prev_pip_list_pathfile" + [[ -e $r_prev_pip_list_pathfile ]] && DebugAsDone "saved current PIP list to $(ShowAsFileName "$r_prev_pip_list_pathfile")" - $OPKG_CMD list-installed > "$PREV_IPK_LIST" - [[ -e $PREV_IPK_LIST ]] && DebugAsDone "saved current $(ShowAsPackageName Entware) IPK list to $(ShowAsFileName "$PREV_IPK_LIST")" + $OPKG_CMD list-installed > "$r_prev_ipk_list_pathfile" + [[ -e $r_prev_ipk_list_pathfile ]] && DebugAsDone "saved current $(ShowAsPackageName Entware) IPK list to $(ShowAsFileName "$r_prev_ipk_list_pathfile")" } 2> /dev/null @@ -3289,14 +3296,14 @@ LoadIpkList() local separator='' local version='' - if [[ -e $PREV_IPK_LIST ]]; then - DebugInfo "IPKs are being loaded from $(ShowAsFileName "$PREV_IPK_LIST")" + if [[ -e $r_prev_ipk_list_pathfile ]]; then + DebugInfo "IPKs are being loaded from $(ShowAsFileName "$r_prev_ipk_list_pathfile")" while read -r name separator version; do name=$(Lowercase "$name") IPKs-ACinstall-to:Add "$name" - done < "$PREV_IPK_LIST" + done < "$r_prev_ipk_list_pathfile" fi } @@ -3307,15 +3314,15 @@ LoadPipList() local name='' local re='' - if [[ -e $PREV_PIP_LIST ]]; then - DebugInfo "PIPs are being loaded from $(ShowAsFileName "$PREV_PIP_LIST")" + if [[ -e $r_prev_pip_list_pathfile ]]; then + DebugInfo "PIPs are being loaded from $(ShowAsFileName "$r_prev_pip_list_pathfile")" while read -r name; do name=$(Lowercase "$name") re=\\b$name\\b - [[ ${EXCLUSION_PIPS[*]} =~ $re ]] || PIPs-ACinstall-to:Add "$name" - done < "$PREV_PIP_LIST" + [[ ${r_exclusion_pips[*]} =~ $re ]] || PIPs-ACinstall-to:Add "$name" + done < "$r_prev_pip_list_pathfile" fi } @@ -3334,7 +3341,7 @@ CalcIpkDepsToInstall() local element='' local ipk_titles='' local -i iterations=0 - local -r ITERATION_LIMIT=20 + local -r r_iteration_limit=20 local -i pre_exclude_count=0 local pre_exclude_list='' local req_list='' @@ -3354,14 +3361,14 @@ CalcIpkDepsToInstall() fi DebugInfo "$requested_count IPK$(Pluralise "$requested_count") requested" "'$req_list' " - while [[ $iterations -le $ITERATION_LIMIT ]]; do + while [[ $iterations -le $r_iteration_limit ]]; do ShowAsIterativeProgress 'resolve IPK dependencies' "$iterations" iteration "${#dep_acc[@]}" 'unique IPK' ((iterations++)) printf -v ipk_titles '^Package: %s$\|' "${this_list[@]}" ipk_titles=${ipk_titles%??} # Remove last 2 characters. - this_list=($($GNU_GREP_CMD --word-regexp --after-context 1 --no-group-separator '^Package:\|^Depends:' "$EXTERNAL_PACKAGES_PATHFILE" | $GNU_GREP_CMD -vG '^Section:\|^Version:' | $GNU_GREP_CMD --word-regexp --after-context 1 --no-group-separator "$ipk_titles" | $GNU_GREP_CMD -vG "$ipk_titles" | $GNU_GREP_CMD -vG '^Package: ' | $SED_CMD 's|^Depends: ||;s|, |\n|g' | $SORT_CMD | $UNIQ_CMD)) + this_list=($($GNU_GREP_CMD --word-regexp --after-context 1 --no-group-separator '^Package:\|^Depends:' "$r_external_packages_pathfile" | $GNU_GREP_CMD -vG '^Section:\|^Version:' | $GNU_GREP_CMD --word-regexp --after-context 1 --no-group-separator "$ipk_titles" | $GNU_GREP_CMD -vG "$ipk_titles" | $GNU_GREP_CMD -vG '^Package: ' | $SED_CMD 's|^Depends: ||;s|, |\n|g' | $SORT_CMD | $UNIQ_CMD)) # Update progress twice per loop. ShowAsIterativeProgress 'resolve IPK dependencies' "$iterations" iteration "${#dep_acc[@]}" 'unique IPK' @@ -3382,7 +3389,7 @@ CalcIpkDepsToInstall() if [[ $complete = true ]]; then DebugAsDone "dependency calculation complete in $iterations iteration$(Pluralise "$iterations")" else - DebugAsError "dependency calculation incomplete in $iterations iteration$(Pluralise "$iterations"), consider raising \$ITERATION_LIMIT [$ITERATION_LIMIT]" + DebugAsError "dependency calculation incomplete in $iterations iteration$(Pluralise "$iterations"), consider raising \$r_iteration_limit [$r_iteration_limit]" show_suggest_raise_issue=true fi @@ -3435,7 +3442,7 @@ CalcIpkDownloadSize() ShowAsProc "calculate size of IPK$(Pluralise "$size_count") to download" DebugAsDone "$size_count IPK$(Pluralise "$size_count") to download: '$(IPKs-ACdownload-to:List)'" - size_array=($($GNU_GREP_CMD -w '^Package:\|^Size:' "$EXTERNAL_PACKAGES_PATHFILE" | $GNU_GREP_CMD --after-context 1 --no-group-separator ": $($SED_CMD 's/ /$ /g;s/\$ /\$\\\|: /g' <<< "$(IPKs-ACdownload-to:List)")" | $GREP_CMD '^Size:' | $SED_CMD 's|^Size: ||')) + size_array=($($GNU_GREP_CMD -w '^Package:\|^Size:' "$r_external_packages_pathfile" | $GNU_GREP_CMD --after-context 1 --no-group-separator ": $($SED_CMD 's/ /$ /g;s/\$ /\$\\\|: /g' <<< "$(IPKs-ACdownload-to:List)")" | $GREP_CMD '^Size:' | $SED_CMD 's|^Size: ||')) # shellcheck disable=2283 IPKs-ACdownload-to:Size = "$(IFS=+; echo "$((${size_array[*]:-}))")" # nifty sizing shortcut found here https://stackoverflow.com/a/13635566/6182835 @@ -3460,7 +3467,7 @@ IPKs:upgrade() FuncInit local desc='' - local log_pathfile=$LOGS_PATH/ipks.$UPGRADE_LOG_FILE + local log_pathfile=$r_logs_path/ipks.$r_upgrade_log_file local -i total_count=0 local -i z=0 @@ -3483,10 +3490,10 @@ IPKs:upgrade() ShowAsProc "upgrade $desc" - _DirSizeMonitor_ "$IPK_DL_PATH" "$(IPKs-ACdownload-to:Size)" & + _DirSizeMonitor_ "$r_ipk_download_path" "$(IPKs-ACdownload-to:Size)" & fork_pid=$! - RunAndLog "$OPKG_CMD upgrade --force-overwrite $(IPKs-ACdownload-to:List) --cache $IPK_CACHE_PATH --tmp-dir $IPK_DL_PATH" "$log_pathfile" log:failure-only + RunAndLog "$OPKG_CMD upgrade --force-overwrite $(IPKs-ACdownload-to:List) --cache $r_ipk_cache_path --tmp-dir $r_ipk_download_path" "$log_pathfile" log:failure-only z=$? KillPID "$fork_pid" @@ -3520,7 +3527,7 @@ IPKs:install() local desc='' local -i i=0 - local log_pathfile=$LOGS_PATH/ipks.$INSTALL_LOG_FILE + local log_pathfile=$r_logs_path/ipks.$r_install_log_file local previous='' local -i total_count=0 local -i z=0 @@ -3529,22 +3536,22 @@ IPKs:install() IPKs-ACdownload-to:Init if QPKGs-ACinstall-ok.Exist Entware || ([[ $useropt_check = true ]] && QpkgIsInstalled Entware); then - IPKs-ACinstall-to:Add "$ESSENTIAL_IPKS" + IPKs-ACinstall-to:Add "$r_essential_ipks" - if [[ -e $PREV_IPK_LIST && $useropt_check = false ]]; then # Don't load previous IPK list during 'check'. + if [[ -e $r_prev_ipk_list_pathfile && $useropt_check = false ]]; then # Don't load previous IPK list during 'check'. LoadIpkList - mv -f "$PREV_IPK_LIST" "$PREV_IPK_LIST.installing" + mv -f "$r_prev_ipk_list_pathfile" "$r_prev_ipk_list_pathfile.installing" fi fi if QPKGs.ACinstall.GRall.IsSet; then - for qpkg_name in "${QPKG_NAME[@]}"; do + for qpkg_name in "${r_qpkg_name[@]}"; do [[ $previous = "$qpkg_name" ]] && continue || previous=$qpkg_name QpkgSetIndex IPKs-ACinstall-to:Add "$(QpkgGetDatabaseIPKs)" done else - for qpkg_name in "${QPKG_NAME[@]}"; do + for qpkg_name in "${r_qpkg_name[@]}"; do [[ $previous = "$qpkg_name" ]] && continue || previous=$qpkg_name if QPKGs-ACinstall-to.Exist "$qpkg_name" || QPKGs-ISinstalled.Exist "$qpkg_name" || (QPKGs-ACreinstall-to.Exist "$qpkg_name" && QPKGs-ISinstalled.Exist "$qpkg_name"); then @@ -3563,10 +3570,10 @@ IPKs:install() ShowAsProc "install $desc" - _DirSizeMonitor_ "$IPK_DL_PATH" "$(IPKs-ACdownload-to:Size)" & + _DirSizeMonitor_ "$r_ipk_download_path" "$(IPKs-ACdownload-to:Size)" & fork_pid=$! - RunAndLog "$OPKG_CMD install --force-overwrite $(IPKs-ACdownload-to:List) --cache $IPK_CACHE_PATH --tmp-dir $IPK_DL_PATH" "$log_pathfile" log:failure-only + RunAndLog "$OPKG_CMD install --force-overwrite $(IPKs-ACdownload-to:List) --cache $r_ipk_cache_path --tmp-dir $r_ipk_download_path" "$log_pathfile" log:failure-only z=$? KillPID "$fork_pid" @@ -3578,13 +3585,13 @@ IPKs:install() HideKeystrokes UpdateCapabilities - rm -f "$PREV_IPK_LIST.installing" 2> /dev/null + rm -f "$r_prev_ipk_list_pathfile.installing" 2> /dev/null else NoteIpkAcAsEr "$(IPKs-ACdownload-to:Array)" install SaveActionResultToLog IPK auxiliary install "$total_count" failed "$z" - if [[ -e $PREV_IPK_LIST.installing ]]; then - mv -f "$PREV_IPK_LIST.installing" "$PREV_IPK_LIST" + if [[ -e $r_prev_ipk_list_pathfile.installing ]]; then + mv -f "$r_prev_ipk_list_pathfile.installing" "$r_prev_ipk_list_pathfile" fi fi @@ -3624,11 +3631,11 @@ IPKs:downgrade() if [[ $total_count -gt 0 ]]; then package_type=IPK desc="$total_count ${package_type}$(Pluralise "$total_count")" - log_pathfile=$LOGS_PATH/ipks.$DOWNLOAD_LOG_FILE + log_pathfile=$r_logs_path/ipks.$r_download_log_file ShowAsProc "download $desc" - case $NAS_QPKG_ARCH in + case $r_nas_qpkg_arch in a41) if OsIsNonStdKernelPageSize; then url_prefix=http://bin.entware.net/armv7sf-k3.2/archive/ @@ -3639,7 +3646,7 @@ IPKs:downgrade() ((ok_count++)) remote_url=${url_prefix}${name}${url_suffix} - local_pathfile=$IPK_DOWNGRADE_PATH/$($BASENAME_CMD "$remote_url") + local_pathfile=$r_ipk_downgrade_path/$($BASENAME_CMD "$remote_url") RunAndLog "$CURL_CMD --location --output $local_pathfile $remote_url" "$log_pathfile" log:failure-only done @@ -3654,7 +3661,7 @@ IPKs:downgrade() ((ok_count++)) remote_url=${url_prefix}${name}${url_suffix} - local_pathfile=$IPK_DOWNGRADE_PATH/$($BASENAME_CMD "$remote_url") + local_pathfile=$r_ipk_downgrade_path/$($BASENAME_CMD "$remote_url") RunAndLog "$CURL_CMD --location --output $local_pathfile $remote_url" "$log_pathfile" log:failure-only done @@ -3667,12 +3674,12 @@ IPKs:downgrade() ok_count=0 fail_count=0 desc="$total_count auxiliary ${package_type}$(Pluralise "$total_count")" - log_pathfile=$LOGS_PATH/ipks.$DOWNGRADE_LOG_FILE + log_pathfile=$r_logs_path/ipks.$r_downgrade_log_file ShowAsProc "downgrade $desc" ShowAsPercentProgress "downgrade $desc" '' "$ok_count" 0 "$fail_count" "$total_count" - RunAndLog "$OPKG_CMD install --force-downgrade --cache $IPK_CACHE_PATH --tmp-dir $IPK_DOWNGRADE_PATH $IPK_DOWNGRADE_PATH/*.ipk" "$log_pathfile" log:failure-only + RunAndLog "$OPKG_CMD install --force-downgrade --cache $r_ipk_cache_path --tmp-dir $r_ipk_downgrade_path $r_ipk_downgrade_path/*.ipk" "$log_pathfile" log:failure-only z=$? if [[ $z -eq 0 ]]; then @@ -3722,23 +3729,23 @@ PIPs:install() local desc='' local exec_cmd='' local -i fail_count=0 - local log_pathfile=$LOGS_PATH/pips.$INSTALL_LOG_FILE + local log_pathfile=$r_logs_path/pips.$r_install_log_file local -i ok_count=0 local package_type=PIP local -i total_count=0 local -i z=0 if [[ $useropt_check = true ]] || IPKs-ACinstall-ok.Exist python3-pip; then - PIPs-ACinstall-to:Add "$ESSENTIAL_PIPS" + PIPs-ACinstall-to:Add "$r_essential_pips" - if [[ -e $PREV_PIP_LIST && $useropt_check = false ]]; then # Don't load previous PIP list during 'check'. + if [[ -e $r_prev_pip_list_pathfile && $useropt_check = false ]]; then # Don't load previous PIP list during 'check'. LoadPipList - mv -f "$PREV_PIP_LIST" "$PREV_PIP_LIST.installing" + mv -f "$r_prev_pip_list_pathfile" "$r_prev_pip_list_pathfile.installing" fi ((total_count++)) - exec_cmd="$PIP_CMD install --upgrade --no-input $(PIPs-ACinstall-to:List) --cache-dir $PIP_CACHE_PATH --root-user-action=ignore" + exec_cmd="$PIP_CMD install --upgrade --no-input $(PIPs-ACinstall-to:List) --cache-dir $r_pip_cache_path --root-user-action=ignore" desc="$total_count auxiliary PIP$(Pluralise "$total_count")" ShowAsPercentProgress "install $desc" '' "$ok_count" 0 0 "$total_count" @@ -3750,13 +3757,13 @@ PIPs:install() DebugAsDone "installed $desc" SaveActionResultToLog PIP auxiliary install "$ok_count" ok - rm -f "$PREV_PIP_LIST.installing" 2> /dev/null + rm -f "$r_prev_pip_list_pathfile.installing" 2> /dev/null else ((fail_count++)) SaveActionResultToLog PIP auxiliary install "$fail_count" failed "$z" - if [[ -e $PREV_PIP_LIST.installing ]]; then - mv -f "$PREV_PIP_LIST.installing" "$PREV_PIP_LIST" + if [[ -e $r_prev_pip_list_pathfile.installing ]]; then + mv -f "$r_prev_pip_list_pathfile.installing" "$r_prev_pip_list_pathfile" fi fi @@ -3784,15 +3791,15 @@ OpenIpkArchive() # Outputs: (local) # $? = 0 if successful, 1 if failed - if [[ ! -e $EXTERNAL_PACKAGES_ARCHIVE_PATHFILE ]]; then + if [[ ! -e $r_external_packages_archive_pathfile ]]; then ShowAsError 'unable to locate the IPK list file' return 1 fi - RunAndLog "/usr/local/sbin/7z e -o$($DIRNAME_CMD "$EXTERNAL_PACKAGES_PATHFILE") $EXTERNAL_PACKAGES_ARCHIVE_PATHFILE" "$CACHE_PATH/ipk.archive.extract" log:failure-only + RunAndLog "/usr/local/sbin/7z e -o$($DIRNAME_CMD "$r_external_packages_pathfile") $r_external_packages_archive_pathfile" "$r_cache_path/ipk.archive.extract" log:failure-only - if [[ ! -e $EXTERNAL_PACKAGES_PATHFILE ]]; then + if [[ ! -e $r_external_packages_pathfile ]]; then ShowAsError 'unable to open the IPK list file' return 1 @@ -3805,7 +3812,7 @@ OpenIpkArchive() CloseIpkArchive() { - rm -f "$EXTERNAL_PACKAGES_PATHFILE" 2> /dev/null + rm -f "$r_external_packages_pathfile" 2> /dev/null } @@ -3834,10 +3841,10 @@ _ExecOneActionWithManyForks_() fork_id=0 for qpkg_name in "${c[@]}"; do - [[ ! -e $ACTION_ABORT_PATHFILE ]] || break + [[ ! -e $r_action_abort_pathfile ]] || break while [[ $fork_count -ge $max_forks ]]; do # Don't fork until an empty spot becomes available. - [[ ! -e $ACTION_ABORT_PATHFILE ]] || break 2 + [[ ! -e $r_action_abort_pathfile ]] || break 2 sleep .2 UpdateForkProgress done @@ -3846,7 +3853,7 @@ _ExecOneActionWithManyForks_() MarkThisAcForkAsStarted # Must create runfile here, as it takes too-long to happen in async function. QpkgSetIndex - action_pidfile=$($MKTEMP_CMD "$ASYNC_PROCS_PATH"/bgproc_XXXXXX) # Set $action_pidfile here, before launching async process so it's inherited by that process. + action_pidfile=$($MKTEMP_CMD "$r_async_procs_path"/bgproc_XXXXXX) # Set $action_pidfile here, before launching async process so it's inherited by that process. $a & @@ -3859,7 +3866,7 @@ _ExecOneActionWithManyForks_() # All action forks have launched, just need to wait for them to exit. while [[ $fork_count -gt 0 ]]; do - [[ ! -e $ACTION_ABORT_PATHFILE ]] || break + [[ ! -e $r_action_abort_pathfile ]] || break sleep .2 UpdateForkProgress # Update display while running forks complete. done @@ -3880,7 +3887,7 @@ _DirSizeMonitor_() # $2 = total target bytes (100%) for specified path. # Inputs: (global) - # $DISPLAY_INHIBIT_PATHFILE + # $r_display_inhibit_pathfile # Outputs: (local) # stdout = formatted as: "percentage downloaded (downloaded bytes/total expected bytes)". @@ -3944,7 +3951,7 @@ _DirSizeMonitor_() progress_msg+=$stall_msg fi - [[ ! -e $DISPLAY_INHIBIT_PATHFILE ]] || return + [[ ! -e $r_display_inhibit_pathfile ]] || return WriteMsgInPlace "$progress_msg" sleep 1 done @@ -4252,7 +4259,7 @@ UserIsOk() if ! UserIsSU; then if OsIsSupportSudo; then ShowAsError 'this utility must be run with superuser privileges. Try again as:' - echo "${CHARS_SUDO_PROMPT}sherpa $ARGS_RAW" >&2 + echo "${r_chars_sudo_prompt}sherpa $r_args_raw" >&2 else ShowAsError "this utility must be run as the 'admin' user. Please login via SSH as 'admin' and try again" fi @@ -4387,17 +4394,17 @@ DisplayAsProjSynExam() # $2 = example syntax # Inputs: (global) - # $CHARS_BULLET - # $HELP_SYNTAX_INDENT - # $HELP_SYNTAX_SUDO_PREFIX + # $r_chars_bullet + # $r_help_syntax_indent + # $r_help_syntax_sudo_prefix # Outputs: (local) # stdout = $1 & $2 formatted. - printf "\n${CHARS_BULLET}%s" "$(Capitalise "${1:-}")" + printf "\n${r_chars_bullet}%s" "$(Capitalise "${1:-}")" [[ ${1: -1} != '!' ]] && printf ':' - printf "\n%${HELP_SYNTAX_INDENT}s${HELP_SYNTAX_SUDO_PREFIX}sherpa %s\n" '' "${2:-}" + printf "\n%${r_help_syntax_indent}s${r_help_syntax_sudo_prefix}sherpa %s\n" '' "${2:-}" } @@ -4411,12 +4418,12 @@ DisplayAsProjSynIndentExam() # $2 = example syntax if [[ -n $1 ]]; then - printf "\n%${HELP_DESC_INDENT}s%s" '' "$(Capitalise "${1:-}")" + printf "\n%${r_help_desc_indent}s%s" '' "$(Capitalise "${1:-}")" [[ ${1: -1} != '!' ]] && printf ':' printf '\n' fi - printf "%${HELP_SYNTAX_INDENT}s${HELP_SYNTAX_SUDO_PREFIX}sherpa %s\n" '' "${2:-}" + printf "%${r_help_syntax_indent}s${r_help_syntax_sudo_prefix}sherpa %s\n" '' "${2:-}" } @@ -4429,7 +4436,7 @@ DisplayAsSynExam() # $1 = description # $2 = example syntax - printf "\n${CHARS_BULLET}%s:\n%${HELP_SYNTAX_INDENT}s${HELP_SYNTAX_PREFIX}%s\n" "$(Capitalise "${1:-}")" '' "${2:-}" + printf "\n${r_chars_bullet}%s:\n%${r_help_syntax_indent}s${r_help_syntax_prefix}%s\n" "$(Capitalise "${1:-}")" '' "${2:-}" } @@ -4441,7 +4448,7 @@ DisplayAsIndentItem() # Inputs: (local) # $1 = item - printf "%${HELP_DESC_INDENT}s${CHARS_BULLET}%s\n" '' "$(Capitalise "${1:-}")" + printf "%${r_help_desc_indent}s${r_chars_bullet}%s\n" '' "$(Capitalise "${1:-}")" } @@ -4458,9 +4465,9 @@ DisplayAsIndentQuotedInfoItem() # $2 = description if OsIsSupportAutowidthTableColumns; then - printf "%${HELP_DESC_INDENT}s%s|%s\n" '' "'${1:-}'" "- $(AddPeriod "${2:-}")" + printf "%${r_help_desc_indent}s%s|%s\n" '' "'${1:-}'" "- $(AddPeriod "${2:-}")" else - printf "%${HELP_DESC_INDENT}s%-$((FOOTER_NAME_COL_WIDTH+2+$(LenANSIDiff "${1:-}")))s%s\n" '' "'${1:-}'" "- $(AddPeriod "${2:-}")" + printf "%${r_help_desc_indent}s%-$((r_report_footer_name_column_width+2+$(LenANSIDiff "${1:-}")))s%s\n" '' "'${1:-}'" "- $(AddPeriod "${2:-}")" fi } @@ -4472,15 +4479,15 @@ GeneratePacksReportTitleLine() # column 1: package name. a='QPKG name:' - printf "%-$((PACKAGE_NAME_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_name_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 2: application version a='Appl. version:' - printf "%-$((PACKAGE_APP_VER_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_appl_version_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 3: package description a='Description:' - printf "%-$((PACKAGE_DESCRIPTION_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_description_column_width+2+$(LenANSIDiff "$a")))s" "$a" printf '\n' @@ -4496,34 +4503,34 @@ GeneratePacksReportDataLine() # $qpkg_name local app_ver='' - local app_ver_msg=$CHARS_BLANK + local app_ver_msg=$r_chars_blank # local author=$(QpkgGetDatabaseAuthor) -# local author_msg=$CHARS_BLANK - local description_msg=$CHARS_BLANK +# local author_msg=$r_chars_blank + local description_msg=$r_chars_blank local mode='' local name=${1:-${qpkg_name:?${FUNCNAME[0]}'()': undefined package name}} local description=$(QpkgGetDatabaseDesc "$name") local notes=$(QpkgGetDatabaseNote "$name") [[ $notes = none ]] && notes='' - local name_msg=$CHARS_NORMAL + local name_msg=$r_chars_normal local notes_msg="${notes}." if QpkgIsInstalledMissing; then mode=highlight - /bin/touch "$REPORT_FLAGS_PATH"/status-missing + /bin/touch "$r_report_flags_path"/status-missing elif QpkgIsNtInstalled; then mode=mute - /bin/touch "$REPORT_FLAGS_PATH"/state-notinstalled + /bin/touch "$r_report_flags_path"/state-notinstalled else mode=normal - /bin/touch "$REPORT_FLAGS_PATH"/state-installed + /bin/touch "$r_report_flags_path"/state-installed fi app_ver=$(QpkgGetDatabaseApplVer) case $app_ver in dynamic|final|static) - /bin/touch "$REPORT_FLAGS_PATH"/app-$app_ver + /bin/touch "$r_report_flags_path"/app-$app_ver esac app_ver_msg+=$app_ver @@ -4539,7 +4546,7 @@ GeneratePacksReportDataLine() name_msg=$(TextDarkGrey "$name_msg") ;; highlight) -# [[ $author = missing ]] && author_msg=$(TextBrightRedBlink "${CHARS_ALERT}${author}") +# [[ $author = missing ]] && author_msg=$(TextBrightRedBlink "${r_chars_alert}${author}") name_msg=$(TextBrightRed "$name_msg") esac @@ -4547,22 +4554,22 @@ GeneratePacksReportDataLine() echo "$name_msg|$app_ver_msg|$description_msg" if [[ -n $notes ]]; then - printf "%s|%s|%$((${#CHARS_BLANK}))s%s\n" '' '' '' "$(TextBrightOrange "${CHARS_DROPEND}${CHARS_NOTE}") $notes_msg" + printf "%s|%s|%$((${#r_chars_blank}))s%s\n" '' '' '' "$(TextBrightOrange "${r_chars_dropend}${r_chars_note}") $notes_msg" fi else # column 1: package name. - printf "%-$((PACKAGE_NAME_COL_WIDTH+$(LenANSIDiff "$name_msg")))s" "$name_msg" + printf "%-$((r_report_qpkg_name_column_width+$(LenANSIDiff "$name_msg")))s" "$name_msg" # column 2: application version - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_APP_VER_COL_WIDTH+$(LenANSIDiff "$app_ver_msg")))s" "$app_ver_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_appl_version_column_width+$(LenANSIDiff "$app_ver_msg")))s" "$app_ver_msg" # column 3: package description - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_DESCRIPTION_COL_WIDTH+$(LenANSIDiff "$description_msg")))s" "$description_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_description_column_width+$(LenANSIDiff "$description_msg")))s" "$description_msg" if [[ -n $notes ]]; then - printf "\n%$((${#CHARS_BLANK}+PACKAGE_NAME_COL_WIDTH+PACKAGE_APP_VER_COL_WIDTH+(COLUMN_SPACING*2)))s$(TextBrightOrange "${CHARS_DROPEND}${CHARS_NOTE}")%s" '' "$notes_msg" + printf "\n%$((${#r_chars_blank}+r_report_qpkg_name_column_width+r_report_qpkg_appl_version_column_width+(r_report_column_spacing*2)))s$(TextBrightOrange "${r_chars_dropend}${r_chars_note}")%s" '' "$notes_msg" fi printf '\n' @@ -4577,33 +4584,33 @@ GenerateStatusReportTitleLine() # column 1: package name. a='QPKG name' - printf "%-${PACKAGE_NAME_COL_WIDTH}s" "$a:" + printf "%-${r_report_qpkg_name_column_width}s" "$a:" # column 2: package statuses - printf "%$((COLUMN_SPACING))s" + printf "%$((r_report_column_spacing))s" a='Status' - printf "%-${PACKAGE_STATUS_COL_WIDTH}s" "$a:" + printf "%-${r_report_qpkg_status_column_width}s" "$a:" # column 3: package action and result - printf "%$((COLUMN_SPACING))s" + printf "%$((r_report_column_spacing))s" a='Previous action (result)' - printf "%-${PACKAGE_ACTION_COL_WIDTH}s" "$a:" + printf "%-${r_report_qpkg_action_column_width}s" "$a:" # column 4: package version - printf "%$((COLUMN_SPACING))s" + printf "%$((r_report_column_spacing))s" a='QPKG version' QPKGs-ISupgradable.IsAny && a+=" ($(TextBrightOrange new))" - printf "%-${PACKAGE_VER_COL_WIDTH}s" "$a:" + printf "%-${r_report_qpkg_version_column_width}s" "$a:" # column 5: application version - printf "%$((COLUMN_SPACING))s" + printf "%$((r_report_column_spacing))s" a='Appl. version' - printf "%-${PACKAGE_APP_VER_COL_WIDTH}s" "$a:" + printf "%-${r_report_qpkg_appl_version_column_width}s" "$a:" # column 6: package installation path - printf "%$((COLUMN_SPACING))s" + printf "%$((r_report_column_spacing))s" a='Location' - printf "%-${PACKAGE_PATH_COL_WIDTH}s" "$a:" + printf "%-${r_report_qpkg_path_column_width}s" "$a:" printf '\n' @@ -4618,19 +4625,19 @@ GenerateStatusReportDataLine() # $qpkg_name local action='' - local action_msg=$CHARS_BLANK + local action_msg=$r_chars_blank local app_ver=$(QpkgGetDatabaseApplVer) - local app_ver_msg=$CHARS_BLANK + local app_ver_msg=$r_chars_blank local mode='' local -i n=0 - local name_msg=$CHARS_BLANK + local name_msg=$r_chars_blank local path=$(QpkgGetInstalledPath) - local path_msg=$CHARS_BLANK + local path_msg=$r_chars_blank local result='' local status='' - local status_msg=$CHARS_NORMAL + local status_msg=$r_chars_normal local ver=$(QpkgGetInstalledVer) - local ver_msg=$CHARS_BLANK + local ver_msg=$r_chars_blank if QpkgIsInstalledMissing; then mode=missing @@ -4643,19 +4650,19 @@ GenerateStatusReportDataLine() case $app_ver in dynamic|final|static) - /bin/touch "$REPORT_FLAGS_PATH"/app-$app_ver + /bin/touch "$r_report_flags_path"/app-$app_ver esac case $mode in missing|normal) if QpkgIsDatabaseSherpaCompatible; then action=$(QpkgGetInstalledServiceAction) - /bin/touch "$REPORT_FLAGS_PATH"/action-$action + /bin/touch "$r_report_flags_path"/action-$action if [[ $action = not-found ]]; then if OsIsStarting && QpkgIsInstalledEnabled; then action_msg+=$(TextBrightOrange pending) - /bin/touch "$REPORT_FLAGS_PATH"/action-pending + /bin/touch "$r_report_flags_path"/action-pending else action_msg+=$(TextDarkGrey not-found) fi @@ -4664,7 +4671,7 @@ GenerateStatusReportDataLine() fi result=$(QpkgGetInstalledServiceResult) - /bin/touch "$REPORT_FLAGS_PATH"/result-$result + /bin/touch "$r_report_flags_path"/result-$result case $result in aborted|failed) @@ -4678,20 +4685,20 @@ GenerateStatusReportDataLine() esac else action=unsupported - /bin/touch "$REPORT_FLAGS_PATH"/action-unsupported + /bin/touch "$r_report_flags_path"/action-unsupported action_msg+=$(TextDarkGrey "$action") fi ;; *) action=N/A - /bin/touch "$REPORT_FLAGS_PATH"/na + /bin/touch "$r_report_flags_path"/na esac case $mode in author) - /bin/touch "$REPORT_FLAGS_PATH"/status-wrongauthor - /bin/touch "$REPORT_FLAGS_PATH"/na + /bin/touch "$r_report_flags_path"/status-wrongauthor + /bin/touch "$r_report_flags_path"/na # Set field values. app_ver=N/A @@ -4703,7 +4710,7 @@ GenerateStatusReportDataLine() app_ver_msg+=$app_ver name_msg+=$qpkg_name path_msg+=$path - status_msg=${CHARS_ATTENTION}${status} + status_msg=${r_chars_attention}${status} ver_msg+=$ver # Highlight field messages. @@ -4715,7 +4722,7 @@ GenerateStatusReportDataLine() ver_msg=$(TextBrightOrange "$ver_msg") ;; missing) - /bin/touch "$REPORT_FLAGS_PATH"/status-missing + /bin/touch "$r_report_flags_path"/status-missing # Set field values. status=missing @@ -4724,7 +4731,7 @@ GenerateStatusReportDataLine() app_ver_msg+=$app_ver name_msg+=$qpkg_name path_msg+=$path - status_msg=${CHARS_ALERT}${status} + status_msg=${r_chars_alert}${status} ver_msg+=$ver # Highlight field messages. @@ -4735,18 +4742,18 @@ GenerateStatusReportDataLine() ver_msg=$(TextBrightRed "$ver_msg") ;; mute) - /bin/touch "$REPORT_FLAGS_PATH"/state-notinstalled - /bin/touch "$REPORT_FLAGS_PATH"/na + /bin/touch "$r_report_flags_path"/state-notinstalled + /bin/touch "$r_report_flags_path"/na # Set field values. path=N/A if ! QpkgIsDatabaseArchOK; then - status+='incompatible NAS arch' + status+='incompatible architecture' elif ! QpkgIsDatabaseMinOSVerOk || ! QpkgIsDatabaseMaxOSVerOk; then status+="incompatible $(OsGetQnapOS)" elif ! QpkgIsDatabaseMinRAMOk; then - status+='insufficient NAS RAM' + status+='insufficient RAM installed' else status+='not installed' fi @@ -4770,7 +4777,7 @@ GenerateStatusReportDataLine() ver_msg=$(TextDarkGrey "$ver_msg") ;; normal) - /bin/touch "$REPORT_FLAGS_PATH"/state-installed + /bin/touch "$r_report_flags_path"/state-installed # Set field values. @@ -4778,24 +4785,24 @@ GenerateStatusReportDataLine() if QPKGs-ISenabled.Exist "$qpkg_name"; then status+=" $(TextBrightGreen enabled)" - /bin/touch "$REPORT_FLAGS_PATH"/state-enabled + /bin/touch "$r_report_flags_path"/state-enabled else status+=" $(TextBrightRed disabled)" - /bin/touch "$REPORT_FLAGS_PATH"/state-disabled + /bin/touch "$r_report_flags_path"/state-disabled fi if QPKGs-ISactive.Exist "$qpkg_name"; then status+=" $(TextBrightGreen active)" - /bin/touch "$REPORT_FLAGS_PATH"/status-active + /bin/touch "$r_report_flags_path"/status-active elif QPKGs-ISslow.Exist "$qpkg_name"; then status+=" $(TextBrightOrange slow)" - /bin/touch "$REPORT_FLAGS_PATH"/status-slow + /bin/touch "$r_report_flags_path"/status-slow elif QPKGs-ISNTactive.Exist "$qpkg_name"; then status+=" $(TextBrightRed inactive)" - /bin/touch "$REPORT_FLAGS_PATH"/status-inactive + /bin/touch "$r_report_flags_path"/status-inactive else status+=" $(TextBrightOrange unknown)" - /bin/touch "$REPORT_FLAGS_PATH"/status-unknown + /bin/touch "$r_report_flags_path"/status-unknown fi # Assign field messages. @@ -4808,34 +4815,34 @@ GenerateStatusReportDataLine() if QPKGs-ISupgradable.Exist "$qpkg_name"; then ver_msg+=" ($(TextBrightOrange "$(QpkgGetDatabaseVer)"))" - /bin/touch "$REPORT_FLAGS_PATH"/status-upgradable + /bin/touch "$r_report_flags_path"/status-upgradable fi if OsIsSupportAutowidthTableColumns; then echo "$name_msg|$status_msg|$action_msg|$ver_msg|$app_ver_msg|$path_msg" else # column 1: package name. - printf "%-$((PACKAGE_NAME_COL_WIDTH+$(LenANSIDiff "$name_msg")))s" "$name_msg" + printf "%-$((r_report_qpkg_name_column_width+$(LenANSIDiff "$name_msg")))s" "$name_msg" # column 2: package statuses - printf "%$((COLUMN_SPACING))s" - printf "%-$((STD_COL_WIDTH+$(LenANSIDiff "$status_msg")))s" "$status_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_lazy_column_width+$(LenANSIDiff "$status_msg")))s" "$status_msg" # column 3: package action and result - printf "%$((COLUMN_SPACING))s" - printf "%-$((STD_COL_WIDTH+$(LenANSIDiff "$action_msg")))s" "$action_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_lazy_column_width+$(LenANSIDiff "$action_msg")))s" "$action_msg" # column 4: package version - printf "%$((COLUMN_SPACING))s" - printf "%-$((STD_COL_WIDTH+$(LenANSIDiff "$ver_msg")))s" "$ver_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_lazy_column_width+$(LenANSIDiff "$ver_msg")))s" "$ver_msg" # column 5: application version - printf "%$((COLUMN_SPACING))s" - printf "%-$((STD_COL_WIDTH+$(LenANSIDiff "$app_ver_msg")))s" "$app_ver_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_lazy_column_width+$(LenANSIDiff "$app_ver_msg")))s" "$app_ver_msg" # column 6: package installation path - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_PATH_COL_WIDTH+$(LenANSIDiff "$path_msg")))s" "$path_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_path_column_width+$(LenANSIDiff "$path_msg")))s" "$path_msg" printf '\n' fi @@ -4849,15 +4856,15 @@ GenerateReposReportTitleLine() # column 1: package name. a="QPKG name:" - printf "%-$((PACKAGE_NAME_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_name_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 2: package repository a="Repository:" - printf "%-$((PACKAGE_REPO_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_repo_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 3: package installation date a="Install date:" - printf "%-$((PACKAGE_INSTALL_DATE_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_install_date_column_width+2+$(LenANSIDiff "$a")))s" "$a" printf '\n' @@ -4873,28 +4880,28 @@ GenerateReposReportDataLine() # stdout = single report line with data fields. local assigned_repo='' - local assigned_repo_msg=$CHARS_NORMAL + local assigned_repo_msg=$r_chars_normal local install_date=$(QpkgGetInstalledDate) - local install_date_msg=$CHARS_BLANK + local install_date_msg=$r_chars_blank local mode='' - local name_msg=$CHARS_BLANK + local name_msg=$r_chars_blank local store_id=$(QpkgGetInstalledStoreID) [[ $store_id = undefined ]] && store_id=sherpa if QpkgIsInstalledMissing; then mode=highlight - /bin/touch "$REPORT_FLAGS_PATH"/status-missing + /bin/touch "$r_report_flags_path"/status-missing elif QpkgIsInstalled; then mode=normal - /bin/touch "$REPORT_FLAGS_PATH"/state-installed + /bin/touch "$r_report_flags_path"/state-installed else mode=mute - /bin/touch "$REPORT_FLAGS_PATH"/state-notinstalled + /bin/touch "$r_report_flags_path"/state-notinstalled fi if [[ $store_id = sherpa ]]; then assigned_repo=sherpa - /bin/touch "$REPORT_FLAGS_PATH"/repo-sherpa + /bin/touch "$r_report_flags_path"/repo-sherpa else assigned_repo=$(GetRepoURLFromStoreID "$store_id") fi @@ -4912,10 +4919,10 @@ GenerateReposReportDataLine() ;; *) assigned_repo_msg+=$assigned_repo - /bin/touch "$REPORT_FLAGS_PATH"/repo-other + /bin/touch "$r_report_flags_path"/repo-other esac - install_date_msg=$(TextBrightRedBlink "${CHARS_ALERT}${install_date}") + install_date_msg=$(TextBrightRedBlink "${r_chars_alert}${install_date}") name_msg=$(TextBrightRed "${name_msg}${qpkg_name}") ;; normal) @@ -4927,26 +4934,26 @@ GenerateReposReportDataLine() undefined) assigned_repo_msg+=N/A name_msg+=$qpkg_name - /bin/touch "$REPORT_FLAGS_PATH"/na + /bin/touch "$r_report_flags_path"/na ;; *) - assigned_repo_msg=$(TextBrightOrange "${CHARS_ATTENTION}${assigned_repo}") + assigned_repo_msg=$(TextBrightOrange "${r_chars_attention}${assigned_repo}") name_msg=$(TextBrightOrange "${name_msg}${qpkg_name}") - /bin/touch "$REPORT_FLAGS_PATH"/repo-other + /bin/touch "$r_report_flags_path"/repo-other esac install_date_msg+=$install_date ;; mute) assigned_repo=N/A - /bin/touch "$REPORT_FLAGS_PATH"/na + /bin/touch "$r_report_flags_path"/na if ! QpkgIsDatabaseArchOK; then - install_date='incompatible arch' + install_date='incompatible architecture' elif ! QpkgIsDatabaseMinOSVerOk; then install_date="incompatible $(OsGetQnapOS)" elif ! QpkgIsDatabaseMinRAMOk; then - install_date='insufficient RAM' + install_date='insufficient RAM installed' else install_date='not installed' fi @@ -4960,15 +4967,15 @@ GenerateReposReportDataLine() echo "$name_msg|$assigned_repo_msg|$install_date_msg" else # column 1: package name. - printf "%-$((PACKAGE_NAME_COL_WIDTH+$(LenANSIDiff "$name_msg")))s" "$name_msg" + printf "%-$((r_report_qpkg_name_column_width+$(LenANSIDiff "$name_msg")))s" "$name_msg" # column 2: package repository - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_REPO_COL_WIDTH+$(LenANSIDiff "$assigned_repo_msg")))s" "$assigned_repo_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_repo_column_width+$(LenANSIDiff "$assigned_repo_msg")))s" "$assigned_repo_msg" # column 3: package installation date - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_INSTALL_DATE_COL_WIDTH+$(LenANSIDiff "$install_date_msg")))s" "$install_date_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_install_date_column_width+$(LenANSIDiff "$install_date_msg")))s" "$install_date_msg" printf '\n' fi @@ -4982,15 +4989,15 @@ GenerateAbsReportTitleLine() # column 1: package name. a='QPKG name:' - printf "%-$((PACKAGE_NAME_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_name_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 2: QPKG is installed a='Installed?' - printf "%-$((PACKAGE_INSTALLED_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_is_installed_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 3: package abbreviations a='Acceptable QPKG name abbreviations and aliases:' - printf "%-$((PACKAGE_ABBS_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_abbreviations_column_width+2+$(LenANSIDiff "$a")))s" "$a" printf '\n' @@ -5005,36 +5012,36 @@ GenerateAbsReportDataLine() # $qpkg_name local abs_msg='' - local installed_msg=$CHARS_BLANK + local installed_msg=$r_chars_blank local mode='' - local name_msg=$CHARS_BLANK + local name_msg=$r_chars_blank if QpkgIsInstalledMissing; then mode=highlight - /bin/touch "$REPORT_FLAGS_PATH"/status-missing + /bin/touch "$r_report_flags_path"/status-missing elif QpkgIsNtInstalled; then mode=mute - /bin/touch "$REPORT_FLAGS_PATH"/state-notinstalled + /bin/touch "$r_report_flags_path"/state-notinstalled else mode=normal - /bin/touch "$REPORT_FLAGS_PATH"/state-installed + /bin/touch "$r_report_flags_path"/state-installed fi case $mode in normal) - abs_msg=${CHARS_NORMAL}$(AddSeparators "$(QpkgGetDatabaseAbbrvs)") + abs_msg=${r_chars_normal}$(AddSeparators "$(QpkgGetDatabaseAbbrvs)") installed_msg+=true name_msg+=$qpkg_name ;; mute) if ! QpkgIsDatabaseArchOK "$qpkg_name"; then - abs_msg="${CHARS_ALERT}incompatible architecture" + abs_msg="${r_chars_alert}incompatible architecture" elif ! QpkgIsDatabaseMinOSVerOk "$qpkg_name"; then - abs_msg="${CHARS_ALERT}incompatible $(OsGetQnapOS) version" + abs_msg="${r_chars_alert}incompatible $(OsGetQnapOS) version" elif ! QpkgIsDatabaseMinRAMOk "$qpkg_name"; then - abs_msg="${CHARS_ALERT}insufficient RAM installed" + abs_msg="${r_chars_alert}insufficient RAM installed" else - abs_msg=${CHARS_NORMAL}$(AddSeparators "$(QpkgGetDatabaseAbbrvs "$qpkg_name")") + abs_msg=${r_chars_normal}$(AddSeparators "$(QpkgGetDatabaseAbbrvs "$qpkg_name")") fi abs_msg=$(TextDarkGrey "$abs_msg") @@ -5042,8 +5049,8 @@ GenerateAbsReportDataLine() name_msg+=$(TextDarkGrey "$qpkg_name") ;; highlight) - abs_msg=$(TextBrightRed "${CHARS_ALERT}$(AddSeparators "$(QpkgGetDatabaseAbbrvs)")") - installed_msg=$(TextBrightRedBlink "${CHARS_ALERT}missing") + abs_msg=$(TextBrightRed "${r_chars_alert}$(AddSeparators "$(QpkgGetDatabaseAbbrvs)")") + installed_msg=$(TextBrightRedBlink "${r_chars_alert}missing") name_msg+=$(TextBrightRed "$qpkg_name") esac @@ -5051,15 +5058,15 @@ GenerateAbsReportDataLine() echo "$name_msg|$installed_msg|$abs_msg" else # column 1: package name. - printf "%-$((PACKAGE_NAME_COL_WIDTH+$(LenANSIDiff "$name_msg")))s" "$name_msg" + printf "%-$((r_report_qpkg_name_column_width+$(LenANSIDiff "$name_msg")))s" "$name_msg" # column 2: package is installed? - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_INSTALLED_COL_WIDTH+$(LenANSIDiff "$installed_msg")))s" "$installed_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_is_installed_column_width+$(LenANSIDiff "$installed_msg")))s" "$installed_msg" # column 3: package abbreviations - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_ABBS_COL_WIDTH+$(LenANSIDiff "$abs_msg")))s" "$abs_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_abbreviations_column_width+$(LenANSIDiff "$abs_msg")))s" "$abs_msg" printf '\n' fi @@ -5073,43 +5080,43 @@ GenerateDepsReportTitleLine() # column 1: package name. a='QPKG name:' - printf "%-$((PACKAGE_NAME_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_name_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 2: package dependencies. a='Dependencies:' - printf "%-$((PACKAGE_DEPENDENCIES_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_dependencies_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 3: QPKG is installed? a='Installed?' - printf "%-$((PACKAGE_INSTALLED_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_is_installed_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 4: QPKG is enabled? a='Enabled?' - printf "%-$((PACKAGE_ENABLED_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_is_enabled_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 5: QPKG is managed by sherpa? a='Managed?' - printf "%-$((PACKAGE_MANAGED_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_is_managed_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 6: minimum NAS RAM required. a='Min. RAM:' - printf "%-$((PACKAGE_MIN_RAM_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_min_ram_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 7: minimum OS fimware version supported. a='Min. OS:' - printf "%-$((PACKAGE_MIN_OS_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_min_os_version_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 8: maximum OS fimware version supported. a='Max. OS:' - printf "%-$((PACKAGE_MAX_OS_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_max_os_version_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 9: arch is compatible? a='Supported arch?' - printf "%-$((PACKAGE_ARCH_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_arch_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 10: installed QPKG author a='Installed QPKG author:' - printf "%-$((STD_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_lazy_column_width+2+$(LenANSIDiff "$a")))s" "$a" printf '\n' @@ -5125,34 +5132,34 @@ GenerateDepsReportDataLine() local author=$(QpkgGetInstalledAuthor) local author_ok=false - local author_msg=$CHARS_BLANK + local author_msg=$r_chars_blank local arch=false - local arch_msg=$CHARS_BLANK + local arch_msg=$r_chars_blank local dep_name='' local deps='' - local deps_msg=$CHARS_NORMAL + local deps_msg=$r_chars_normal local deps_raw=$(QpkgGetDatabaseDependencies "$qpkg_name") local enabled=false - local enabled_msg=$CHARS_BLANK + local enabled_msg=$r_chars_blank local installed=false - local installed_msg=$CHARS_BLANK + local installed_msg=$r_chars_blank local managed=false - local managed_msg=$CHARS_BLANK + local managed_msg=$r_chars_blank local max_os=$(QpkgGetDatabaseMaxOSVer "$qpkg_name") - local max_os_msg=$CHARS_BLANK + local max_os_msg=$r_chars_blank local max_os_ok=false local min_os=$(QpkgGetDatabaseMinOSVer "$qpkg_name") - local min_os_msg=$CHARS_BLANK + local min_os_msg=$r_chars_blank local min_os_ok=false local min_ram=$(QpkgGetDatabaseMinRAM "$qpkg_name") - local min_ram_msg=$CHARS_BLANK + local min_ram_msg=$r_chars_blank local min_ram_ok=false local mode='' - local name_msg=$CHARS_BLANK + local name_msg=$r_chars_blank local req_alert=false local req_attention=false - /bin/touch "$REPORT_FLAGS_PATH"/deps + /bin/touch "$r_report_flags_path"/deps if QpkgIsInstalledMissing; then mode=missing @@ -5170,7 +5177,7 @@ GenerateDepsReportDataLine() case $mode in author) - /bin/touch "$REPORT_FLAGS_PATH"/status-wrongauthor + /bin/touch "$r_report_flags_path"/status-wrongauthor # Set field values. arch=N/A @@ -5185,8 +5192,8 @@ GenerateDepsReportDataLine() # Assign field messages. arch_msg+=$arch - author_msg=${CHARS_ATTENTION}${author} - deps_msg=${CHARS_ATTENTION}${deps} + author_msg=${r_chars_attention}${author} + deps_msg=${r_chars_attention}${deps} enabled_msg+=$enabled installed_msg+=$installed managed_msg+=$managed @@ -5238,7 +5245,7 @@ GenerateDepsReportDataLine() if [[ $arch = true ]]; then arch_msg+=$arch else - arch_msg=${CHARS_ALERT}${arch} + arch_msg=${r_chars_alert}${arch} fi author_msg+=$author @@ -5247,28 +5254,28 @@ GenerateDepsReportDataLine() if [[ $enabled = true ]]; then enabled_msg+=$enabled else - enabled_msg=${CHARS_ALERT}${enabled} + enabled_msg=${r_chars_alert}${enabled} fi - installed_msg=${CHARS_ALERT}${installed} + installed_msg=${r_chars_alert}${installed} managed_msg+=$managed if [[ $max_os_ok = true ]]; then max_os_msg+=$max_os else - max_os_msg=${CHARS_ALERT}${max_os} + max_os_msg=${r_chars_alert}${max_os} fi if [[ $min_os_ok = true ]]; then min_os_msg+=$min_os else - min_os_msg=${CHARS_ALERT}${min_os} + min_os_msg=${r_chars_alert}${min_os} fi if [[ $min_ram_ok = true ]]; then min_ram_msg+=$min_ram else - min_ram_msg=${CHARS_ALERT}${min_ram} + min_ram_msg=${r_chars_alert}${min_ram} fi # Highlight field messages. @@ -5320,7 +5327,7 @@ GenerateDepsReportDataLine() fi ;; mute) - /bin/touch "$REPORT_FLAGS_PATH"/state-notinstalled + /bin/touch "$r_report_flags_path"/state-notinstalled # Set field values. QpkgIsDatabaseArchOK "$qpkg_name" && arch=true @@ -5341,14 +5348,14 @@ GenerateDepsReportDataLine() QpkgIsDatabaseMinOSVerOk "$qpkg_name" && min_os_ok=true QpkgIsDatabaseMinRAMOk "$qpkg_name" && min_ram_ok=true - /bin/touch "$REPORT_FLAGS_PATH"/na + /bin/touch "$r_report_flags_path"/na # Assign field messages. if [[ $arch = true ]]; then arch_msg+=$arch else - arch_msg=${CHARS_ATTENTION}${arch} + arch_msg=${r_chars_attention}${arch} req_attention=true fi @@ -5361,21 +5368,21 @@ GenerateDepsReportDataLine() if [[ $max_os_ok = true ]]; then max_os_msg+=$max_os else - max_os_msg=${CHARS_ATTENTION}${max_os} + max_os_msg=${r_chars_attention}${max_os} req_attention=true fi if [[ $min_os_ok = true ]]; then min_os_msg+=$min_os else - min_os_msg=${CHARS_ATTENTION}${min_os} + min_os_msg=${r_chars_attention}${min_os} req_attention=true fi if [[ $min_ram_ok = true ]]; then min_ram_msg+=$min_ram else - min_ram_msg=${CHARS_ATTENTION}${min_ram} + min_ram_msg=${r_chars_attention}${min_ram} req_attention=true fi @@ -5428,7 +5435,7 @@ GenerateDepsReportDataLine() if [[ $arch = true ]]; then arch_msg+=$arch else - arch_msg=${CHARS_ALERT}${arch} + arch_msg=${r_chars_alert}${arch} req_alert=true fi @@ -5442,7 +5449,7 @@ GenerateDepsReportDataLine() deps+=$(TextBrightGreen "$dep_name") else deps+=$(TextBrightRed "$dep_name") - deps_msg=$(TextBrightRed "$CHARS_ALERT") + deps_msg=$(TextBrightRed "$r_chars_alert") req_alert=true fi done @@ -5453,7 +5460,7 @@ GenerateDepsReportDataLine() if [[ $enabled = true ]]; then enabled_msg+=$enabled else - enabled_msg=${CHARS_ALERT}${enabled} + enabled_msg=${r_chars_alert}${enabled} req_alert=true fi @@ -5463,21 +5470,21 @@ GenerateDepsReportDataLine() if [[ $max_os_ok = true ]]; then max_os_msg+=$max_os else - max_os_msg=${CHARS_ALERT}${max_os} + max_os_msg=${r_chars_alert}${max_os} req_alert=true fi if [[ $min_os_ok = true ]]; then min_os_msg+=$min_os else - min_os_msg=${CHARS_ALERT}${min_os} + min_os_msg=${r_chars_alert}${min_os} req_alert=true fi if [[ $min_ram_ok = true ]]; then min_ram_msg+=$min_ram else - min_ram_msg=${CHARS_ALERT}${min_ram} + min_ram_msg=${r_chars_alert}${min_ram} req_alert=true fi @@ -5532,11 +5539,11 @@ GenerateDepsReportDataLine() esac if [[ $req_alert = true ]]; then - /bin/touch "$REPORT_FLAGS_PATH"/req-alert - name_msg=${CHARS_BLANK}$(TextBrightRed "$qpkg_name") + /bin/touch "$r_report_flags_path"/req-alert + name_msg=${r_chars_blank}$(TextBrightRed "$qpkg_name") elif [[ $req_attention = true ]]; then - /bin/touch "$REPORT_FLAGS_PATH"/req-attention - name_msg=${CHARS_BLANK}$(TextBrightOrange "$qpkg_name") + /bin/touch "$r_report_flags_path"/req-attention + name_msg=${r_chars_blank}$(TextBrightOrange "$qpkg_name") elif [[ $mode = mute ]]; then name_msg+=$(TextDarkGrey "$qpkg_name") else @@ -5547,43 +5554,43 @@ GenerateDepsReportDataLine() echo "$name_msg|$deps_msg|$installed_msg|$enabled_msg|$managed_msg|$min_ram_msg|$min_os_msg|$max_os_msg|$arch_msg|$author_msg" else # column 1: package name. - printf "%-$((PACKAGE_NAME_COL_WIDTH+$(LenANSIDiff "$name_msg")))s" "$name_msg" + printf "%-$((r_report_qpkg_name_column_width+$(LenANSIDiff "$name_msg")))s" "$name_msg" # column 2: package dependencies. - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_DEPENDENCIES_COL_WIDTH+$(LenANSIDiff "$deps_msg")))s" "$deps_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_dependencies_column_width+$(LenANSIDiff "$deps_msg")))s" "$deps_msg" # column 3: package is installed? - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_INSTALLED_COL_WIDTH+$(LenANSIDiff "$installed_msg")))s" "$installed_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_is_installed_column_width+$(LenANSIDiff "$installed_msg")))s" "$installed_msg" # column 4: package is enabled? - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_ENABLED_COL_WIDTH+$(LenANSIDiff "$enabled_msg")))s" "$enabled_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_is_enabled_column_width+$(LenANSIDiff "$enabled_msg")))s" "$enabled_msg" # column 5: package is managed by sherpa? - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_MANAGED_COL_WIDTH+$(LenANSIDiff "$managed_msg")))s" "$managed_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_is_managed_column_width+$(LenANSIDiff "$managed_msg")))s" "$managed_msg" # column 6: minimum NAS RAM required. - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_MIN_RAM_COL_WIDTH+$(LenANSIDiff "$min_ram_msg")))s" "$min_ram_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_min_ram_column_width+$(LenANSIDiff "$min_ram_msg")))s" "$min_ram_msg" # column 7: minimum OS fimware version supported. - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_MIN_OS_COL_WIDTH+$(LenANSIDiff "$min_os_msg")))s" "$min_os_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_min_os_version_column_width+$(LenANSIDiff "$min_os_msg")))s" "$min_os_msg" # column 8: maximum OS fimware version supported. - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_MAX_OS_COL_WIDTH+$(LenANSIDiff "$max_os_msg")))s" "$max_os_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_max_os_version_column_width+$(LenANSIDiff "$max_os_msg")))s" "$max_os_msg" # column 9: NAS arch is compatible? - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_ARCH_COL_WIDTH+$(LenANSIDiff "$arch_msg")))s" "$arch_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_arch_column_width+$(LenANSIDiff "$arch_msg")))s" "$arch_msg" # column 10: installed QPKG author. - printf "%$((COLUMN_SPACING))s" - printf "%-$((STD_COL_WIDTH+$(LenANSIDiff "$author_msg")))s" "$author_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_lazy_column_width+$(LenANSIDiff "$author_msg")))s" "$author_msg" printf '\n' fi @@ -5597,39 +5604,39 @@ GenerateFeaturesReportTitleLine() # column 1: package name. a='QPKG name:' - printf "%-$((PACKAGE_NAME_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_name_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 2: package supports `backup` action? a='CanBack?' - printf "%-$((PACKAGE_SUPPORTS_BACKUP_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_supports_backup_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 3: package supports `clean` action? a='CanClean?' - printf "%-$((PACKAGE_SUPPORTS_CLEAN_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_supports_clean_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 4: package supports restart-to-update application action? a='StartUpd?' - printf "%-$((PACKAGE_SUPPORTS_START_TO_UPDATE_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_supports_start_to_update_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 5: package is set to auto-update on restart? a='AutoUpd?' - printf "%-$((PACKAGE_AUTO_UPDATE_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_auto_update_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 6: package active test is builtin? a='LiveTest?' - printf "%-$((PACKAGE_ACTIVE_TEST_BUILTIN_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_active_test_builtin_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 7: package is independent? a='Indep?' - printf "%-$((PACKAGE_TIER_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_tier_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 8: NAS arch is compatible? a='Compat?' - printf "%-$((PACKAGE_COMPATIBLE_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_qpkg_is_compatible_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 9: QPKG is sherpa-compatible? a='Enhanced?' - printf "%-$((STD_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%-$((r_report_lazy_column_width+2+$(LenANSIDiff "$a")))s" "$a" printf '\n' @@ -5644,25 +5651,25 @@ GenerateFeaturesReportDataLine() # $qpkg_name local active_test=false - local active_test_msg=$CHARS_BLANK + local active_test_msg=$r_chars_blank local autoupdate=false - local autoupdate_msg=$CHARS_BLANK + local autoupdate_msg=$r_chars_blank local backup=false - local backup_msg=$CHARS_BLANK + local backup_msg=$r_chars_blank local clean=false - local clean_msg=$CHARS_BLANK + local clean_msg=$r_chars_blank local compatible=false - local compatible_msg=$CHARS_BLANK + local compatible_msg=$r_chars_blank local mode='' - local name_msg=$CHARS_BLANK + local name_msg=$r_chars_blank local req_alert=false local req_attention=false local restart_to_update=false - local restart_to_update_msg=$CHARS_BLANK + local restart_to_update_msg=$r_chars_blank local sherpa_compatible=false - local sherpa_compatible_msg=$CHARS_BLANK + local sherpa_compatible_msg=$r_chars_blank local tier=false - local tier_msg=$CHARS_BLANK + local tier_msg=$r_chars_blank if QpkgIsInstalledMissing; then mode=missing @@ -5680,7 +5687,7 @@ GenerateFeaturesReportDataLine() req_attention=true # Assign field messages. - backup_msg=${CHARS_ATTENTION}${backup} + backup_msg=${r_chars_attention}${backup} # Highlight field messages. backup_msg=$(TextBrightOrange "$backup_msg") @@ -5691,7 +5698,7 @@ GenerateFeaturesReportDataLine() req_alert=true # Assign field messages. - backup_msg=${CHARS_ALERT}${backup} + backup_msg=${r_chars_alert}${backup} # Highlight field messages. backup_msg=$(TextBrightRedBlink "$backup_msg") @@ -5739,7 +5746,7 @@ GenerateFeaturesReportDataLine() autoupdate=true # sherpa always auto-updates and this can't be disabled. else autoupdate=N/A - /bin/touch "$REPORT_FLAGS_PATH"/na + /bin/touch "$r_report_flags_path"/na fi QpkgIsDatabaseCanBackup && backup=true @@ -5798,11 +5805,11 @@ GenerateFeaturesReportDataLine() esac if [[ $req_alert = true ]]; then - /bin/touch "$REPORT_FLAGS_PATH"/req-alert - name_msg=${CHARS_BLANK}$(TextBrightRed "$qpkg_name") + /bin/touch "$r_report_flags_path"/req-alert + name_msg=${r_chars_blank}$(TextBrightRed "$qpkg_name") elif [[ $req_attention = true ]]; then - /bin/touch "$REPORT_FLAGS_PATH"/req-attention - name_msg=${CHARS_BLANK}$(TextBrightOrange "$qpkg_name") + /bin/touch "$r_report_flags_path"/req-attention + name_msg=${r_chars_blank}$(TextBrightOrange "$qpkg_name") elif [[ $mode = mute ]]; then name_msg+=$(TextDarkGrey "$qpkg_name") else @@ -5813,39 +5820,39 @@ GenerateFeaturesReportDataLine() echo "$name_msg|$backup_msg|$clean_msg|$restart_to_update_msg|$autoupdate_msg|$active_test_msg|$tier_msg|$compatible_msg|$sherpa_compatible_msg" else # column 1: package name. - printf "%-$((PACKAGE_NAME_COL_WIDTH+$(LenANSIDiff "$name_msg")))s" "$name_msg" + printf "%-$((r_report_qpkg_name_column_width+$(LenANSIDiff "$name_msg")))s" "$name_msg" # column 2: package supports `backup` action? - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_SUPPORTS_BACKUP_COL_WIDTH+$(LenANSIDiff "$backup_msg")))s" "$backup_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_supports_backup_column_width+$(LenANSIDiff "$backup_msg")))s" "$backup_msg" # column 3: package supports `clean` action? - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_SUPPORTS_CLEAN_COL_WIDTH+$(LenANSIDiff "$clean_msg")))s" "$clean_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_supports_clean_column_width+$(LenANSIDiff "$clean_msg")))s" "$clean_msg" # column 4: package supports restart-to-update application action? - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_SUPPORTS_START_TO_UPDATE_COL_WIDTH+$(LenANSIDiff "$restart_to_update_msg")))s" "$restart_to_update_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_supports_start_to_update_column_width+$(LenANSIDiff "$restart_to_update_msg")))s" "$restart_to_update_msg" # column 5: package is set to auto-update on restart? - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_AUTO_UPDATE_COL_WIDTH+$(LenANSIDiff "$autoupdate_msg")))s" "$autoupdate_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_auto_update_column_width+$(LenANSIDiff "$autoupdate_msg")))s" "$autoupdate_msg" # column 6: package active test is builtin? - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_ACTIVE_TEST_BUILTIN_COL_WIDTH+$(LenANSIDiff "$active_test_msg")))s" "$active_test_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_active_test_builtin_column_width+$(LenANSIDiff "$active_test_msg")))s" "$active_test_msg" # column 7: package is independent? - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_TIER_COL_WIDTH+$(LenANSIDiff "$tier_msg")))s" "$tier_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_tier_column_width+$(LenANSIDiff "$tier_msg")))s" "$tier_msg" # column 8: NAS arch is compatible? - printf "%$((COLUMN_SPACING))s" - printf "%-$((PACKAGE_COMPATIBLE_COL_WIDTH+$(LenANSIDiff "$compatible_msg")))s" "$compatible_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_qpkg_is_compatible_column_width+$(LenANSIDiff "$compatible_msg")))s" "$compatible_msg" # column 9: QPKG is sherpa-compatible? - printf "%$((COLUMN_SPACING))s" - printf "%-$((STD_COL_WIDTH+$(LenANSIDiff "$sherpa_compatible_msg")))s" "$sherpa_compatible_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_lazy_column_width+$(LenANSIDiff "$sherpa_compatible_msg")))s" "$sherpa_compatible_msg" printf '\n' fi @@ -5860,18 +5867,18 @@ DisplayAsBacksReportTitleLine() printf '\n' # column 1: backup filename - a="${CHARS_BULLET}Backup file:" - printf "%-$((FILE_NAME_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + a="${r_chars_bullet}Backup file:" + printf "%-$((r_report_file_name_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 2: filesize in bytes - printf "%$((COLUMN_SPACING))s" - a="${CHARS_BULLET}Size in bytes:" - printf "%-$((FILE_BYTES_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%$((r_report_column_spacing))s" + a="${r_chars_bullet}Size in bytes:" + printf "%-$((r_report_file_bytes_column_width+2+$(LenANSIDiff "$a")))s" "$a" # column 3: last backup date - printf "%$((COLUMN_SPACING))s" - a="${CHARS_BULLET}Backup date:" - printf "%-$((FILE_CHANGE_DATE_COL_WIDTH+2+$(LenANSIDiff "$a")))s" "$a" + printf "%$((r_report_column_spacing))s" + a="${r_chars_bullet}Backup date:" + printf "%-$((r_report_file_change_date_column_width+2+$(LenANSIDiff "$a")))s" "$a" printf '\n' @@ -5887,11 +5894,11 @@ DisplayAsBacksReportItemLine() # $4 = age threshold to highlight (optional) '1 week ago' (default) e.g. '2 days ago', '2 weeks ago', etc ... local epoch_time=${1:-0} - local epoch_time_msg=$CHARS_NORMAL + local epoch_time_msg=$r_chars_normal local file_bytes=${3:-0} - local file_bytes_msg=$CHARS_BLANK + local file_bytes_msg=$r_chars_blank local file_name=${2:-} - local file_name_msg=$CHARS_BLANK + local file_name_msg=$r_chars_blank local local_highlight_backups_older_than=${4:-'1 week ago'} local mode='' @@ -5908,25 +5915,25 @@ DisplayAsBacksReportItemLine() epoch_time_msg+=$(ConvertSecondsToFullDate "$epoch_time") file_bytes_msg+=$file_bytes file_name_msg+=$file_name - /bin/touch "$REPORT_FLAGS_PATH"/backup-file-ok + /bin/touch "$r_report_flags_path"/backup-file-ok ;; highlight) - epoch_time_msg=$(TextBrightRed "${CHARS_ALERT}$(ConvertSecondsToFullDate "$epoch_time")") + epoch_time_msg=$(TextBrightRed "${r_chars_alert}$(ConvertSecondsToFullDate "$epoch_time")") file_bytes_msg+=$(TextBrightRed "$file_bytes") file_name_msg+=$(TextBrightRed "$file_name") - /bin/touch "$REPORT_FLAGS_PATH"/backup-file-old + /bin/touch "$r_report_flags_path"/backup-file-old esac # column 1: backup filename - printf "%-$((FILE_NAME_COL_WIDTH+$(LenANSIDiff "$file_name_msg")))s" "$file_name_msg" + printf "%-$((r_report_file_name_column_width+$(LenANSIDiff "$file_name_msg")))s" "$file_name_msg" # column 2: filesize in bytes - printf "%$((COLUMN_SPACING))s" - printf "%$((FILE_BYTES_COL_WIDTH+$(LenANSIDiff "$file_bytes_msg")))s" "$file_bytes_msg " # append 1 x whitespace char to force right-justified numbers to the left a bit. Looks nicer. + printf "%$((r_report_column_spacing))s" + printf "%$((r_report_file_bytes_column_width+$(LenANSIDiff "$file_bytes_msg")))s" "$file_bytes_msg " # append 1 x whitespace char to force right-justified numbers to the left a bit. Looks nicer. # column 3: last backup date - printf "%$((COLUMN_SPACING))s" - printf "%-$((FILE_CHANGE_DATE_COL_WIDTH+$(LenANSIDiff "$epoch_time_msg")))s" "$epoch_time_msg" + printf "%$((r_report_column_spacing))s" + printf "%-$((r_report_file_change_date_column_width+$(LenANSIDiff "$epoch_time_msg")))s" "$epoch_time_msg" printf '\n' @@ -5938,7 +5945,7 @@ DisplayAsHelpTitle() # Inputs: # $1 = text - printf "\n${CHARS_BULLET}%s\n" "$(Capitalise "${1:-}" | tr -s ' ')" + printf "\n${r_chars_bullet}%s\n" "$(Capitalise "${1:-}" | tr -s ' ')" } @@ -5949,7 +5956,7 @@ DisplayAsHelpTitleHighlighted() # $1 = text # shellcheck disable=2059 - printf "\n$(TextBrightOrange "${CHARS_BULLET}%s\n")" "$(Capitalise "${1:-}")" + printf "\n$(TextBrightOrange "${r_chars_bullet}%s\n")" "$(Capitalise "${1:-}")" } @@ -5980,7 +5987,7 @@ DisplayAsIndentActionResultDurationReason() [[ -n ${3:-} ]] && duration=$(ConvertMillisecondsToDuration "$3") - printf "%${ACTION_RESULT_INDENT}s" '' + printf "%${r_report_action_result_indent}s" '' if [[ -z ${4:-} ]]; then printf "%s %s%s" "$(Lowercase "$action")" "$2" "$([[ -n $duration ]] && printf ' in %s' "$duration")" @@ -6069,12 +6076,12 @@ ShowHelpActions() DisplayAsProjSynExam "multiple $(ShowAsAction)s are supported like this" "$(ShowAsAction) $(ShowAsPackages) $(ShowAsAction) $(ShowAsPackages)" DisplayAsProjSynIndentExam '' 'install sabnzbd sickgear reactivate transmission uninstall lazy nzbget upgrade nzbtomedia' - } > "$REPORT_OUTPUT_PATHFILE" + } > "$r_report_output_pathfile" EraseThisLine - if [[ -e $REPORT_OUTPUT_PATHFILE ]]; then - DisplayFileInViewport "$REPORT_OUTPUT_PATHFILE" + if [[ -e $r_report_output_pathfile ]]; then + DisplayFileInViewport "$r_report_output_pathfile" else ShowAsError 'no information to display' fi @@ -6116,12 +6123,12 @@ ShowHelpActionsAll() DisplayAsProjSynIndentExam 'uninstall all QPKGs' 'uninstall all' DisplayAsProjSynIndentExam 'upgrade all QPKGs (and internal applications where-supported)' 'upgrade all' - } > "$REPORT_OUTPUT_PATHFILE" + } > "$r_report_output_pathfile" EraseThisLine - if [[ -e $REPORT_OUTPUT_PATHFILE ]]; then - DisplayFileInViewport "$REPORT_OUTPUT_PATHFILE" + if [[ -e $r_report_output_pathfile ]]; then + DisplayFileInViewport "$r_report_output_pathfile" else ShowAsError 'no information to display' fi @@ -6133,7 +6140,7 @@ ShowHelpActionsAll() ShowHelpBackupLocation() { - DisplayAsSynExam 'the backup location can be accessed by running' "cd $QPKG_BU_PATH" + DisplayAsSynExam 'the backup location can be accessed by running' "cd $r_qpkg_bu_path" return 0 @@ -6189,12 +6196,12 @@ ShowHelpGroups() DisplayAsProjSynIndentExam 'select only missing QPKGs (these are partly installed and broken)' "$(ShowAsAction) missing" DisplayAsProjSynExam 'multiple groups are supported like this' "$(ShowAsAction) $(ShowAsPackageGroup) $(ShowAsPackageGroup)" - } > "$REPORT_OUTPUT_PATHFILE" + } > "$r_report_output_pathfile" EraseThisLine - if [[ -e $REPORT_OUTPUT_PATHFILE ]]; then - DisplayFileInViewport "$REPORT_OUTPUT_PATHFILE" + if [[ -e $r_report_output_pathfile ]]; then + DisplayFileInViewport "$r_report_output_pathfile" else ShowAsError 'no information to display' fi @@ -6210,7 +6217,7 @@ ShowHelpIssue() DisplayAsHelpTitle "alternatively, post on the QNAP NAS Community Forum: $(ShowAsURL 'https://forum.qnap.com/viewtopic.php?f=320&t=132373')" DisplayAsProjSynIndentExam "view only the most recent $(ShowAsTitleName) session log" last DisplayAsProjSynIndentExam "view the entire $(ShowAsTitleName) session log" log - DisplayAsProjSynIndentExam "upload the most-recent $(FormatAsThous "$LOG_TAIL_LINES") lines in your $(ShowAsTitleName) log to the $(ShowAsURL 'https://termbin.com') public pastebin. A URL will be generated afterward" 'paste log' + DisplayAsProjSynIndentExam "upload the most-recent $(FormatAsThous "$r_log_tail_lines") lines in your $(ShowAsTitleName) log to the $(ShowAsURL 'https://termbin.com') public pastebin. A URL will be generated afterward" 'paste log' DisplayAsHelpTitleHighlighted "if you need help, please include a copy of your $(ShowAsTitleName) $(TextBrightOrange 'log for analysis!')" Display @@ -6242,12 +6249,12 @@ ShowHelpLists() DisplayAsProjSynIndentExam '' upgradable DisplayAsProjSynIndentExam "list $(ShowAsTitleName) object version numbers" 'list versions' - } > "$REPORT_OUTPUT_PATHFILE" + } > "$r_report_output_pathfile" EraseThisLine - if [[ -e $REPORT_OUTPUT_PATHFILE ]]; then - DisplayFileInViewport "$REPORT_OUTPUT_PATHFILE" + if [[ -e $r_report_output_pathfile ]]; then + DisplayFileInViewport "$r_report_output_pathfile" else ShowAsError 'no information to display' fi @@ -6281,12 +6288,12 @@ ShowHelpShow() DisplayAsProjSynIndentExam '' results DisplayAsProjSynIndentExam 'find the live status of each application in all QPKGs' 'show status' - } > "$REPORT_OUTPUT_PATHFILE" + } > "$r_report_output_pathfile" EraseThisLine - if [[ -e $REPORT_OUTPUT_PATHFILE ]]; then - DisplayFileInViewport "$REPORT_OUTPUT_PATHFILE" + if [[ -e $r_report_output_pathfile ]]; then + DisplayFileInViewport "$r_report_output_pathfile" else ShowAsError 'no information to display' fi @@ -6309,12 +6316,12 @@ ShowHelpOptions() DisplayAsProjSynIndentExam '' "$(ShowAsAction) $(ShowAsPackages) verbose" DisplayAsProjSynIndentExam '' "$(ShowAsAction) $(ShowAsPackages) v" - } > "$REPORT_OUTPUT_PATHFILE" + } > "$r_report_output_pathfile" EraseThisLine - if [[ -e $REPORT_OUTPUT_PATHFILE ]]; then - DisplayFileInViewport "$REPORT_OUTPUT_PATHFILE" + if [[ -e $r_report_output_pathfile ]]; then + DisplayFileInViewport "$r_report_output_pathfile" else ShowAsError 'no information to display' fi @@ -6334,12 +6341,12 @@ ShowHelpPackages() ShowHelpBasic DisplayAsHelpTitle 'usage examples for QPKGs will go here:' - } > "$REPORT_OUTPUT_PATHFILE" + } > "$r_report_output_pathfile" EraseThisLine - if [[ -e $REPORT_OUTPUT_PATHFILE ]]; then - DisplayFileInViewport "$REPORT_OUTPUT_PATHFILE" + if [[ -e $r_report_output_pathfile ]]; then + DisplayFileInViewport "$r_report_output_pathfile" else ShowAsError 'no information to display' fi @@ -6368,7 +6375,7 @@ ShowHelpProblems() DisplayAsProjSynIndentExam '' l DisplayAsProjSynIndentExam "view the entire $(ShowAsTitleName) session log" log DisplayAsProjSynIndentExam "upload the most-recent session in your $(ShowAsTitleName) log to the $(ShowAsURL 'https://termbin.com') public pastebin. A URL will be generated afterward" 'paste last' - DisplayAsProjSynIndentExam "upload the most-recent $(FormatAsThous "$LOG_TAIL_LINES") lines in your $(ShowAsTitleName) log to the $(ShowAsURL 'https://termbin.com') public pastebin. A URL will be generated afterward" 'paste log' + DisplayAsProjSynIndentExam "upload the most-recent $(FormatAsThous "$r_log_tail_lines") lines in your $(ShowAsTitleName) log to the $(ShowAsURL 'https://termbin.com') public pastebin. A URL will be generated afterward" 'paste log' DisplayAsProjSynIndentExam 'reactivate installed QPKGs (upgrades internal applications where-supported)' 'reactivate all' DisplayAsProjSynIndentExam "remove all cached $(ShowAsTitleName) items and logs" reset DisplayAsProjSynIndentExam 'find the live status of each application in these QPKGs' "status $(ShowAsPackages)" @@ -6378,12 +6385,12 @@ ShowHelpProblems() DisplayAsProjSynIndentExam '' "$(ShowAsAction) $(ShowAsPackages) v" DisplayAsHelpTitleHighlighted "if you need help, please include a copy of your $(ShowAsTitleName) $(TextBrightOrange "log for analysis!")" - } > "$REPORT_OUTPUT_PATHFILE" + } > "$r_report_output_pathfile" EraseThisLine - if [[ -e $REPORT_OUTPUT_PATHFILE ]]; then - DisplayFileInViewport "$REPORT_OUTPUT_PATHFILE" + if [[ -e $r_report_output_pathfile ]]; then + DisplayFileInViewport "$r_report_output_pathfile" else ShowAsError 'no information to display' fi @@ -6410,12 +6417,12 @@ ShowHelpUpgrades() DisplayAsProjSynIndentExam '' 's upgradable' DisplayAsProjSynIndentExam '' 's new' - } > "$REPORT_OUTPUT_PATHFILE" + } > "$r_report_output_pathfile" EraseThisLine - if [[ -e $REPORT_OUTPUT_PATHFILE ]]; then - DisplayFileInViewport "$REPORT_OUTPUT_PATHFILE" + if [[ -e $r_report_output_pathfile ]]; then + DisplayFileInViewport "$r_report_output_pathfile" else ShowAsError 'no information to display' fi @@ -6445,12 +6452,12 @@ ShowHelpTips() DisplayAsProjSynIndentExam 'upgrade the internal applications only' "reactivate $(ShowAsPackages)" ShowHelpBackupLocation - } > "$REPORT_OUTPUT_PATHFILE" + } > "$r_report_output_pathfile" EraseThisLine - if [[ -e $REPORT_OUTPUT_PATHFILE ]]; then - DisplayFileInViewport "$REPORT_OUTPUT_PATHFILE" + if [[ -e $r_report_output_pathfile ]]; then + DisplayFileInViewport "$r_report_output_pathfile" else ShowAsError 'no information to display' fi @@ -6468,8 +6475,8 @@ ViewLogLast() ExtractPrevSessFromTail EraseThisLine - if [[ -e $SESS_LAST_PATHFILE ]]; then - DisplayFileInViewport "$SESS_LAST_PATHFILE" linenumbers + if [[ -e $r_session_last_pathfile ]]; then + DisplayFileInViewport "$r_session_last_pathfile" linenumbers Display else ShowAsError 'no last session log to display' @@ -6488,8 +6495,8 @@ ViewLogTail() ExtractTailFromLog EraseThisLine - if [[ -e $SESS_TAIL_PATHFILE ]]; then - DisplayFileInViewport "$SESS_TAIL_PATHFILE" linenumbers + if [[ -e $r_session_tail_pathfile ]]; then + DisplayFileInViewport "$r_session_tail_pathfile" linenumbers Display else ShowAsError 'no session log tail to display' @@ -6549,7 +6556,7 @@ DisplayFileInViewport() fi fi - if [[ $($WC_CMD -l < "$filename") -ge $SESS_ROWS || $($WC_CMD -L < "$filename") -ge $SESS_COLS ]]; then + if [[ $($WC_CMD -l < "$filename") -ge $r_sess_rows || $($WC_CMD -L < "$filename") -ge $r_sess_columns ]]; then if [[ -e $GNU_LESS_CMD ]]; then options=' --quit-on-intr --tilde --mouse --RAW-CONTROL-CHARS --shift=4 --redraw-on-quit --quit-if-one-screen' [[ $wraplines = false ]] && options+=' --chop-long-lines' @@ -6595,12 +6602,12 @@ PasteLogLast() DisableDebugToArchiveAndFile ExtractPrevSessFromTail - if [[ -e $SESS_LAST_PATHFILE ]]; then + if [[ -e $r_session_last_pathfile ]]; then if Quiz "Press 'Y' to post the most-recent session in your $(ShowAsTitleName) log to a public pastebin, or any other key to abort"; then ShowAsProc "upload $(ShowAsTitleName) log" # with thanks to https://github.com/solusipse/fiche - link=$($CAT_CMD --number "$SESS_LAST_PATHFILE" | (exec 3<>/dev/tcp/termbin.com/9999; $CAT_CMD >&3; $CAT_CMD <&3; exec 3<&-)) + link=$($CAT_CMD --number "$r_session_last_pathfile" | (exec 3<>/dev/tcp/termbin.com/9999; $CAT_CMD >&3; $CAT_CMD <&3; exec 3<&-)) if [[ $? -eq 0 ]]; then ShowAsDone "your $(ShowAsTitleName) log is now online at $(ShowAsURL "$link") and will be deleted in 1 month" @@ -6630,12 +6637,12 @@ PasteLogTail() DisableDebugToArchiveAndFile ExtractTailFromLog - if [[ -e $SESS_TAIL_PATHFILE ]]; then - if Quiz "Press 'Y' to post the most-recent $(FormatAsThous "$LOG_TAIL_LINES") lines in your $(ShowAsTitleName) log to a public pastebin, or any other key to abort"; then + if [[ -e $r_session_tail_pathfile ]]; then + if Quiz "Press 'Y' to post the most-recent $(FormatAsThous "$r_log_tail_lines") lines in your $(ShowAsTitleName) log to a public pastebin, or any other key to abort"; then ShowAsProc "upload $(ShowAsTitleName) log" # with thanks to https://github.com/solusipse/fiche - link=$($CAT_CMD --number "$SESS_TAIL_PATHFILE" | (exec 3<>/dev/tcp/termbin.com/9999; $CAT_CMD >&3; $CAT_CMD <&3; exec 3<&-)) + link=$($CAT_CMD --number "$r_session_tail_pathfile" | (exec 3<>/dev/tcp/termbin.com/9999; $CAT_CMD >&3; $CAT_CMD <&3; exec 3<&-)) if [[ $? -eq 0 ]]; then ShowAsDone "your $(ShowAsTitleName) log is now online at $(ShowAsURL "$link") and will be deleted in 1 month" @@ -6663,7 +6670,7 @@ GetLogSessStartLine() # Inputs: # $1 = how many sessions back? (optional) default = 1 - local -i linenum=$(($($GREP_CMD -n 'SCRIPT:.*started:' "$SESS_TAIL_PATHFILE" | $TAIL_CMD -n${1:-1} | head -n1 | cut -d':' -f1)-1)) + local -i linenum=$(($($GREP_CMD -n 'SCRIPT:.*started:' "$r_session_tail_pathfile" | $TAIL_CMD -n${1:-1} | head -n1 | cut -d':' -f1)-1)) [[ $linenum -lt 1 ]] && linenum=1 printf '%s' "$linenum" @@ -6675,7 +6682,7 @@ GetLogSessFinishLine() # Inputs: # $1 = how many sessions back? (optional) default = 1 - local -i linenum=$(($($GREP_CMD -n 'SCRIPT:.*finished:' "$SESS_TAIL_PATHFILE" | $TAIL_CMD -n${1:-1} | cut -d':' -f1)+2)) + local -i linenum=$(($($GREP_CMD -n 'SCRIPT:.*finished:' "$r_session_tail_pathfile" | $TAIL_CMD -n${1:-1} | cut -d':' -f1)+2)) [[ $linenum -eq 2 ]] && linenum=3 printf '%s' "$linenum" @@ -6684,7 +6691,7 @@ GetLogSessFinishLine() ArchiveActiveSessLog() { - [[ -n ${sess_active_pathfile:-} && -e $sess_active_pathfile ]] && $CAT_CMD "$sess_active_pathfile" >> "$SESS_ARCHIVE_PATHFILE" + [[ -n ${sess_active_pathfile:-} && -e $sess_active_pathfile ]] && $CAT_CMD "$sess_active_pathfile" >> "$r_session_archive_pathfile" } @@ -6695,9 +6702,9 @@ ArchivePriorSessLogs() local f='' - for f in "$THIS_PACKAGE_PATH"/session.*.active.log; do + for f in "$r_this_package_path"/session.*.active.log; do if [[ -f $f && $f != "$sess_active_pathfile" ]]; then - $CAT_CMD "$f" >> "$SESS_ARCHIVE_PATHFILE" + $CAT_CMD "$f" >> "$r_session_archive_pathfile" rm -f "$f" 2> /dev/null fi done @@ -6721,7 +6728,7 @@ ExtractPrevSessFromTail() ExtractTailFromLog - if [[ -e $SESS_TAIL_PATHFILE ]]; then + if [[ -e $r_session_tail_pathfile ]]; then end_line=$(GetLogSessFinishLine "$old_session") start_line=$((end_line+1)) # Ensure an invalid condition, to be solved by the loop. @@ -6732,9 +6739,9 @@ ExtractPrevSessFromTail() [[ $old_session -gt $old_session_limit ]] && break done - $SED_CMD "$start_line,$end_line!d" "$SESS_TAIL_PATHFILE" > "$SESS_LAST_PATHFILE" + $SED_CMD "$start_line,$end_line!d" "$r_session_tail_pathfile" > "$r_session_last_pathfile" else - rm -f "$SESS_LAST_PATHFILE" 2> /dev/null + rm -f "$r_session_last_pathfile" 2> /dev/null fi return 0 @@ -6744,10 +6751,10 @@ ExtractPrevSessFromTail() ExtractTailFromLog() { - if [[ -e $SESS_ARCHIVE_PATHFILE ]]; then - $TAIL_CMD -n${LOG_TAIL_LINES} "$SESS_ARCHIVE_PATHFILE" > "$SESS_TAIL_PATHFILE" # Trim main log first so there's less to `grep`. + if [[ -e $r_session_archive_pathfile ]]; then + $TAIL_CMD -n${r_log_tail_lines} "$r_session_archive_pathfile" > "$r_session_tail_pathfile" # Trim main log first so there's less to `grep`. else - rm -f "$SESS_TAIL_PATHFILE" 2> /dev/null + rm -f "$r_session_tail_pathfile" 2> /dev/null fi return 0 @@ -6759,8 +6766,8 @@ InitForkCounts() # Create directories so async processes can be monitored. - MakePath "$ACTION_FORKS_COUNT" 'action forks' - proc_counts_path=$($MKTEMP_CMD -d "$ACTION_FORKS_COUNT"/"${FUNCNAME[1]}"_XXXXXX) + MakePath "$r_action_forks_count" 'action forks' + proc_counts_path=$($MKTEMP_CMD -d "$r_action_forks_count"/"${FUNCNAME[1]}"_XXXXXX) [[ -n ${proc_counts_path:?undefined proc counts path} ]] || return EraseForkCountPaths @@ -6820,7 +6827,7 @@ EraseForkCountPaths() { ClearPath /var/run/sherpa/actions/forks "$proc_counts_path" - [[ -e $ACTION_ABORT_PATHFILE ]] && rm -f "$ACTION_ABORT_PATHFILE" + [[ -e $r_action_abort_pathfile ]] && rm -f "$r_action_abort_pathfile" } &> /dev/null @@ -6843,7 +6850,7 @@ UpdateForkProgress() local b='' RefreshForkCounts - [[ $useropt_verbose = false && ! -e $DISPLAY_INHIBIT_PATHFILE ]] || return # Don't display progress, it's difficult to read with so-many other writes to the screen. + [[ $useropt_verbose = false && ! -e $r_display_inhibit_pathfile ]] || return # Don't display progress, it's difficult to read with so-many other writes to the screen. a=$((skip_count+skip_ok_count+skip_error_count+skip_abort_count)) b=$(PercFrac "$ok_count" "$a" "$fail_count" "$total_count") @@ -6868,7 +6875,7 @@ UpdateForkProgress() b+="$(TextBrightYellow "$fork_count") in-progress" fi - [[ -n $b && ! -e $DISPLAY_INHIBIT_PATHFILE ]] && ShowAsProc "${fork_progress_prefix:-}" "$b" + [[ -n $b && ! -e $r_display_inhibit_pathfile ]] && ShowAsProc "${fork_progress_prefix:-}" "$b" return 0 @@ -6986,9 +6993,9 @@ CheckQPKGsConflicts() local a='' - if [[ -n ${BASE_QPKG_CONFLICTS_WITH:-} ]]; then + if [[ -n ${r_base_qpkg_conflicts_with:-} ]]; then # shellcheck disable=2068 - for a in "${BASE_QPKG_CONFLICTS_WITH[@]}"; do + for a in "${r_base_qpkg_conflicts_with[@]}"; do if QpkgIsInstalledEnabled "$a"; then ShowAsError "the '$a' QPKG is enabled. $(ShowAsTitleName) is incompatible with this package. Please consider stopping this QPKG in your App Center" run_package_actions=false @@ -7007,9 +7014,9 @@ CheckQPKGsWarnings() local a='' - if [[ -n ${BASE_QPKG_WARNINGS:-} ]]; then + if [[ -n ${r_base_qpkg_warnings:-} ]]; then # shellcheck disable=2068 - for a in "${BASE_QPKG_WARNINGS[@]}"; do + for a in "${r_base_qpkg_warnings[@]}"; do if QpkgIsInstalledEnabled "$a"; then ShowAsWarn "the '$a' QPKG is enabled. This may cause problems with $(ShowAsTitleName) applications. Please consider stopping this QPKG in your App Center" @@ -7033,7 +7040,7 @@ ListQPKGsActions() local b='' local border_shown=false - for a in "${QPKG_ACTIONS[@]}"; do + for a in "${r_qpkg_actions[@]}"; do for b in ok er sk so se sa; do if QPKGs-AC${a}-${b}.IsAny; then if [[ $border_shown = false ]]; then @@ -7072,7 +7079,7 @@ ListQPKGsActionsAll() #devdebug local b='' #devdebug DebugInfoMinSepr #devdebug - for a in "${QPKG_ACTIONS[@]}"; do #devdebug + for a in "${r_qpkg_actions[@]}"; do #devdebug for b in to ok er sk so se sa; do #devdebug if QPKGs-AC${a}-${b}.IsAny; then #devdebug DebugQpkg info "AC${a}-${b}" "($(QPKGs-AC${a}-${b}:Count)) $(QPKGs-AC${a}-${b}:ListCSV) " #devdebug @@ -7096,7 +7103,7 @@ ListIPKsActions() local a='' local border_shown=false - for a in "${IPK_ACTIONS[@]}"; do + for a in "${r_ipk_actions[@]}"; do if IPKs-AC${a}-ok.IsAny; then if [[ $border_shown = false ]]; then DebugInfoMinSepr @@ -7130,7 +7137,7 @@ ListPIPsActions() local a='' DebugInfoMinSepr - for a in "${PIP_ACTIONS[@]}"; do + for a in "${r_pip_actions[@]}"; do PIPs-AC${a}-ok.IsAny && DebugPipInfo "AC${a}-ok" "($(PIPs-AC${a}-ok:Count)) $(PIPs-AC${a}-ok:ListCSV) " PIPs-AC${a}-er.IsAny && DebugPipError "AC${a}-er" "($(PIPs-AC${a}-er:Count)) $(PIPs-AC${a}-er:ListCSV) " done @@ -7153,7 +7160,7 @@ ListQPKGsStates() BuildQPKGsStates DebugInfoMinSepr - for a in "${QPKG_IS_STATES[@]}" "${QPKG_SERVICE_RESULTS[@]}"; do + for a in "${r_qpkg_is_states[@]}" "${r_qpkg_service_results[@]}"; do [[ $a = installed ]] && continue if [[ $a = unknown ]]; then @@ -7163,7 +7170,7 @@ ListQPKGsStates() fi done - for a in "${QPKG_ISNT_STATES[@]}" "${QPKG_SERVICE_RESULTS[@]}"; do + for a in "${r_qpkg_isnt_states[@]}" "${r_qpkg_service_results[@]}"; do [[ $a = installed ]] && continue if [[ $a = ok ]]; then @@ -7175,7 +7182,7 @@ ListQPKGsStates() fi done - for a in "${QPKG_STATES_TRANSIENT[@]}"; do + for a in "${r_qpkg_states_transient[@]}"; do # shellcheck disable=2043 QPKGs-IS${a}.IsAny && DebugQpkg info "IS${a}" "($(QPKGs-IS${a}:Count)) $(QPKGs-IS${a}:ListCSV) " done @@ -7205,26 +7212,26 @@ BuildQPKGsTiers() local previous='' - if [[ ! -e $DEPENDENT_QPKGS_LIST_PATHFILE || ! -e $INDEPENDENT_QPKGS_LIST_PATHFILE ]]; then + if [[ ! -e $r_dependent_qpkgs_list_pathfile || ! -e $r_independent_qpkgs_list_pathfile ]]; then ShowAsProc tiers - rm -f "$DEPENDENT_QPKGS_LIST_PATHFILE" "$INDEPENDENT_QPKGS_LIST_PATHFILE" 2> /dev/null + rm -f "$r_dependent_qpkgs_list_pathfile" "$r_independent_qpkgs_list_pathfile" 2> /dev/null - for qpkg_name in "${QPKG_NAME[@]}"; do + for qpkg_name in "${r_qpkg_name[@]}"; do [[ $previous = "$qpkg_name" ]] && continue || previous=$qpkg_name QpkgSetIndex if QpkgIsDatabaseDependent; then - echo "$qpkg_name" >> "$DEPENDENT_QPKGS_LIST_PATHFILE" + echo "$qpkg_name" >> "$r_dependent_qpkgs_list_pathfile" else - echo "$qpkg_name" >> "$INDEPENDENT_QPKGS_LIST_PATHFILE" + echo "$qpkg_name" >> "$r_independent_qpkgs_list_pathfile" fi done qpkgs_tiers_built=true fi - [[ -e $DEPENDENT_QPKGS_LIST_PATHFILE ]] && QPKGs-GRdependent:Add "$(<$DEPENDENT_QPKGS_LIST_PATHFILE)" - [[ -e $INDEPENDENT_QPKGS_LIST_PATHFILE ]] && QPKGs-GRindependent:Add "$(<$INDEPENDENT_QPKGS_LIST_PATHFILE)" + [[ -e $r_dependent_qpkgs_list_pathfile ]] && QPKGs-GRdependent:Add "$(<$r_dependent_qpkgs_list_pathfile)" + [[ -e $r_independent_qpkgs_list_pathfile ]] && QPKGs-GRindependent:Add "$(<$r_independent_qpkgs_list_pathfile)" FuncExit @@ -7233,7 +7240,7 @@ BuildQPKGsTiers() InitQPKGsTiers() { - rm -f "$DEPENDENT_QPKGS_LIST_PATHFILE" "$INDEPENDENT_QPKGS_LIST_PATHFILE" 2> /dev/null + rm -f "$r_dependent_qpkgs_list_pathfile" "$r_independent_qpkgs_list_pathfile" 2> /dev/null qpkgs_tiers_built=false } @@ -7264,7 +7271,7 @@ BuildQPKGsStates() LoadPackages InitQPKGsStates - OsIsStarting && ShowAsWarn "$(OsGetQnapOS) is starting all enabled QPKGs $CHARS_ELLIPSIS check again in a few minutes" + OsIsStarting && ShowAsWarn "$(OsGetQnapOS) is starting all enabled QPKGs $r_chars_ellipsis check again in a few minutes" OsIsStopping && ShowAsWarn "$(OsGetQnapOS) is shutting-down and all QPKGs are stopping" if OsIsLoadAverageInsane; then @@ -7277,7 +7284,7 @@ BuildQPKGsStates() ShowAsProc 'QPKG states' - MakePath "$QPKG_STATES_PATH" states || return + MakePath "$r_qpkg_states_path" states || return # Faster to launch several concurrent loops async, than a single loop. Launch those requiring more processing-time first. @@ -7291,7 +7298,7 @@ BuildQPKGsStates() echo installable else echo notinstallable - fi >> "$QPKG_STATES_PATH/$qpkg_name" + fi >> "$r_qpkg_states_path/$qpkg_name" # done #& done & @@ -7303,7 +7310,7 @@ BuildQPKGsStates() echo missing else echo notmissing - fi >> "$QPKG_STATES_PATH/$qpkg_name" + fi >> "$r_qpkg_states_path/$qpkg_name" # done #& done & @@ -7315,7 +7322,7 @@ BuildQPKGsStates() echo upgradable else echo notupgradable - fi >> "$QPKG_STATES_PATH/$qpkg_name" + fi >> "$r_qpkg_states_path/$qpkg_name" # done #& done & @@ -7329,7 +7336,7 @@ BuildQPKGsStates() else echo notenabled fi - fi >> "$QPKG_STATES_PATH/$qpkg_name" + fi >> "$r_qpkg_states_path/$qpkg_name" # done #& done & @@ -7341,7 +7348,7 @@ BuildQPKGsStates() echo installed elif QpkgIsNtReallyInstalled; then echo notinstalled - fi >> "$QPKG_STATES_PATH/$qpkg_name" + fi >> "$r_qpkg_states_path/$qpkg_name" # done #& done & @@ -7355,7 +7362,7 @@ BuildQPKGsStates() echo backedup else echo notbackedup - fi >> "$QPKG_STATES_PATH/$qpkg_name" + fi >> "$r_qpkg_states_path/$qpkg_name" # done #& done & @@ -7389,7 +7396,7 @@ BuildQPKGsStates() esac fi - a=$QPKG_STATES_PATH/$qpkg_name + a=$r_qpkg_states_path/$qpkg_name [[ -e $a ]] || continue for b in $(<$a); do @@ -7464,17 +7471,17 @@ InitQPKGsStates() DebugAsProc 'initialising state lists' - for a in "${QPKG_IS_STATES[@]:-}" "${QPKG_STATES_TRANSIENT[@]:-}"; do + for a in "${r_qpkg_is_states[@]:-}" "${r_qpkg_states_transient[@]:-}"; do [[ $a = active ]] && continue # don't reset. QPKGs-IS${a}:Init done - for a in "${QPKG_ISNT_STATES[@]:-}"; do + for a in "${r_qpkg_isnt_states[@]:-}"; do [[ $a = active ]] && continue # don't reset. QPKGs-ISNT${a}:Init done - ClearPath /var/run/sherpa/packages "$QPKG_STATES_PATH" + ClearPath /var/run/sherpa/packages "$r_qpkg_states_path" DebugAsDone 'initialised state lists' qpkgs_states_built=false @@ -7562,7 +7569,7 @@ HelpAbbreviations() DisplayAsHelpTitle "$(ShowAsTitleName) can recognise various abbreviations and aliases as $(ShowAsPackages)." printf '\n' - } > "$REPORT_OUTPUT_PATHFILE" + } > "$r_report_output_pathfile" if OsIsSupportAutowidthTableColumns; then printf -v a '%s\n' 'QPKG name:|Installed?|Acceptable QPKG name abbreviations and aliases:' @@ -7573,7 +7580,7 @@ HelpAbbreviations() for qpkg_name in $(QPKGs-GRall:Array); do ((n++)) QpkgSetIndex - GenerateAbsReportDataLine > "$REPORTS_PATH/$n" & + GenerateAbsReportDataLine > "$r_reports_path/$n" & done m=$n @@ -7582,7 +7589,7 @@ HelpAbbreviations() # Load report lines from individual files. for ((n=1; n<=m; n++)); do - f="$REPORTS_PATH/$n" + f="$r_reports_path/$n" [[ -e $f ]] && printf -v a '%s\n' "$a$(<$f)" # Add newline to each imported report line. done @@ -7591,17 +7598,17 @@ HelpAbbreviations() printf '%s' "$a" | Tableise else printf '%s' "$a" - fi >> "$REPORT_OUTPUT_PATHFILE" + fi >> "$r_report_output_pathfile" -# GenerateReportFooter >> "$REPORT_OUTPUT_PATHFILE" +# GenerateReportFooter >> "$r_report_output_pathfile" fi - DisplayAsProjSynExam "example: to install $(ShowAsPackageName SABnzbd), $(ShowAsPackageName Mylar3) and $(ShowAsPackageName nzbToMedia) all-at-once" 'install sab my nzb2' >> "$REPORT_OUTPUT_PATHFILE" + DisplayAsProjSynExam "example: to install $(ShowAsPackageName SABnzbd), $(ShowAsPackageName Mylar3) and $(ShowAsPackageName nzbToMedia) all-at-once" 'install sab my nzb2' >> "$r_report_output_pathfile" EraseThisLine - if [[ -e $REPORT_OUTPUT_PATHFILE ]]; then - DisplayFileInViewport "$REPORT_OUTPUT_PATHFILE" + if [[ -e $r_report_output_pathfile ]]; then + DisplayFileInViewport "$r_report_output_pathfile" else ShowAsError 'no information to display' fi @@ -7635,24 +7642,24 @@ ShowReportBackups() while read -r epoch_time file_name file_bytes; do [[ -z $epoch_time || -z $file_name ]] && break DisplayAsBacksReportItemLine "$epoch_time" "$file_name" "$file_bytes" "$highlight_backups_older_than" - done <<< "$($GNU_FIND_CMD "$QPKG_BU_PATH"/*.config.tar.gz -maxdepth 1 -printf '%C@ %f %s\n' 2> /dev/null | $SORT_CMD)" + done <<< "$($GNU_FIND_CMD "$r_qpkg_bu_path"/*.config.tar.gz -maxdepth 1 -printf '%C@ %f %s\n' 2> /dev/null | $SORT_CMD)" else # If GNU `find` isn't available, do-it the hard-way. while read -r file_date file_time file_name file_bytes; do [[ -z $file_date || -z $file_name ]] && break epoch_time=$(/bin/date -d "$file_date $file_time" +"%s") file_name=$($BASENAME_CMD "$file_name") DisplayAsBacksReportItemLine "$epoch_time" "$file_name" "$file_bytes" "$highlight_backups_older_than" - done <<< "$(cd "$QPKG_BU_PATH" && ls -l1tr --time-style=+"%Y-%m-%d %H:%M:%S" ./*.config.tar.gz 2> /dev/null | $AWK_CMD '{print $6" "$7" "$8" "$5}')" + done <<< "$(cd "$r_qpkg_bu_path" && ls -l1tr --time-style=+"%Y-%m-%d %H:%M:%S" ./*.config.tar.gz 2> /dev/null | $AWK_CMD '{print $6" "$7" "$8" "$5}')" fi GenerateReportFooter - } > "$REPORT_OUTPUT_PATHFILE" + } > "$r_report_output_pathfile" EraseThisLine - if [[ -e $REPORT_OUTPUT_PATHFILE ]]; then - DisplayFileInViewport "$REPORT_OUTPUT_PATHFILE" + if [[ -e $r_report_output_pathfile ]]; then + DisplayFileInViewport "$r_report_output_pathfile" else ShowAsError 'no information to display' fi @@ -7683,7 +7690,7 @@ ShowReportDependencies() for qpkg_name in $(QPKGs-GRall:Array); do ((n++)) QpkgSetIndex - GenerateDepsReportDataLine > "$REPORTS_PATH/$n" & + GenerateDepsReportDataLine > "$r_reports_path/$n" & done m=$n @@ -7692,7 +7699,7 @@ ShowReportDependencies() # Load report lines from individual files. for ((n=1; n<=m; n++)); do - f="$REPORTS_PATH/$n" + f="$r_reports_path/$n" [[ -e $f ]] && printf -v a '%s\n' "$a$(<$f)" # Add newline to each imported report line. done @@ -7701,16 +7708,16 @@ ShowReportDependencies() printf '%s' "$a" | Tableise else printf '%s' "$a" - fi > "$REPORT_OUTPUT_PATHFILE" + fi > "$r_report_output_pathfile" - GenerateReportFooter >> "$REPORT_OUTPUT_PATHFILE" + GenerateReportFooter >> "$r_report_output_pathfile" fi EraseThisLine - if [[ -e $REPORT_OUTPUT_PATHFILE ]]; then + if [[ -e $r_report_output_pathfile ]]; then echo - DisplayFileInViewport "$REPORT_OUTPUT_PATHFILE" + DisplayFileInViewport "$r_report_output_pathfile" else ShowAsError 'no information to display' fi @@ -7743,7 +7750,7 @@ ShowReportFeatures() for qpkg_name in $(QPKGs-GRall:Array); do ((n++)) QpkgSetIndex - GenerateFeaturesReportDataLine > "$REPORTS_PATH/$n" & + GenerateFeaturesReportDataLine > "$r_reports_path/$n" & done m=$n @@ -7752,7 +7759,7 @@ ShowReportFeatures() # Load report lines from individual files. for ((n=1; n<=m; n++)); do - f="$REPORTS_PATH/$n" + f="$r_reports_path/$n" [[ -e $f ]] && printf -v a '%s\n' "$a$(<$f)" # Add newline to each imported report line. done @@ -7761,16 +7768,16 @@ ShowReportFeatures() printf '%s' "$a" | Tableise else printf '%s' "$a" - fi > "$REPORT_OUTPUT_PATHFILE" + fi > "$r_report_output_pathfile" - GenerateReportHeadingsFooter >> "$REPORT_OUTPUT_PATHFILE" + GenerateReportHeadingsFooter >> "$r_report_output_pathfile" fi EraseThisLine - if [[ -e $REPORT_OUTPUT_PATHFILE ]]; then + if [[ -e $r_report_output_pathfile ]]; then echo - DisplayFileInViewport "$REPORT_OUTPUT_PATHFILE" + DisplayFileInViewport "$r_report_output_pathfile" else ShowAsError 'no information to display' fi @@ -7799,7 +7806,7 @@ ShowReportPackages() DisplayAsHelpTitle "one-or-more $(ShowAsPackages) may be specified at-once." printf '\n' - } > "$REPORT_OUTPUT_PATHFILE" + } > "$r_report_output_pathfile" if OsIsSupportAutowidthTableColumns; then printf -v a '%s\n' 'QPKG name:|Appl. version:|Description:' @@ -7810,7 +7817,7 @@ ShowReportPackages() for qpkg_name in $(QPKGs-GRall:Array); do ((n++)) QpkgSetIndex - GeneratePacksReportDataLine "$qpkg_name" > "$REPORTS_PATH/$n" & + GeneratePacksReportDataLine "$qpkg_name" > "$r_reports_path/$n" & done m=$n @@ -7818,7 +7825,7 @@ ShowReportPackages() # Load report data lines from individual files. for ((n=1; n<=m; n++)); do - f="$REPORTS_PATH/$n" + f="$r_reports_path/$n" [[ -e $f ]] && printf -v a '%s\n' "$a$(<$f)" # Add newline to each imported report line. done @@ -7827,9 +7834,9 @@ ShowReportPackages() printf '%s' "$a" | Tableise else printf '%s' "$a" - fi >> "$REPORT_OUTPUT_PATHFILE" + fi >> "$r_report_output_pathfile" - GenerateReportFooter >> "$REPORT_OUTPUT_PATHFILE" + GenerateReportFooter >> "$r_report_output_pathfile" fi { @@ -7837,13 +7844,13 @@ ShowReportPackages() DisplayAsProjSynExam "abbreviations and aliases may also be used to specify $(ShowAsPackages). To list these" 'help abs' DisplayAsProjSynIndentExam '' a - } >> "$REPORT_OUTPUT_PATHFILE" + } >> "$r_report_output_pathfile" EraseThisLine - if [[ -e $REPORT_OUTPUT_PATHFILE ]]; then + if [[ -e $r_report_output_pathfile ]]; then echo - DisplayFileInViewport "$REPORT_OUTPUT_PATHFILE" + DisplayFileInViewport "$r_report_output_pathfile" else ShowAsError 'no information to display' fi @@ -7874,7 +7881,7 @@ ShowReportRepos() for qpkg_name in $(QPKGs-GRall:Array); do ((n++)) QpkgSetIndex - GenerateReposReportDataLine > "$REPORTS_PATH/$n" & + GenerateReposReportDataLine > "$r_reports_path/$n" & done m=$n @@ -7883,7 +7890,7 @@ ShowReportRepos() # Load report data lines from individual files. for ((n=1; n<=m; n++)); do - f="$REPORTS_PATH/$n" + f="$r_reports_path/$n" [[ -e $f ]] && printf -v a '%s\n' "$a$(<$f)" # Add newline to each imported report line. done @@ -7892,16 +7899,16 @@ ShowReportRepos() printf '%s' "$a" | Tableise else printf '%s' "$a" - fi > "$REPORT_OUTPUT_PATHFILE" + fi > "$r_report_output_pathfile" - GenerateReportFooter >> "$REPORT_OUTPUT_PATHFILE" + GenerateReportFooter >> "$r_report_output_pathfile" fi EraseThisLine - if [[ -e $REPORT_OUTPUT_PATHFILE ]]; then + if [[ -e $r_report_output_pathfile ]]; then echo - DisplayFileInViewport "$REPORT_OUTPUT_PATHFILE" + DisplayFileInViewport "$r_report_output_pathfile" else ShowAsError 'no information to display' fi @@ -7933,7 +7940,7 @@ ShowReportStatuses() ((n++)) QpkgSetIndex QPKGs-ISupgradable.Exist "$qpkg_name" && a=true - GenerateStatusReportDataLine > "$REPORTS_PATH/$n" & + GenerateStatusReportDataLine > "$r_reports_path/$n" & done if OsIsSupportAutowidthTableColumns; then @@ -7949,7 +7956,7 @@ ShowReportStatuses() # Load report lines from individual files. for ((n=1; n<=m; n++)); do - f="$REPORTS_PATH/$n" + f="$r_reports_path/$n" # shellcheck disable=2179 [[ -e $f ]] && printf -v c '%s\n' "$c$(<$f)" # Add newline to each imported report line. done @@ -7959,16 +7966,16 @@ ShowReportStatuses() printf '%s' "$c" | Tableise else printf '%s' "$c" - fi > "$REPORT_OUTPUT_PATHFILE" + fi > "$r_report_output_pathfile" - GenerateReportFooter >> "$REPORT_OUTPUT_PATHFILE" + GenerateReportFooter >> "$r_report_output_pathfile" fi EraseThisLine - if [[ -e $REPORT_OUTPUT_PATHFILE ]]; then + if [[ -e $r_report_output_pathfile ]]; then echo - DisplayFileInViewport "$REPORT_OUTPUT_PATHFILE" + DisplayFileInViewport "$r_report_output_pathfile" else ShowAsError 'no information to display' fi @@ -7989,11 +7996,11 @@ ShowReportVersions() DisableDebugToArchiveAndFile EraseThisLine - Display "QPKG: ${THIS_PACKAGE_VER:-undefined}" - Display "manager: ${THIS_SCRIPT_VER:-undefined}" - Display "loader: ${LOADER_SCRIPT_VER:-undefined}" - Display "objects: ${OBJECTS_VER:-undefined}" - Display "packages: ${PACKAGES_EPOCH}$([[ $PACKAGES_EPOCH != undefined ]] && printf '%s' " ($(ConvertSecondsToFullDate "$PACKAGES_EPOCH"))")" + Display "QPKG: ${r_this_package_ver:-undefined}" + Display "manager: ${r_this_script_ver:-undefined}" + Display "loader: ${LOADER_SCRIPT_VERSION:-undefined}" + Display "objects: ${r_objects_version:-undefined}" + Display "packages: ${r_packages_epoch}$([[ $r_packages_epoch != undefined ]] && printf '%s' " ($(ConvertSecondsToFullDate "$r_packages_epoch"))")" return 0 @@ -8022,7 +8029,7 @@ ShowReportAllActionResults() show_action_results_skipped=true fi - if [[ -e $SESS_ACTION_RESULTS_PATHFILE ]]; then + if [[ -e $r_session_action_results_pathfile ]]; then while IFS='|' read -r datetime action quantity package_name package_type result duration reason; do if [[ $datetime -gt 0 && $duration -gt 0 ]]; then [[ $a -eq 0 ]] && a=$datetime # Only use first entry as start time. @@ -8030,7 +8037,7 @@ ShowReportAllActionResults() c=$duration ((d++)) fi - done < "$SESS_ACTION_RESULTS_PATHFILE" + done < "$r_session_action_results_pathfile" a=$(ConvertMillisecondsToSeconds "$a") b=$(ConvertMillisecondsToSeconds "$b") @@ -8048,10 +8055,10 @@ ShowReportAllActionResults() [[ $show_action_results_failed = true ]] && ShowReportActionResults failed [[ $show_action_results_zero = true ]] && ShowZeroQpkgs - } > "$REPORT_OUTPUT_PATHFILE" + } > "$r_report_output_pathfile" - if [[ -e $REPORT_OUTPUT_PATHFILE ]]; then - DisplayFileInViewport "$REPORT_OUTPUT_PATHFILE" + if [[ -e $r_report_output_pathfile ]]; then + DisplayFileInViewport "$r_report_output_pathfile" else ShowAsError 'no information to display' fi @@ -8076,7 +8083,7 @@ ShowReportActionResults() local reason='' local result='' - if [[ -e $SESS_ACTION_RESULTS_PATHFILE ]]; then + if [[ -e $r_session_action_results_pathfile ]]; then # Obtain count of same results. Need to know if action applied to one QPKG or many. while IFS='|' read -r datetime action quantity package_name package_type result duration reason; do @@ -8085,7 +8092,7 @@ ShowReportActionResults() ((count++)) [[ $count -gt 1 ]] && break # Two-or-more of the same action means must pluralise messages. fi - done < "$SESS_ACTION_RESULTS_PATHFILE" + done < "$r_session_action_results_pathfile" # Display action titles and QPKGs. @@ -8119,7 +8126,7 @@ ShowReportActionResults() [[ $action = status && $useropt_show_all_results = false ]] && continue # Don't need to see the result of `status` checks unless a 'results' report has been requested. ShowAsActionLogDetail "$datetime" "$package_name" "$action" "$result" "$duration" "$reason" "$package_type" "$quantity" fi - done < "$SESS_ACTION_RESULTS_PATHFILE" + done < "$r_session_action_results_pathfile" fi fi @@ -8150,111 +8157,111 @@ GenerateReportFooter() local a='' a=$({ - if [[ -e "$REPORT_FLAGS_PATH"/status-missing ]]; then + if [[ -e "$r_report_flags_path"/status-missing ]]; then DisplayAsIndentQuotedInfoItem "$(TextBrightRed missing)" 'QPKG is missing from its installation path. Please reinstall it' fi - if [[ -e "$REPORT_FLAGS_PATH"/req-alert ]]; then + if [[ -e "$r_report_flags_path"/req-alert ]]; then DisplayAsIndentQuotedInfoItem "$(TextBrightRed '!')" 'QPKG is prevented from working correctly' fi - if [[ -e "$REPORT_FLAGS_PATH"/state-disabled ]]; then + if [[ -e "$r_report_flags_path"/state-disabled ]]; then DisplayAsIndentQuotedInfoItem "$(TextBrightRed disabled)" "QPKG won't start at bootup. Enable it first, then start it" fi - if [[ -e "$REPORT_FLAGS_PATH"/result-aborted ]]; then + if [[ -e "$r_report_flags_path"/result-aborted ]]; then DisplayAsIndentQuotedInfoItem "($(TextBrightRed aborted))" 'previous action was aborted' fi - if [[ -e "$REPORT_FLAGS_PATH"/result-failed ]]; then + if [[ -e "$r_report_flags_path"/result-failed ]]; then DisplayAsIndentQuotedInfoItem "($(TextBrightRed failed))" 'previous action failed' fi - if [[ -e "$REPORT_FLAGS_PATH"/status-inactive ]]; then + if [[ -e "$r_report_flags_path"/status-inactive ]]; then DisplayAsIndentQuotedInfoItem "$(TextBrightRed inactive)" 'application process is dead or not-started. Try starting it' fi - if [[ -e "$REPORT_FLAGS_PATH"/backup-file-old ]]; then + if [[ -e "$r_report_flags_path"/backup-file-old ]]; then DisplayAsIndentQuotedInfoItem "$(TextBrightRed '!')" "QPKG backup file was updated more-than $highlight_backups_older_than." fi - if [[ -e "$REPORT_FLAGS_PATH"/status-upgradable ]]; then + if [[ -e "$r_report_flags_path"/status-upgradable ]]; then DisplayAsIndentQuotedInfoItem "($(TextBrightOrange new))" 'an upgraded QPKG version is available' fi - if [[ -e "$REPORT_FLAGS_PATH"/status-wrongauthor ]]; then + if [[ -e "$r_report_flags_path"/status-wrongauthor ]]; then DisplayAsIndentQuotedInfoItem "$(TextBrightOrange 'incompatible author')" "QPKG is a non-compatible, identically-named duplicate of a $(ShowAsTitleName) QPKG" fi - if [[ -e "$REPORT_FLAGS_PATH"/req-attention ]]; then + if [[ -e "$r_report_flags_path"/req-attention ]]; then DisplayAsIndentQuotedInfoItem "$(TextBrightOrange '*')" "QPKG cannot be managed with $(ShowAsTitleName)" fi - if [[ -e "$REPORT_FLAGS_PATH"/action-pending ]]; then + if [[ -e "$r_report_flags_path"/action-pending ]]; then DisplayAsIndentQuotedInfoItem "$(TextBrightOrange pending)" 'QPKG is waiting to run an action. Check again shortly' fi - if [[ -e "$REPORT_FLAGS_PATH"/status-stopping ]]; then + if [[ -e "$r_report_flags_path"/status-stopping ]]; then DisplayAsIndentQuotedInfoItem "$(TextBrightOrange stopping)" 'QPKG is stopping. Check again shortly' fi - if [[ -e "$REPORT_FLAGS_PATH"/status-slow ]]; then + if [[ -e "$r_report_flags_path"/status-slow ]]; then DisplayAsIndentQuotedInfoItem "$(TextBrightOrange slow)" 'application is alive, but was slow to respond to the status request. Check again shortly' # More common on NAS with lower installed RAM, and usually because the application has been page-swapped to disk and must be reloaded into RAM. fi - if [[ -e "$REPORT_FLAGS_PATH"/status-starting ]]; then + if [[ -e "$r_report_flags_path"/status-starting ]]; then DisplayAsIndentQuotedInfoItem "$(TextBrightOrange starting)" 'QPKG is starting. Check again shortly' fi - if [[ -e "$REPORT_FLAGS_PATH"/result-in-progress ]]; then + if [[ -e "$r_report_flags_path"/result-in-progress ]]; then DisplayAsIndentQuotedInfoItem "($(TextBrightOrange in-progress))" 'an action is in-progress. Check again shortly' fi - if [[ -e "$REPORT_FLAGS_PATH"/status-unknown ]]; then + if [[ -e "$r_report_flags_path"/status-unknown ]]; then DisplayAsIndentQuotedInfoItem "$(TextBrightOrange unknown)" 'application status could not be determined' fi - if [[ -e "$REPORT_FLAGS_PATH"/repo-other ]]; then + if [[ -e "$r_report_flags_path"/repo-other ]]; then DisplayAsIndentQuotedInfoItem "$(TextBrightOrange '* URL')" 'another repository is managing this QPKG' fi - if [[ -e "$REPORT_FLAGS_PATH"/state-enabled ]]; then + if [[ -e "$r_report_flags_path"/state-enabled ]]; then DisplayAsIndentQuotedInfoItem "$(TextBrightGreen enabled)" 'QPKG will be started at bootup' fi - if [[ -e "$REPORT_FLAGS_PATH"/result-ok ]]; then + if [[ -e "$r_report_flags_path"/result-ok ]]; then DisplayAsIndentQuotedInfoItem "($(TextBrightGreen OK))" 'previous action was successful' fi - if [[ -e "$REPORT_FLAGS_PATH"/status-active ]]; then + if [[ -e "$r_report_flags_path"/status-active ]]; then DisplayAsIndentQuotedInfoItem "$(TextBrightGreen active)" 'application is alive (and responsive if a daemon)' fi - if [[ -e "$REPORT_FLAGS_PATH"/repo-sherpa ]]; then + if [[ -e "$r_report_flags_path"/repo-sherpa ]]; then DisplayAsIndentQuotedInfoItem "$(TextBrightGreen sherpa)" "$(ShowAsTitleName) is managing this QPKG" fi - if [[ -e "$REPORT_FLAGS_PATH"/app-dynamic ]]; then + if [[ -e "$r_report_flags_path"/app-dynamic ]]; then DisplayAsIndentQuotedInfoItem dynamic 'application version is the latest available' fi - if [[ -e "$REPORT_FLAGS_PATH"/app-static ]]; then + if [[ -e "$r_report_flags_path"/app-static ]]; then DisplayAsIndentQuotedInfoItem static 'application version auto-update is disabled or unsupported' fi - if [[ -e "$REPORT_FLAGS_PATH"/app-final ]]; then + if [[ -e "$r_report_flags_path"/app-final ]]; then DisplayAsIndentQuotedInfoItem final 'application version is the last available' fi - if [[ -e "$REPORT_FLAGS_PATH"/na ]]; then + if [[ -e "$r_report_flags_path"/na ]]; then DisplayAsIndentQuotedInfoItem N/A 'not applicable' fi - if [[ -e "$REPORT_FLAGS_PATH"/action-not-found ]]; then + if [[ -e "$r_report_flags_path"/action-not-found ]]; then DisplayAsIndentQuotedInfoItem "$(TextDarkGrey not-found)" 'action tracking files were not found' fi - if [[ -e "$REPORT_FLAGS_PATH"/action-unsupported ]]; then + if [[ -e "$r_report_flags_path"/action-unsupported ]]; then DisplayAsIndentQuotedInfoItem "$(TextDarkGrey unsupported)" 'action tracking is unsupported by this QPKG' fi }) @@ -8267,16 +8274,16 @@ GenerateReportFooter() fi fi - if [[ -e "$REPORT_FLAGS_PATH"/deps ]]; then + if [[ -e "$r_report_flags_path"/deps ]]; then DisplayAsHelpTitle "QPKG dependencies are automatically installed/started/stopped/restarted as-required by $(ShowAsTitleName)." fi - if compgen -G "${REPORT_FLAGS_PATH}/backup-file-*" > /dev/null; then # https://stackoverflow.com/a/6364244 + if compgen -G "${r_report_flags_path}/backup-file-*" > /dev/null; then # https://stackoverflow.com/a/6364244 DisplayAsIndentItem "backups are listed oldest-first." fi - if compgen -G "${REPORT_FLAGS_PATH}/backup-file-*" > /dev/null; then # https://stackoverflow.com/a/6364244 - DisplayAsIndentItem "all $(ShowAsTitleName) backup files are stored here: $QPKG_BU_PATH" + if compgen -G "${r_report_flags_path}/backup-file-*" > /dev/null; then # https://stackoverflow.com/a/6364244 + DisplayAsIndentItem "all $(ShowAsTitleName) backup files are stored here: $r_qpkg_bu_path" fi } @@ -8895,7 +8902,7 @@ Python3IsOutdated() [[ -e $PYTHON3_CMD ]] || return installed_ver=$(Python3GetVer "$PYTHON3_CMD") - [[ $NAS_ARCH = armv5tel && ${installed_ver//./} -lt 3114 ]] || [[ $NAS_ARCH != armv5tel && ${installed_ver//./} -lt $MIN_PYTHON_VER ]] + [[ $r_nas_arch = armv5tel && ${installed_ver//./} -lt 3114 ]] || [[ $r_nas_arch != armv5tel && ${installed_ver//./} -lt $r_min_python_version ]] } @@ -8924,7 +8931,7 @@ PerlIsOutdated() [[ -e $PERL_CMD ]] || return installed_ver=$(PerlGetVer "$PERL_CMD") - [[ $NAS_ARCH = armv5tel && ${installed_ver//./} -lt 5281 ]] || [[ $NAS_ARCH != armv5tel && ${installed_ver//./} -lt $MIN_PERL_VER ]] + [[ $r_nas_arch = armv5tel && ${installed_ver//./} -lt 5281 ]] || [[ $r_nas_arch != armv5tel && ${installed_ver//./} -lt $r_min_perl_version ]] } @@ -9061,9 +9068,9 @@ QpkgGetArch() return fi - case $NAS_ARCH in + case $r_nas_arch in x86_64) - [[ ${NAS_FIRMWARE_VER//.} -ge 430 ]] && printf i64 || printf i86 + [[ ${r_nas_firmware_version//.} -ge 430 ]] && printf i64 || printf i86 ;; i686|x86) printf i86 @@ -9072,7 +9079,7 @@ QpkgGetArch() printf a19 ;; armv7l) - case $NAS_PLATFORM in + case $r_nas_platform in ARM_MS) printf a31 ;; @@ -9165,7 +9172,7 @@ OsIsSupported() # Unable to test firmwares any earlier than 4.2.6 (but still have 4.2.0 available for TS-559Pro+): - [[ ${NAS_FIRMWARE_VER//.} -ge 400 ]] + [[ ${r_nas_firmware_version//.} -ge 400 ]] } @@ -9181,25 +9188,25 @@ OsIsSupportSecureDownload() # works in: # QTS 4.5.4.2627 - [[ ${NAS_FIRMWARE_VER//.} -ge 500 ]] + [[ ${r_nas_firmware_version//.} -ge 500 ]] } OsIsSupportQpkgTimeout() { - [[ ${NAS_FIRMWARE_VER//.} -ge 430 ]] + [[ ${r_nas_firmware_version//.} -ge 430 ]] } OsIsSupportSignedPackages() { -# [[ ${NAS_FIRMWARE_VER//.} -ge 435 ]] +# [[ ${r_nas_firmware_version//.} -ge 435 ]] # NOTE: signing failed on QTS 4.3.6 (x31). No cert database. So, let's go one-version-higher: - [[ ${NAS_FIRMWARE_VER//.} -ge 440 ]] + [[ ${r_nas_firmware_version//.} -ge 440 ]] } @@ -9208,7 +9215,7 @@ OsIsCompatibleWithSigned() # QTS builds released over these 6 days don't allow unsigned QPKGs to run at-all: - [[ $NAS_FIRMWARE_DATE -lt 20201015 || $NAS_FIRMWARE_DATE -gt 20201020 ]] + [[ $r_nas_firmware_date -lt 20201015 || $r_nas_firmware_date -gt 20201020 ]] } @@ -9217,7 +9224,7 @@ OsIsSupportUnofficialPackages() # Must check for "official QPKGs" on QTS 4.3.3 to QTS 4.3.6: - [[ ${NAS_FIRMWARE_VER//.} -gt 426 && ${NAS_FIRMWARE_VER//.} -le 436 ]] + [[ ${r_nas_firmware_version//.} -gt 426 && ${r_nas_firmware_version//.} -le 436 ]] } @@ -9287,7 +9294,7 @@ OsIsStdKernelPageSize() # Standard kernel page size for most QNAP NAS is 4kiB. Non-standard size is 32kiB (confirmed on the TS-431XeU, TS-431X3 & TS-1635). # https://www.qnap.com/en-us/how-to/faq/article/why-do-the-installed-third-party-containers-not-run-successfully-on-specific-32-bit-arm-devices - [[ ${KERNEL_PAGE_SIZE:=$(OsGetKernelPageSize)} = 4096 || $KERNEL_PAGE_SIZE = 4kB ]] + [[ ${r_kernel_page_size:=$(OsGetKernelPageSize)} = 4096 || $r_kernel_page_size = 4kB ]] } @@ -9302,7 +9309,7 @@ OsIsLoadAverageElevated() { local a=$(OsGetSysLoad1MinAverage); a=${a/./} - local b=$((CPU_CORES*2*100)) + local b=$((r_cpu_cores*2*100)) [[ $((10#$a)) -ge $((10#$b)) ]] @@ -9312,7 +9319,7 @@ OsIsLoadAverageHigh() { local a=$(OsGetSysLoad1MinAverage); a=${a/./} - local b=$((CPU_CORES*4*100)) + local b=$((r_cpu_cores*4*100)) [[ $((10#$a)) -ge $((10#$b)) ]] @@ -9322,7 +9329,7 @@ OsIsLoadAverageInsane() { local a=$(OsGetSysLoad1MinAverage); a=${a/./} - local b=$((CPU_CORES*8*100)) + local b=$((r_cpu_cores*8*100)) [[ $((10#$a)) -ge $((10#$b)) ]] @@ -9360,8 +9367,8 @@ ShowZeroQpkgs() local a='' local b='' - for a in "${QPKG_IS_STATES[@]:-}"; do - for b in "${USER_QPKG_ACTIONS[@]:-}"; do + for a in "${r_qpkg_is_states[@]:-}"; do + for b in "${r_user_qpkg_actions[@]:-}"; do [[ $b = list ]] && continue # Action results lists are unavailable for these. QPKGs.AC${b}.IS${a}.IsSet && QPKGs-AC${b}-ok.IsNone && ShowAsWarn "no QPKGs were able to $(Lowercase "$b")" done @@ -9375,17 +9382,17 @@ ClaimLockfile() { local a='' - readonly LOCK_PATHFILE=/var/run/sherpa.lock # global + readonly r_lock_pathfile=/var/run/sherpa.lock # global for a in sherpa-manager.sh sherpa-manager.source; do - if [[ -e $LOCK_PATHFILE && -d /proc/$(<"$LOCK_PATHFILE") && $(< /proc/"$(<"$LOCK_PATHFILE")"/cmdline) =~ $a ]]; then - ShowAsAbort "another sherpa instance was found (PID:$(<"$LOCK_PATHFILE")), can't continue" + if [[ -e $r_lock_pathfile && -d /proc/$(<"$r_lock_pathfile") && $(< /proc/"$(<"$r_lock_pathfile")"/cmdline) =~ $a ]]; then + ShowAsAbort "another sherpa instance was found (PID:$(<"$r_lock_pathfile")), can't continue" return 1 fi done - echo "$$" > "$LOCK_PATHFILE" + echo "$$" > "$r_lock_pathfile" return 0 @@ -9394,7 +9401,7 @@ ClaimLockfile() ReleaseLockfile() { - [[ -n ${LOCK_PATHFILE:-} ]] && rm -f "$LOCK_PATHFILE" 2> /dev/null + [[ -n ${r_lock_pathfile:-} ]] && rm -f "$r_lock_pathfile" 2> /dev/null } @@ -9446,19 +9453,18 @@ SaveActionResultToLog() # Calculate duration here. - local -r VAR_NAME=${FUNCNAME[1]}_STARTNANOSECONDS - local var_safe_name=${VAR_NAME//[.-]/_} - var_safe_name=${var_safe_name//:/_} - local -r PACKAGE_TYPE=${1:?${FUNCNAME[0]}'()': undefined package type} - local -r qpkg_name=${2:?${FUNCNAME[0]}'()': undefined package name} - local -r ACTION=${3:?${FUNCNAME[0]}'()': undefined action} - local -r QTY=${4:-1} - local -r CLEAN_ACTION=${ACTION//\"/} - local -r RESULT=${5:?${FUNCNAME[0]}'()': undefined result} - local -r REASON=${6:-} - local -r STARTTIME=$(ConvertNanosecondsToMilliseconds "${!var_safe_name}") - local -r DURATION=$(CalcAmountDiff "$STARTTIME" "$(ConvertNowToMilliseconds)") - local -r ACTION_TIMES_PATHFILE=$ACTION_TIMES_PATH/$CLEAN_ACTION.milliseconds + local -r r_var_name=${FUNCNAME[1]}_STARTNANOSECONDS + local var_safe_name=${r_var_name//[.-]/_}; var_safe_name=${var_safe_name//:/_} + local -r r_package_type=${1:?${FUNCNAME[0]}'()': undefined package type} + local -r r_name=${2:?${FUNCNAME[0]}'()': undefined package name} + local -r r_action=${3:?${FUNCNAME[0]}'()': undefined action} + local -r r_qty=${4:-1} + local -r r_clean_action=${r_action//\"/} + local -r r_result=${5:?${FUNCNAME[0]}'()': undefined result} + local -r r_reason=${6:-} + local -r r_starttime=$(ConvertNanosecondsToMilliseconds "${!var_safe_name}") + local -r r_duration=$(CalcAmountDiff "$r_starttime" "$(ConvertNowToMilliseconds)") + local -r r_action_times_pathfile=$r_action_times_path/$r_clean_action.milliseconds if [[ $2 = undefined ]]; then ShowAsError "${FUNCNAME[0]}() was provided an undefined value for \$2" @@ -9467,26 +9473,26 @@ SaveActionResultToLog() fi # Add new action results entry. - echo "$STARTTIME|$ACTION|$QTY|$qpkg_name|$PACKAGE_TYPE|$RESULT|$DURATION|$REASON" >> "$SESS_ACTION_RESULTS_PATHFILE" + echo "$r_starttime|$r_action|$r_qty|$r_name|$r_package_type|$r_result|$r_duration|$r_reason" >> "$r_session_action_results_pathfile" # Remove previous action duration entry if one exists. - if [[ -e $ACTION_TIMES_PATHFILE ]] && $GREP_CMD -q "^$qpkg_name|" < "$ACTION_TIMES_PATHFILE"; then - $SED_CMD -i "/^$qpkg_name|/d" "$ACTION_TIMES_PATHFILE" + if [[ -e $r_action_times_pathfile ]] && $GREP_CMD -q "^$r_name|" < "$r_action_times_pathfile"; then + $SED_CMD -i "/^$r_name|/d" "$r_action_times_pathfile" fi # Add new action duration entry. - echo "$qpkg_name|$DURATION" >> "$ACTION_TIMES_PATHFILE" + echo "$r_name|$r_duration" >> "$r_action_times_pathfile" case $4 in ok|skipped-ok) - DebugAsInfo "$REASON" + DebugAsInfo "$r_reason" ;; skipped) - DebugAsWarn "$REASON" + DebugAsWarn "$r_reason" ;; failed|skipped-@(error|abort)) - DebugAsError "$REASON" + DebugAsError "$r_reason" esac return 0 @@ -9507,9 +9513,9 @@ _QPKG:reassign_() # Remove the `storeid` assignment for the QPKG named in $qpkg_name. # Inputs: (global) - # $LOGS_PATH + # $r_logs_path # $qpkg_name - # $REASSIGN_LOG_FILE + # $r_reassign_log_file # $useropt_verbose # Outputs: (local) @@ -9538,7 +9544,7 @@ _QPKG:reassign_() [[ $z -eq 0 ]] || FuncForkExit $z DebugAsProc "reassigning $(ShowAsPackageName)" - RunAndLog "/sbin/setcfg -e $qpkg_name store -f /etc/config/qpkg.conf" "$LOGS_PATH/$qpkg_name.$REASSIGN_LOG_FILE" log:failure-only + RunAndLog "/sbin/setcfg -e $qpkg_name store -f /etc/config/qpkg.conf" "$r_logs_path/$qpkg_name.$r_reassign_log_file" log:failure-only z=$? if [[ $z -eq 0 ]]; then @@ -9561,11 +9567,11 @@ _QPKG:download_() # Download the QPKG named in $qpkg_name. # Inputs: (global) - # $DOWNLOAD_LOG_FILE - # $LOGS_PATH - # $QPKG_DL_PATH + # $r_download_log_file + # $r_logs_path + # $r_qpkg_download_path # $qpkg_name - # $REMOTE_FILENAME + # $r_remote_filename # $useropt_verbose # Outputs: (local) @@ -9575,47 +9581,47 @@ _QPKG:download_() FuncForkInit - local -r REMOTE_HASH=$(QpkgGetDatabaseHash) - local -r REMOTE_URL=$(QpkgGetDatabaseURL) - local -r REMOTE_FILENAME=$($BASENAME_CMD "$REMOTE_URL") - local -r LOCAL_PATHFILE=$QPKG_DL_PATH/$REMOTE_FILENAME - local -r LOCAL_FILENAME=$($BASENAME_CMD "$LOCAL_PATHFILE") - local -r LOG_PATHFILE=$LOGS_PATH/$LOCAL_FILENAME.$DOWNLOAD_LOG_FILE + local -r r_remote_hash=$(QpkgGetDatabaseHash) + local -r r_remote_url=$(QpkgGetDatabaseURL) + local -r r_remote_filename=$($BASENAME_CMD "$r_remote_url") + local -r r_local_pathfile=$r_qpkg_download_path/$r_remote_filename + local -r r_local_filename=$($BASENAME_CMD "$r_local_pathfile") + local -r r_log_pathfile=$r_logs_path/$r_local_filename.$r_download_log_file local -i z=0 - if [[ -z $REMOTE_URL || -z $REMOTE_HASH ]]; then + if [[ -z $r_remote_url || -z $r_remote_hash ]]; then SaveActionResultToLog QPKG "$qpkg_name" download '' skipped 'NAS arch is incompatible' MarkThisAcForkAsSkipped z=1 - elif [[ -f $LOCAL_PATHFILE ]]; then - if FileMatchesMD5 "$LOCAL_PATHFILE" "$REMOTE_HASH"; then - SaveActionResultToLog QPKG "$qpkg_name" download '' skipped-ok "existing file $(ShowAsFileName "$LOCAL_FILENAME") checksum is correct" + elif [[ -f $r_local_pathfile ]]; then + if FileMatchesMD5 "$r_local_pathfile" "$r_remote_hash"; then + SaveActionResultToLog QPKG "$qpkg_name" download '' skipped-ok "existing file $(ShowAsFileName "$r_local_filename") checksum is correct" MarkThisAcForkAsSkippedOk z=2 else - DebugInfo "deleting $(ShowAsFileName "$LOCAL_FILENAME") as checksum is incorrect" - rm -f "$LOCAL_PATHFILE" 2> /dev/null + DebugInfo "deleting $(ShowAsFileName "$r_local_filename") as checksum is incorrect" + rm -f "$r_local_pathfile" 2> /dev/null fi fi [[ $z -eq 0 ]] || FuncForkExit $z - if [[ ! -f $LOCAL_PATHFILE ]]; then - DebugAsProc "downloading $(ShowAsFileName "$REMOTE_FILENAME")" + if [[ ! -f $r_local_pathfile ]]; then + DebugAsProc "downloading $(ShowAsFileName "$r_remote_filename")" - rm -f "$LOG_PATHFILE" 2> /dev/null + rm -f "$r_log_pathfile" 2> /dev/null - RunAndLog "$CURL_CMD --location --output $LOCAL_PATHFILE $REMOTE_URL" "$LOG_PATHFILE" log:failure-only + RunAndLog "$CURL_CMD --location --output $r_local_pathfile $r_remote_url" "$r_log_pathfile" log:failure-only z=$? if [[ $z -eq 0 ]]; then - if FileMatchesMD5 "$LOCAL_PATHFILE" "$REMOTE_HASH"; then - [[ $(Lowercase "${LOCAL_PATHFILE##*.}") = zip ]] && $UNZIP_CMD -nq "$LOCAL_PATHFILE" -d "$QPKG_DL_PATH" + if FileMatchesMD5 "$r_local_pathfile" "$r_remote_hash"; then + [[ $(Lowercase "${r_local_pathfile##*.}") = zip ]] && $UNZIP_CMD -nq "$r_local_pathfile" -d "$r_qpkg_download_path" SaveActionResultToLog QPKG "$qpkg_name" download '' ok SendPackageStateChange ISdownloaded MarkThisAcForkAsOk else - SaveActionResultToLog QPKG "$qpkg_name" download '' failed "cache file $(ShowAsFileName "$LOCAL_FILENAME") has incorrect checksum" + SaveActionResultToLog QPKG "$qpkg_name" download '' failed "cache file $(ShowAsFileName "$r_local_filename") has incorrect checksum" SendPackageStateChange ISNTdownloaded MarkThisAcForkAsError z=1 @@ -9638,8 +9644,8 @@ _QPKG:install_() # Install the QPKG named in $qpkg_name. # Inputs: (global) - # $INSTALL_LOG_FILE - # $LOGS_PATH + # $r_install_log_file + # $r_logs_path # $qpkg_name # $QPKGs_were_installed_name[] # $useropt_debug @@ -9673,7 +9679,7 @@ _QPKG:install_() MarkThisAcForkAsSkipped z=1 elif ! QpkgIsDatabaseMinRAMOk "$qpkg_name"; then - SaveActionResultToLog QPKG "$qpkg_name" install '' skipped 'NAS has insufficient RAM' + SaveActionResultToLog QPKG "$qpkg_name" install '' skipped 'NAS has insufficient RAM installed' MarkThisAcForkAsSkipped z=1 fi @@ -9691,12 +9697,12 @@ _QPKG:install_() [[ $z -eq 0 ]] || FuncForkExit $z if [[ $qpkg_name = Entware ]] && ! QPKGs-ISinstalled.Exist Entware && QPKGs-ACinstall-to.Exist Entware; then - local -r OPT_PATH=/opt - local -r OPT_BU_PATH=/opt.orig + local -r r_opt_path=/opt + local -r r_opt_bu_path=/opt.orig - if [[ -d $OPT_PATH && ! -L $OPT_PATH && ! -e $OPT_BU_PATH ]]; then + if [[ -d $r_opt_path && ! -L $r_opt_path && ! -e $r_opt_bu_path ]]; then DebugAsProc 'backup original /opt' - mv "$OPT_PATH" "$OPT_BU_PATH" + mv "$r_opt_path" "$r_opt_bu_path" DebugAsDone complete fi fi @@ -9704,7 +9710,7 @@ _QPKG:install_() DebugAsProc "installing $(ShowAsPackageName)" [[ ${QPKGs_were_installed_name[*]:-} = *"$qpkg_name"* ]] && a+="QINSTALL_PATH=$(QpkgGetInstalledOriginalPath "$qpkg_name") " - RunAndLog "${a}${SH_CMD} $local_pathfile" "$LOGS_PATH/$($BASENAME_CMD "$local_pathfile").$INSTALL_LOG_FILE" log:failure-only 10 + RunAndLog "${a}${SH_CMD} $local_pathfile" "$r_logs_path/$($BASENAME_CMD "$local_pathfile").$r_install_log_file" log:failure-only 10 z=$? LogQpkgServiceResult @@ -9730,9 +9736,9 @@ _QPKG:install_() # Shift all files from original [/opt] into new [/opt] - if [[ -L ${OPT_PATH:-} && -d ${OPT_BU_PATH:-} ]]; then + if [[ -L ${r_opt_path:-} && -d ${r_opt_bu_path:-} ]]; then DebugAsProc 'restoring original /opt' - mv "$OPT_BU_PATH"/* "$OPT_PATH" && ClearPath / "$OPT_BU_PATH" + mv "$r_opt_bu_path"/* "$r_opt_path" && ClearPath / "$r_opt_bu_path" DebugAsDone complete fi fi @@ -9768,7 +9774,7 @@ _QPKG:reinstall_() FuncForkInit - local a='QPKG_REINSTALL=true ' + local a='REINSTALL_QPKG=true ' [[ $useropt_debug = true ]] && a+='DEBUG_QPKG=true ' local -i z=0 @@ -9801,7 +9807,7 @@ _QPKG:reinstall_() DebugAsProc "reinstalling $(ShowAsPackageName)" QpkgIsInstalled && a+="QINSTALL_PATH=$($DIRNAME_CMD "$(QpkgGetInstalledPath)") " - RunAndLog "${a}${SH_CMD} $local_pathfile" "$LOGS_PATH/$($BASENAME_CMD "$local_pathfile").$REINSTALL_LOG_FILE" log:failure-only 10 + RunAndLog "${a}${SH_CMD} $local_pathfile" "$r_logs_path/$($BASENAME_CMD "$local_pathfile").$r_reinstall_log_file" log:failure-only 10 z=$? LogQpkgServiceResult @@ -9900,7 +9906,7 @@ _QPKG:upgrade_() FuncForkInit - local a='QPKG_UPGRADE=true ' + local a='UPGRADE_QPKG=true ' [[ $useropt_debug = true ]] && a+='DEBUG_QPKG=true ' local -i z=0 @@ -9939,7 +9945,7 @@ _QPKG:upgrade_() DebugAsProc "upgrading $(ShowAsPackageName)" QpkgIsInstalled && a+="QINSTALL_PATH=$($DIRNAME_CMD "$(QpkgGetInstalledPath "$qpkg_name")") " - RunAndLog "${a}${SH_CMD} $local_pathfile" "$LOGS_PATH/$($BASENAME_CMD "$local_pathfile").$UPGRADE_LOG_FILE" log:failure-only 10 + RunAndLog "${a}${SH_CMD} $local_pathfile" "$r_logs_path/$($BASENAME_CMD "$local_pathfile").$r_upgrade_log_file" log:failure-only 10 z=$? LogQpkgServiceResult @@ -10018,14 +10024,14 @@ _QPKG:uninstall_() [[ $z -eq 0 ]] || FuncForkExit $z - local -r QPKG_UNINSTALLER_PATHFILE=$(QpkgGetInstalledPath)/.uninstall.sh + local -r r_qpkg_uninstaller_pathfile=$(QpkgGetInstalledPath)/.uninstall.sh [[ $qpkg_name = Entware ]] && SaveIpkAndPipList - if [[ -e $QPKG_UNINSTALLER_PATHFILE ]]; then + if [[ -e $r_qpkg_uninstaller_pathfile ]]; then DebugAsProc "uninstalling $(ShowAsPackageName)" - RunAndLog "${a}${SH_CMD} $QPKG_UNINSTALLER_PATHFILE" "$LOGS_PATH/$qpkg_name.$UNINSTALL_LOG_FILE" log:failure-only + RunAndLog "${a}${SH_CMD} $r_qpkg_uninstaller_pathfile" "$r_logs_path/$qpkg_name.$r_uninstall_log_file" log:failure-only z=$? if [[ $z -eq 0 ]]; then @@ -10100,9 +10106,9 @@ _QPKG:activate_() [[ $z -eq 0 ]] || FuncForkExit $z - local -r LOG_PATHFILE=$LOGS_PATH/$qpkg_name.$ACTIVATE_LOG_FILE + local -r r_log_pathfile=$r_logs_path/$qpkg_name.$r_activate_log_file local timeout='' - OsIsSupportQpkgTimeout && timeout=" -t $QPKG_START_TIMEOUT_SECONDS" + OsIsSupportQpkgTimeout && timeout=" -t $r_qpkg_start_timeout_seconds" local service_pathfile=$(QpkgGetInstalledServicePathFile) DebugAsProc "activating $(ShowAsPackageName)" @@ -10113,13 +10119,13 @@ _QPKG:activate_() FuncForkExit 4 elif [[ $useropt_debug = true ]]; then - RunAndLog "${a}${service_pathfile} start" "$LOG_PATHFILE" log:failure-only + RunAndLog "${a}${service_pathfile} start" "$r_log_pathfile" log:failure-only z=$? elif QpkgIsDatabaseCanLog; then # Use `qpkg_service` if-possible, so package icon in App Center will dynamically update. - RunAndLog "/sbin/qpkg_service${timeout} start $qpkg_name" "$LOG_PATHFILE" log:failure-only + RunAndLog "/sbin/qpkg_service${timeout} start $qpkg_name" "$r_log_pathfile" log:failure-only QpkgInstalledServiceResultWasOk && z=0 || z=1 else - RunAndLog "$service_pathfile start" "$LOG_PATHFILE" log:failure-only + RunAndLog "$service_pathfile start" "$r_log_pathfile" log:failure-only z=$? fi @@ -10188,9 +10194,9 @@ _QPKG:reactivate_() [[ $z -eq 0 ]] || FuncForkExit $z - local -r LOG_PATHFILE=$LOGS_PATH/$qpkg_name.$REACTIVATE_LOG_FILE + local -r r_log_pathfile=$r_logs_path/$qpkg_name.$r_reactivate_log_file local timeout='' - OsIsSupportQpkgTimeout && timeout=" -t $QPKG_RESTART_TIMEOUT_SECONDS" + OsIsSupportQpkgTimeout && timeout=" -t $r_qpkg_restart_timeout_seconds" local service_pathfile=$(QpkgGetInstalledServicePathFile) DebugAsProc "reactivating $(ShowAsPackageName)" @@ -10201,13 +10207,13 @@ _QPKG:reactivate_() FuncForkExit 4 elif [[ $useropt_debug = true ]]; then - RunAndLog "${a}${service_pathfile} restart" "$LOG_PATHFILE" log:failure-only + RunAndLog "${a}${service_pathfile} restart" "$r_log_pathfile" log:failure-only z=$? elif QpkgIsDatabaseCanLog; then # Use `qpkg_service` if-possible, so package icon in App Center will dynamically update. - RunAndLog "/sbin/qpkg_service${timeout} restart $qpkg_name" "$LOG_PATHFILE" log:failure-only + RunAndLog "/sbin/qpkg_service${timeout} restart $qpkg_name" "$r_log_pathfile" log:failure-only QpkgInstalledServiceResultWasOk && z=0 || z=1 else - RunAndLog "$service_pathfile restart" "$LOG_PATHFILE" log:failure-only + RunAndLog "$service_pathfile restart" "$r_log_pathfile" log:failure-only z=$? fi @@ -10267,9 +10273,9 @@ _QPKG:deactivate_() [[ $z -eq 0 ]] || FuncForkExit $z - local -r LOG_PATHFILE=$LOGS_PATH/$qpkg_name.$DEACTIVATE_LOG_FILE + local -r r_log_pathfile=$r_logs_path/$qpkg_name.$r_deactivate_log_file local timeout='' - OsIsSupportQpkgTimeout && timeout=" -t $QPKG_STOP_TIMEOUT_SECONDS" + OsIsSupportQpkgTimeout && timeout=" -t $r_qpkg_stop_timeout_seconds" local service_pathfile=$(QpkgGetInstalledServicePathFile) DebugAsProc "deactivating $(ShowAsPackageName)" @@ -10280,13 +10286,13 @@ _QPKG:deactivate_() FuncForkExit 4 elif [[ $useropt_debug = true ]]; then - RunAndLog "${a}${service_pathfile} stop" "$LOG_PATHFILE" log:failure-only + RunAndLog "${a}${service_pathfile} stop" "$r_log_pathfile" log:failure-only z=$? elif QpkgIsDatabaseCanLog; then # Use `qpkg_service` if-possible, so package icon in App Center will dynamically update. - RunAndLog "/sbin/qpkg_service${timeout} stop $qpkg_name" "$LOG_PATHFILE" log:failure-only + RunAndLog "/sbin/qpkg_service${timeout} stop $qpkg_name" "$r_log_pathfile" log:failure-only QpkgInstalledServiceResultWasOk && z=0 || z=1 else - RunAndLog "$service_pathfile stop" "$LOG_PATHFILE" log:failure-only + RunAndLog "$service_pathfile stop" "$r_log_pathfile" log:failure-only z=$? fi @@ -10352,13 +10358,13 @@ _QPKG:enable_() [[ $z -eq 0 ]] || FuncForkExit $z - local -r LOG_PATHFILE=$LOGS_PATH/$qpkg_name.$ENABLE_LOG_FILE + local -r r_log_pathfile=$r_logs_path/$qpkg_name.$r_enable_log_file local timeout='' - OsIsSupportQpkgTimeout && timeout=" -t $QPKG_ENABLE_TIMEOUT_SECONDS" + OsIsSupportQpkgTimeout && timeout=" -t $r_qpkg_enable_timeout_seconds" DebugAsProc "enabling $(ShowAsPackageName)" - RunAndLog "/sbin/qpkg_service${timeout} enable $qpkg_name" "$LOG_PATHFILE" log:failure-only + RunAndLog "/sbin/qpkg_service${timeout} enable $qpkg_name" "$r_log_pathfile" log:failure-only QpkgIsInstalledEnabled "$qpkg_name" && SendPackageStateChange ISenabled ClearQpkgInstalledAppCenterNotifier SaveActionResultToLog QPKG "$qpkg_name" enable '' ok @@ -10410,13 +10416,13 @@ _QPKG:disable_() [[ $z -eq 0 ]] || FuncForkExit $z - local -r LOG_PATHFILE=$LOGS_PATH/$qpkg_name.$DISABLE_LOG_FILE + local -r r_log_pathfile=$r_logs_path/$qpkg_name.$r_disable_log_file local timeout='' - OsIsSupportQpkgTimeout && timeout=" -t $QPKG_DISABLE_TIMEOUT_SECONDS" + OsIsSupportQpkgTimeout && timeout=" -t $r_qpkg_disable_timeout_seconds" DebugAsProc "disabling $(ShowAsPackageName)" - RunAndLog "/sbin/qpkg_service${timeout} disable $qpkg_name" "$LOG_PATHFILE" log:failure-only + RunAndLog "/sbin/qpkg_service${timeout} disable $qpkg_name" "$r_log_pathfile" log:failure-only ! QpkgIsInstalledEnabled "$qpkg_name" && SendPackageStateChange ISNTenabled ClearQpkgInstalledAppCenterNotifier @@ -10473,7 +10479,7 @@ _QPKG:enableau_() DebugAsProc "enabling auto-update $(ShowAsPackageName)" - RunAndLog "${a}$(QpkgGetInstalledServicePathFile) enable-auto-update" "$LOGS_PATH/$qpkg_name.$ENABLEAU_LOG_FILE" log:failure-only + RunAndLog "${a}$(QpkgGetInstalledServicePathFile) enable-auto-update" "$r_logs_path/$qpkg_name.$r_enableau_log_file" log:failure-only z=$? if [[ $z -eq 0 ]]; then @@ -10536,7 +10542,7 @@ _QPKG:disableau_() DebugAsProc "disabling auto-update $(ShowAsPackageName)" - RunAndLog "${a}$(QpkgGetInstalledServicePathFile) disable-auto-update" "$LOGS_PATH/$qpkg_name.$DISABLEAU_LOG_FILE" log:failure-only + RunAndLog "${a}$(QpkgGetInstalledServicePathFile) disable-auto-update" "$r_logs_path/$qpkg_name.$r_disableau_log_file" log:failure-only z=$? if [[ $z -eq 0 ]]; then @@ -10595,7 +10601,7 @@ _QPKG:backup_() DebugAsProc "backing-up $(ShowAsPackageName) configuration" - RunAndLog "${a}$(QpkgGetInstalledServicePathFile) backup" "$LOGS_PATH/$qpkg_name.$BACKUP_LOG_FILE" log:failure-only + RunAndLog "${a}$(QpkgGetInstalledServicePathFile) backup" "$r_logs_path/$qpkg_name.$r_backup_log_file" log:failure-only z=$? if [[ $z -eq 0 ]]; then @@ -10659,7 +10665,7 @@ _QPKG:restore_() DebugAsProc "restoring $(ShowAsPackageName) configuration" - RunAndLog "${a}$(QpkgGetInstalledServicePathFile) restore" "$LOGS_PATH/$qpkg_name.$RESTORE_LOG_FILE" log:failure-only + RunAndLog "${a}$(QpkgGetInstalledServicePathFile) restore" "$r_logs_path/$qpkg_name.$r_restore_log_file" log:failure-only z=$? if [[ $z -eq 0 ]]; then @@ -10719,7 +10725,7 @@ _QPKG:clean_() DebugAsProc "cleaning $(ShowAsPackageName)" - RunAndLog "${a}$(QpkgGetInstalledServicePathFile) clean" "$LOGS_PATH/$qpkg_name.$CLEAN_LOG_FILE" log:failure-only + RunAndLog "${a}$(QpkgGetInstalledServicePathFile) clean" "$r_logs_path/$qpkg_name.$r_clean_log_file" log:failure-only z=$? if [[ $z -eq 0 ]]; then @@ -10760,7 +10766,7 @@ _QPKG:sign_() local b='' local -i z=0 - if [[ -e $ACTION_ABORT_PATHFILE ]]; then + if [[ -e $r_action_abort_pathfile ]]; then SaveActionResultToLog QPKG "$qpkg_name" '"sign"' '' skipped-abort 'abort requested, unable to continue' MarkThisAcForkAsSkippedAbort z=3 @@ -10790,25 +10796,25 @@ _QPKG:sign_() SaveActionResultToLog QPKG "$qpkg_name" '"sign"' '' skipped-abort "$(ShowAsFileName sqlite3) binary not found" MarkThisAcForkAsSkippedAbort z=3 - elif [[ ! -e $CERT_DB_PATHFILE ]]; then + elif [[ ! -e $r_cert_db_pathfile ]]; then SaveActionResultToLog QPKG "$qpkg_name" '"sign"' '' skipped-abort "$(OsGetQnapOS) QPKG certificate database not found" MarkThisAcForkAsSkippedAbort z=3 else a="SELECT 1 FROM Certificate WHERE QpkgName = '$qpkg_name' LIMIT 1;" - b=$(eval "$sqlite_cmd" "$CERT_DB_PATHFILE" \"$a\") + b=$(eval "$sqlite_cmd" "$r_cert_db_pathfile" \"$a\") if [[ $b = 1 ]]; then # SaveActionResultToLog QPKG "$qpkg_name" '"sign"' '' skipped-ok 'already signed' # MarkThisAcForkAsSkippedOk # z=2 - # KLUDGE: replace db entries created prior to 2024-06-08 as $QPKG_SIGNATURE quoting was incorrect. + # KLUDGE: replace db entries created prior to 2024-06-08 as $r_qpkg_signature quoting was incorrect. # So, remove existing entry now, and re-add it later in this function. # Keep this in-place until 2025-06-07. a="DELETE FROM Certificate WHERE QpkgName = '$qpkg_name';" - b=$(eval "$sqlite_cmd" "$CERT_DB_PATHFILE" \"$a\") + b=$(eval "$sqlite_cmd" "$r_cert_db_pathfile" \"$a\") z=0 # Disregard errors generated while deleting record. fi fi @@ -10817,14 +10823,14 @@ _QPKG:sign_() DebugAsProc "\"signing\" $(ShowAsPackageName)" -# a="DELETE FROM Certificate WHERE QpkgName = '$qpkg_name'; INSERT INTO Certificate (Type,QpkgName,Cert,DigitalSignature) VALUES ('qpkg','$qpkg_name','$QPKG_CERTIFICATE','$QPKG_SIGNATURE');" +# a="DELETE FROM Certificate WHERE QpkgName = '$qpkg_name'; INSERT INTO Certificate (Type,QpkgName,Cert,DigitalSignature) VALUES ('qpkg','$qpkg_name','$r_qpkg_certificate','$r_qpkg_signature');" -# a="INSERT INTO Certificate (Type, QpkgName, Cert, DigitalSignature) SELECT 'qpkg','$qpkg_name','$QPKG_CERTIFICATE','$QPKG_SIGNATURE' WHERE NOT EXISTS (SELECT * FROM Certificate WHERE QpkgName = '$qpkg_name');" +# a="INSERT INTO Certificate (Type, QpkgName, Cert, DigitalSignature) SELECT 'qpkg','$qpkg_name','$r_qpkg_certificate','$r_qpkg_signature' WHERE NOT EXISTS (SELECT * FROM Certificate WHERE QpkgName = '$qpkg_name');" - a="INSERT INTO Certificate (Type,QpkgName,Cert,DigitalSignature) VALUES ('qpkg','$qpkg_name','$QPKG_CERTIFICATE','$QPKG_SIGNATURE');" + a="INSERT INTO Certificate (Type,QpkgName,Cert,DigitalSignature) VALUES ('qpkg','$qpkg_name','$r_qpkg_certificate','$r_qpkg_signature');" for ((retries=0; retries<10; retries++)); do - eval "$sqlite_cmd" "$CERT_DB_PATHFILE" "\"$a\"" + eval "$sqlite_cmd" "$r_cert_db_pathfile" "\"$a\"" z=$? case $z in @@ -10888,10 +10894,10 @@ _QPKG:status_() # Run status query with GNU `timeout` if-possible. if [[ -e $GNU_TIMEOUT_CMD ]]; then - $GNU_TIMEOUT_CMD "$QPKG_STATUS_CHECK_TIMEOUT_SECONDS" /bin/bash -c "${b}$(QpkgGetInstalledServicePathFile) status" + $GNU_TIMEOUT_CMD "$r_qpkg_status_check_timeout_seconds" /bin/bash -c "${b}$(QpkgGetInstalledServicePathFile) status" z=$? else - RunAndLog "${b}$(QpkgGetInstalledServicePathFile) status" "$LOGS_PATH/$qpkg_name.$STATUS_LOG_FILE" log:failure-only + RunAndLog "${b}$(QpkgGetInstalledServicePathFile) status" "$r_logs_path/$qpkg_name.$r_status_log_file" log:failure-only z=$? fi elif [[ $a != none ]]; then @@ -11018,12 +11024,12 @@ QpkgGetDatabaseApplVer() # Returns the version number of the application contained within a QPKG. # Inputs: (global) - # $QPKG_APPL_VERSION + # $r_qpkg_appl_version # $qpkg_default_index # $qpkg_index # $qpkg_name - # $QPKG_NAME - # $QPKG_VERSION + # $r_qpkg_name + # $r_qpkg_version # Outputs: (local) # stdout = application version @@ -11033,15 +11039,15 @@ QpkgGetDatabaseApplVer() local -i i=0 if [[ $qpkg_index -gt 0 ]]; then - a=${QPKG_APPL_VERSION[$qpkg_index]} - [[ $a = default ]] && a=${QPKG_APPL_VERSION[$qpkg_default_index]} - [[ $a = version ]] && a=${QPKG_VERSION[$qpkg_default_index]} + a=${r_qpkg_appl_version[$qpkg_index]} + [[ $a = default ]] && a=${r_qpkg_appl_version[$qpkg_default_index]} + [[ $a = version ]] && a=${r_qpkg_version[$qpkg_default_index]} [[ $a != none ]] || return else - for i in "${!QPKG_NAME[@]}"; do - if [[ ${QPKG_NAME[$i]} = "$qpkg_name" ]]; then - a=${QPKG_APPL_VERSION[$i]} - [[ $a = version ]] && a=${QPKG_VERSION[$qpkg_default_index]} + for i in "${!r_qpkg_name[@]}"; do + if [[ ${r_qpkg_name[$i]} = "$qpkg_name" ]]; then + a=${r_qpkg_appl_version[$i]} + [[ $a = version ]] && a=${r_qpkg_version[$qpkg_default_index]} [[ $a != none ]] || return break fi @@ -11075,16 +11081,16 @@ QpkgGetDatabaseVer() local -i i=0 if [[ -n ${1:-} ]]; then - for i in "${!QPKG_NAME[@]}"; do - if [[ ${QPKG_NAME[$i]} = "$1" ]]; then - printf '%s' "${QPKG_VERSION[$i]}" + for i in "${!r_qpkg_name[@]}"; do + if [[ ${r_qpkg_name[$i]} = "$1" ]]; then + printf '%s' "${r_qpkg_version[$i]}" return 0 fi done elif [[ $qpkg_index -gt 0 ]]; then - a=${QPKG_VERSION[$qpkg_index]} - [[ $a = default ]] && a=${QPKG_VERSION[$qpkg_default_index]} + a=${r_qpkg_version[$qpkg_index]} + [[ $a = default ]] && a=${r_qpkg_version[$qpkg_default_index]} [[ $a != none ]] || return printf '%s' "$a" @@ -11196,7 +11202,7 @@ QpkgGetDatabasePathFilename() [[ $(Lowercase "${a##*.}") != qpkg ]] && a=${a%.*}.qpkg # Swap 'zip' for 'qpkg' here (only for compatibilty with 'QDK.zip'). - printf '%s' "$QPKG_DL_PATH/$($BASENAME_CMD "$a")" + printf '%s' "$r_qpkg_download_path/$($BASENAME_CMD "$a")" return 0 @@ -11218,8 +11224,8 @@ QpkgGetDatabaseHash() local a='' - a=${QPKG_HASH[$qpkg_index]} - [[ $a = default ]] && a=${QPKG_HASH[$qpkg_default_index]} + a=${r_qpkg_hash[$qpkg_index]} + [[ $a = default ]] && a=${r_qpkg_hash[$qpkg_default_index]} [[ $a != none ]] || return printf '%s' "$a" @@ -11249,9 +11255,9 @@ QpkgGetDatabaseURL() local -i i=0 if [[ -n ${1:-} ]]; then - for i in "${!QPKG_NAME[@]}"; do - if [[ ${QPKG_NAME[$i]} = "$1" ]] && [[ ${QPKG_ARCH[$i]} = all || ${QPKG_ARCH[$i]} = "$NAS_QPKG_ARCH" ]]; then - printf '%s' "${QPKG_URL[$i]}" + for i in "${!r_qpkg_name[@]}"; do + if [[ ${r_qpkg_name[$i]} = "$1" ]] && [[ ${r_qpkg_arch[$i]} = all || ${r_qpkg_arch[$i]} = "$r_nas_qpkg_arch" ]]; then + printf '%s' "${r_qpkg_url[$i]}" return 0 fi @@ -11259,8 +11265,8 @@ QpkgGetDatabaseURL() return 1 else - a=${QPKG_URL[$qpkg_index]} - [[ $a = default ]] && a=${QPKG_URL[$qpkg_default_index]} + a=${r_qpkg_url[$qpkg_index]} + [[ $a = default ]] && a=${r_qpkg_url[$qpkg_default_index]} [[ -n $a ]] || a=none printf '%s' "$a" fi @@ -11288,14 +11294,14 @@ QpkgGetDatabaseMinRAM() local -i i=0 if [[ -n ${1:-} ]]; then - for i in "${!QPKG_NAME[@]}"; do - [[ ${QPKG_NAME[$i]} = "$1" ]] || continue - a=${QPKG_MIN_RAM_KB[$i]} # Always grab first found as default. + for i in "${!r_qpkg_name[@]}"; do + [[ ${r_qpkg_name[$i]} = "$1" ]] || continue + a=${r_qpkg_min_ram_kb[$i]} # Always grab first found as default. break done else - a=${QPKG_MIN_RAM_KB[$qpkg_index]} - [[ $a = default ]] && a=${QPKG_MIN_RAM_KB[$qpkg_default_index]} + a=${r_qpkg_min_ram_kb[$qpkg_index]} + [[ $a = default ]] && a=${r_qpkg_min_ram_kb[$qpkg_default_index]} fi [[ -n $a ]] || a=none @@ -11324,14 +11330,14 @@ QpkgGetDatabaseMinOSVer() local -i i=0 if [[ -n ${1:-} ]]; then - for i in "${!QPKG_NAME[@]}"; do - [[ ${QPKG_NAME[$i]} = "$1" ]] || continue - a=${QPKG_MIN_OS_VERSION[$i]} # Always grab first found as default. + for i in "${!r_qpkg_name[@]}"; do + [[ ${r_qpkg_name[$i]} = "$1" ]] || continue + a=${r_qpkg_min_os_version[$i]} # Always grab first found as default. break done else - a=${QPKG_MIN_OS_VERSION[$qpkg_index]} - [[ $a = default ]] && a=${QPKG_MIN_OS_VERSION[$qpkg_default_index]} + a=${r_qpkg_min_os_version[$qpkg_index]} + [[ $a = default ]] && a=${r_qpkg_min_os_version[$qpkg_default_index]} fi [[ -n $a ]] || a=none @@ -11360,14 +11366,14 @@ QpkgGetDatabaseMaxOSVer() local -i i=0 if [[ -n ${1:-} ]]; then - for i in "${!QPKG_NAME[@]}"; do - [[ ${QPKG_NAME[$i]} = "$1" ]] || continue - a=${QPKG_MAX_OS_VERSION[$i]} # Always grab first found as default. + for i in "${!r_qpkg_name[@]}"; do + [[ ${r_qpkg_name[$i]} = "$1" ]] || continue + a=${r_qpkg_max_os_version[$i]} # Always grab first found as default. break done else - a=${QPKG_MAX_OS_VERSION[$qpkg_index]} - [[ $a = default ]] && a=${QPKG_MAX_OS_VERSION[$qpkg_default_index]} + a=${r_qpkg_max_os_version[$qpkg_index]} + [[ $a = default ]] && a=${r_qpkg_max_os_version[$qpkg_default_index]} fi [[ -n $a ]] || a=none @@ -11395,9 +11401,9 @@ QpkgGetDatabaseAuthor() local a=${1:-${qpkg_name:?${FUNCNAME[0]}'()': undefined package name}} local -i i=0 - for i in "${!QPKG_NAME[@]}"; do - [[ ${QPKG_NAME[$i]} = "$a" ]] || continue - printf '%s' "${QPKG_AUTHOR[$i]}" + for i in "${!r_qpkg_name[@]}"; do + [[ ${r_qpkg_name[$i]} = "$a" ]] || continue + printf '%s' "${r_qpkg_author[$i]}" return 0 done @@ -11438,9 +11444,9 @@ QpkgGetInstalledAuthor() # # local -i i=0 # -# for i in "${!QPKG_NAME[@]}"; do -# [[ ${QPKG_NAME[$i]} = "${1:?${FUNCNAME[0]}'()': undefined package name}" ]] || continue -# printf '%s' "${QPKG_AUTHOR_EMAIL[$i]}" +# for i in "${!r_qpkg_name[@]}"; do +# [[ ${r_qpkg_name[$i]} = "${1:?${FUNCNAME[0]}'()': undefined package name}" ]] || continue +# printf '%s' "${r_qpkg_author_email[$i]}" # # return 0 # done @@ -11463,9 +11469,9 @@ QpkgGetInstalledAuthor() # # local -i i=0 # -# for i in "${!QPKG_NAME[@]}"; do -# [[ ${QPKG_NAME[$i]} = "${1:?${FUNCNAME[0]}'()': undefined package name}" ]] || continue -# printf '%s' "${QPKG_APPL_AUTHOR[$i]}" +# for i in "${!r_qpkg_name[@]}"; do +# [[ ${r_qpkg_name[$i]} = "${1:?${FUNCNAME[0]}'()': undefined package name}" ]] || continue +# printf '%s' "${r_qpkg_appl_author[$i]}" # # return 0 # done @@ -11488,9 +11494,9 @@ QpkgGetInstalledAuthor() # # local -i i=0 # -# for i in "${!QPKG_NAME[@]}"; do -# [[ ${QPKG_NAME[$i]} = "${1:?${FUNCNAME[0]}'()': undefined package name}" ]] || continue -# printf '%s' "${QPKG_APPL_AUTHOR_EMAIL[$i]}" +# for i in "${!r_qpkg_name[@]}"; do +# [[ ${r_qpkg_name[$i]} = "${1:?${FUNCNAME[0]}'()': undefined package name}" ]] || continue +# printf '%s' "${r_qpkg_appl_author_email[$i]}" # # return 0 # done @@ -11516,14 +11522,14 @@ QpkgGetDatabaseDesc() local -i i=0 if [[ -n ${1:-} ]]; then - for i in "${!QPKG_NAME[@]}"; do - [[ ${QPKG_NAME[$i]} = "$1" ]] || continue - a=${QPKG_DESC[$i]} # Always grab first found as default. + for i in "${!r_qpkg_name[@]}"; do + [[ ${r_qpkg_name[$i]} = "$1" ]] || continue + a=${r_qpkg_description[$i]} # Always grab first found as default. break done else - a=${QPKG_DESC[$qpkg_index]} - [[ $a = default ]] && a=${QPKG_DESC[$qpkg_default_index]} + a=${r_qpkg_description[$qpkg_index]} + [[ $a = default ]] && a=${r_qpkg_description[$qpkg_default_index]} fi [[ -n $a ]] || a=none @@ -11551,14 +11557,14 @@ QpkgGetDatabaseNote() local -i i=0 if [[ -n ${1:-} ]]; then - for i in "${!QPKG_NAME[@]}"; do - [[ ${QPKG_NAME[$i]} = "$1" ]] || continue - a=${QPKG_NOTE[$i]} # Always grab first found as default. + for i in "${!r_qpkg_name[@]}"; do + [[ ${r_qpkg_name[$i]} = "$1" ]] || continue + a=${r_qpkg_note[$i]} # Always grab first found as default. break done else - a=${QPKG_NOTE[$qpkg_index]} - [[ $a = default ]] && a=${QPKG_NOTE[$qpkg_default_index]} + a=${r_qpkg_note[$qpkg_index]} + [[ $a = default ]] && a=${r_qpkg_note[$qpkg_default_index]} [[ $a = none ]] && return 1 fi @@ -11585,14 +11591,14 @@ QpkgGetDatabaseAbbrvs() local -i i=0 if [[ -n ${1:-} ]]; then - for i in "${!QPKG_NAME[@]}"; do - [[ ${QPKG_NAME[$i]} = "$1" ]] || continue - a=${QPKG_ABBRVS[$i]} # Always grab first found as default. + for i in "${!r_qpkg_name[@]}"; do + [[ ${r_qpkg_name[$i]} = "$1" ]] || continue + a=${r_qpkg_abbrvs[$i]} # Always grab first found as default. break done else - a=${QPKG_ABBRVS[$qpkg_index]} - [[ $a = default ]] && a=${QPKG_ABBRVS[$qpkg_default_index]} + a=${r_qpkg_abbrvs[$qpkg_index]} + [[ $a = default ]] && a=${r_qpkg_abbrvs[$qpkg_default_index]} fi [[ -n $a ]] || a=none @@ -11622,9 +11628,9 @@ QpkgGetDatabaseDependencies() local out='' local x='' - g=${QPKG_DEPENDS_ON[$qpkg_index]} + g=${r_qpkg_depends_on[$qpkg_index]} [[ $g = none ]] && return 1 - [[ $g = default ]] && g=${QPKG_DEPENDS_ON[$qpkg_default_index]} + [[ $g = default ]] && g=${r_qpkg_depends_on[$qpkg_default_index]} if [[ $g != *'|'* ]]; then # no alternatives were listed. printf '%s' "$g" @@ -11695,9 +11701,9 @@ QpkgGetDatabaseDependents() local re=\\b${qpkg_name}\\b if QPKGs-GRindependent.Exist "$qpkg_name"; then - for i in "${!QPKG_NAME[@]}"; do - if [[ ${QPKG_DEPENDS_ON[$i]} =~ $re ]]; then - [[ ${ar[*]:-} != "${QPKG_NAME[$i]}" ]] && ar+=(${QPKG_NAME[$i]}) + for i in "${!r_qpkg_name[@]}"; do + if [[ ${r_qpkg_depends_on[$i]} =~ $re ]]; then + [[ ${ar[*]:-} != "${r_qpkg_name[$i]}" ]] && ar+=(${r_qpkg_name[$i]}) fi done fi @@ -11728,8 +11734,8 @@ QpkgGetDatabaseIPKs() local a='' - a=${QPKG_REQUIRES_IPKS[$qpkg_index]} - [[ $a = default ]] && a=${QPKG_REQUIRES_IPKS[$qpkg_default_index]} + a=${r_qpkg_requires_ipks[$qpkg_index]} + [[ $a = default ]] && a=${r_qpkg_requires_ipks[$qpkg_default_index]} [[ $a = none ]] && return 1 printf '%s' "$a" @@ -11754,8 +11760,8 @@ QpkgGetDatabaseActiveTest() [[ -n $qpkg_name && $qpkg_index -gt 0 && $qpkg_default_index -gt 0 ]] || return - a=${QPKG_TEST_FOR_ACTIVE[$qpkg_index]} - [[ $a = default ]] && a=${QPKG_TEST_FOR_ACTIVE[$qpkg_default_index]} + a=${r_qpkg_test_for_active[$qpkg_index]} + [[ $a = default ]] && a=${r_qpkg_test_for_active[$qpkg_default_index]} [[ $a = none ]] && return 1 printf '%s' "$a" @@ -11838,8 +11844,8 @@ QpkgMatchAbbrv() # $1 (string) = a potential package abbreviation supplied by user. # Inputs: (global) - # $QPKG_ABBRVS[] - # $QPKG_NAME[] + # $r_qpkg_abbrvs[] + # $r_qpkg_name[] # Outputs: (local) # stdout = matched installable package name (empty if unmatched). @@ -11850,12 +11856,12 @@ QpkgMatchAbbrv() local -i j=0 local -i z=1 # Default to 'unmatched'. - for i in "${!QPKG_NAME[@]}"; do - ar=(${QPKG_ABBRVS[$i]}) + for i in "${!r_qpkg_name[@]}"; do + ar=(${r_qpkg_abbrvs[$i]}) for j in "${!ar[@]}"; do [[ ${ar[$j]} = "$1" ]] || continue - printf '%s' "${QPKG_NAME[$i]}" + printf '%s' "${r_qpkg_name[$i]}" z=0 break 2 done @@ -11871,10 +11877,10 @@ QpkgSetIndex() # Find and set the 1-based indexed reference of the named arch-specific QPKG in `packages` file. # Inputs: (global) - # $NAS_QPKG_ARCH - # $QPKG_ARCH[] + # $r_nas_qpkg_arch + # $r_qpkg_arch[] # $qpkg_name - # $QPKG_NAME[] + # $r_qpkg_name[] # Outputs: (local) # $? = 0 (successful) / !0 (failed) @@ -11886,9 +11892,9 @@ QpkgSetIndex() QpkgSetDefaultIndex - for qpkg_index in "${!QPKG_NAME[@]}"; do - [[ ${QPKG_NAME[$qpkg_index]} = "$qpkg_name" ]] || continue - [[ ${QPKG_ARCH[$qpkg_index]} = all || ${QPKG_ARCH[$qpkg_index]} = "$NAS_QPKG_ARCH" ]] || continue + for qpkg_index in "${!r_qpkg_name[@]}"; do + [[ ${r_qpkg_name[$qpkg_index]} = "$qpkg_name" ]] || continue + [[ ${r_qpkg_arch[$qpkg_index]} = all || ${r_qpkg_arch[$qpkg_index]} = "$r_nas_qpkg_arch" ]] || continue return 0 done @@ -11906,7 +11912,7 @@ QpkgSetDefaultIndex() # Inputs: (global) # $qpkg_name - # $QPKG_NAME[] + # $r_qpkg_name[] # Outputs: (local) # $? = 0 (successful) / !0 (failed) @@ -11916,8 +11922,8 @@ QpkgSetDefaultIndex() [[ -n ${qpkg_name:-} ]] || return - for qpkg_default_index in "${!QPKG_NAME[@]}"; do - [[ ${QPKG_NAME[$qpkg_default_index]} = "$qpkg_name" ]] || continue + for qpkg_default_index in "${!r_qpkg_name[@]}"; do + [[ ${r_qpkg_name[$qpkg_default_index]} = "$qpkg_name" ]] || continue return 0 done @@ -11975,13 +11981,13 @@ QpkgIsBackupExist() # $1 (optional) = QPKG name. # Inputs: (global) - # $QPKG_BU_PATH + # $r_qpkg_bu_path # $qpkg_name (default) # Outputs: (local) # $? = true/false - [[ -e $QPKG_BU_PATH/${1:-${qpkg_name:?${FUNCNAME[0]}'()': undefined package name}}.config.tar.gz ]] + [[ -e $r_qpkg_bu_path/${1:-${qpkg_name:?${FUNCNAME[0]}'()': undefined package name}}.config.tar.gz ]] } @@ -12039,8 +12045,8 @@ QpkgIsDatabaseDependent() local a='' - a=${QPKG_DEPENDS_ON[$qpkg_index]} - [[ $a = default ]] && a=${QPKG_DEPENDS_ON[$qpkg_default_index]} + a=${r_qpkg_depends_on[$qpkg_index]} + [[ $a = default ]] && a=${r_qpkg_depends_on[$qpkg_default_index]} [[ $a != none ]] } @@ -12090,7 +12096,7 @@ QpkgIsDatabaseMinRAMOk() # $1 (optional) = QPKG name. # Inputs: (global) - # $NAS_RAM_KB + # $r_nas_ram_kb # $qpkg_name (default) # Outputs: (local) @@ -12098,7 +12104,7 @@ QpkgIsDatabaseMinRAMOk() local a=$(QpkgGetDatabaseMinRAM "${1:-${qpkg_name:?${FUNCNAME[0]}'()': undefined package name}}") - [[ -n $a ]] && [[ $a = none || $NAS_RAM_KB -ge $a ]] + [[ -n $a ]] && [[ $a = none || $r_nas_ram_kb -ge $a ]] } @@ -12111,7 +12117,7 @@ QpkgIsDatabaseMinOSVerOk() # $1 (string, optional override for $qpkg_name) = QPKG name: if $1 is explicitly stated, lookup $1 in package lists, ignoring current $qpkg_name and $qpkg_index. # Inputs: (global) - # $NAS_FIRMWARE_VER + # $r_nas_firmware_version # $qpkg_name (default for $1) # Outputs: (local) @@ -12119,7 +12125,7 @@ QpkgIsDatabaseMinOSVerOk() local a=$(QpkgGetDatabaseMinOSVer "${1:-${qpkg_name:?${FUNCNAME[0]}'()': undefined package name}}") - [[ -n $a ]] && [[ $a = none || ${NAS_FIRMWARE_VER//.} -ge $a ]] + [[ -n $a ]] && [[ $a = none || ${r_nas_firmware_version//.} -ge $a ]] } @@ -12132,7 +12138,7 @@ QpkgIsDatabaseMaxOSVerOk() # $1 (string, optional override for $qpkg_name) = QPKG name: if $1 is explicitly stated, lookup $1 in package lists, ignoring current $qpkg_name and $qpkg_index. # Inputs: (global) - # $NAS_FIRMWARE_VER + # $r_nas_firmware_version # $qpkg_name (default for $1) # Outputs: (local) @@ -12140,7 +12146,7 @@ QpkgIsDatabaseMaxOSVerOk() local a=$(QpkgGetDatabaseMaxOSVer "${1:-${qpkg_name:?${FUNCNAME[0]}'()': undefined package name}}") - [[ -n $a ]] && [[ $a = none || ${NAS_FIRMWARE_VER//.} -le $a ]] + [[ -n $a ]] && [[ $a = none || ${r_nas_firmware_version//.} -le $a ]] } @@ -12153,11 +12159,11 @@ QpkgIsDatabaseCanBackup() # $1 (string, optional override for $qpkg_name) = QPKG name: if $1 is explicitly stated, lookup $1 in package lists, ignoring current $qpkg_name and $qpkg_index. # Inputs: (global) - # $QPKG_CAN_BACKUP[] + # $r_qpkg_can_backup[] # $qpkg_default_index # $qpkg_index # $qpkg_name (default for $1) - # $QPKG_NAME[] + # $r_qpkg_name[] # Outputs: (local) # $? = true/false @@ -12166,14 +12172,14 @@ QpkgIsDatabaseCanBackup() local -i i=0 if [[ -n ${1:-} ]]; then - for i in "${!QPKG_NAME[@]}"; do - [[ ${QPKG_NAME[$i]} = "$1" ]] || continue - a=${QPKG_CAN_BACKUP[$i]} # Always grab first found as default. + for i in "${!r_qpkg_name[@]}"; do + [[ ${r_qpkg_name[$i]} = "$1" ]] || continue + a=${r_qpkg_can_backup[$i]} # Always grab first found as default. break done else - a=${QPKG_CAN_BACKUP[$qpkg_index]} - [[ $a = default ]] && a=${QPKG_CAN_BACKUP[$qpkg_default_index]} + a=${r_qpkg_can_backup[$qpkg_index]} + [[ $a = default ]] && a=${r_qpkg_can_backup[$qpkg_default_index]} fi [[ -n $a ]] || a=none @@ -12191,8 +12197,8 @@ QpkgIsDatabaseCanRestartToUpdate() # Inputs: (global) # $qpkg_name (default for $1) - # $QPKG_NAME[] - # $QPKG_CAN_RESTART_TO_UPDATE[] + # $r_qpkg_name[] + # $r_qpkg_can_restart_to_update[] # Outputs: (local) # $? = 0 (true), !0 (false) (first package found). @@ -12200,9 +12206,9 @@ QpkgIsDatabaseCanRestartToUpdate() local a=${1:-${qpkg_name:?${FUNCNAME[0]}'()': undefined package name}} local -i i=0 - for i in "${!QPKG_NAME[@]}"; do - [[ ${QPKG_NAME[$i]} = "$a" ]] || continue - ${QPKG_CAN_RESTART_TO_UPDATE[$i]} && return 0 || break + for i in "${!r_qpkg_name[@]}"; do + [[ ${r_qpkg_name[$i]} = "$a" ]] || continue + ${r_qpkg_can_restart_to_update[$i]} && return 0 || break done return 1 @@ -12226,9 +12232,9 @@ QpkgIsDatabaseCanClean() local a=${1:-${qpkg_name:?${FUNCNAME[0]}'()': undefined package name}} local -i i=0 - for i in "${!QPKG_NAME[@]}"; do - [[ ${QPKG_NAME[$i]} = "$a" ]] || continue - ${QPKG_CAN_CLEAN[$i]} && return 0 || break + for i in "${!r_qpkg_name[@]}"; do + [[ ${r_qpkg_name[$i]} = "$a" ]] || continue + ${r_qpkg_can_clean[$i]} && return 0 || break done return 1 @@ -12255,14 +12261,14 @@ QpkgIsDatabaseSherpaCompatible() local -i i=0 if [[ -n ${1:-} ]]; then - for i in "${!QPKG_NAME[@]}"; do - [[ ${QPKG_NAME[$i]} = "$1" ]] || continue - a=${QPKG_IS_SHERPA_COMPATIBLE[$i]} # Always grab first found as default. + for i in "${!r_qpkg_name[@]}"; do + [[ ${r_qpkg_name[$i]} = "$1" ]] || continue + a=${r_qpkg_is_sherpa_compatible[$i]} # Always grab first found as default. break done else - a=${QPKG_IS_SHERPA_COMPATIBLE[$qpkg_index]} - [[ $a = default ]] && a=${QPKG_IS_SHERPA_COMPATIBLE[$qpkg_default_index]} + a=${r_qpkg_is_sherpa_compatible[$qpkg_index]} + [[ $a = default ]] && a=${r_qpkg_is_sherpa_compatible[$qpkg_default_index]} fi [[ -n $a ]] || a=none @@ -12286,9 +12292,9 @@ QpkgIsDatabaseCanLog() local -i i=0 - for i in "${!QPKG_NAME[@]}"; do - [[ ${QPKG_NAME[$i]} = "${1:-${qpkg_name:?${FUNCNAME[0]}'()': undefined package name}}" ]] || continue - ${QPKG_CAN_LOG[$i]} && return 0 || break + for i in "${!r_qpkg_name[@]}"; do + [[ ${r_qpkg_name[$i]} = "${1:-${qpkg_name:?${FUNCNAME[0]}'()': undefined package name}}" ]] || continue + ${r_qpkg_can_log[$i]} && return 0 || break done return 1 @@ -12462,14 +12468,14 @@ LoadQpkgSigning() { # Outputs: (global) - # $QPKG_CERTIFICATE - # $QPKG_SIGNATURE + # $r_qpkg_certificate + # $r_qpkg_signature - QPKG_CERTIFICATE='' - QPKG_SIGNATURE='' + r_qpkg_certificate='' + r_qpkg_signature='' # This certificate block is the same used by QNAP for LicenseCenter. - read -r -d '' QPKG_CERTIFICATE << EOB + read -r -d '' r_qpkg_certificate << EOB -----BEGIN CERTIFICATE----- MIIDwzCCAqugAwIBAgIFALhDVuwwDQYJKoZIhvcNAQELBQAwgYAxCzAJBgNVBAYT AlRXMQ8wDQYDVQQIDAZUYWl3YW4xDzANBgNVBAcMBlRhaXBlaTENMAsGA1UECgwE @@ -12496,7 +12502,7 @@ AVIlas0e4g== EOB # This digital signature block is the same used by QNAP for LicenseCenter. - read -r -d '' QPKG_SIGNATURE << EOB + read -r -d '' r_qpkg_signature << EOB MIME-Version: 1.0 Content-Disposition: attachment; filename=\"smime.p7m\" Content-Type: application/pkcs7-mime; smime-type=signed-data; name=\"smime.p7m\" @@ -12540,8 +12546,8 @@ U48h9xKvPg6CsIlyfuKetHBjZZI6iSCvh2FZOWsD1/W2oGYkkY9Hdff24B34/res cKXk/K9/JFAONWBbXUpxtzpBCeVJlZS1wQgu4Q+Fr6imaBXJkiyiNg== EOB - readonly QPKG_CERTIFICATE - readonly QPKG_SIGNATURE + readonly r_qpkg_certificate + readonly r_qpkg_signature } @@ -12603,7 +12609,7 @@ RunAndLog() # $4 = e.g. '10' (optional) - an additional acceptable result code. Any other non-zero result from command will be considered a failure. # Inputs: (global) - # $RUN_LOGS_PATH + # $r_run_logs_path # $useropt_debug # $useropt_verbose @@ -12616,25 +12622,25 @@ RunAndLog() FuncInit - MakePath "$RUN_LOGS_PATH" 'runtime logs' + MakePath "$r_run_logs_path" 'runtime logs' - local -r LOG_PATHFILE=$($MKTEMP_CMD "$RUN_LOGS_PATH"/"${FUNCNAME[0]}"_XXXXXX) + local -r r_log_pathfile=$($MKTEMP_CMD "$r_run_logs_path"/"${FUNCNAME[0]}"_XXXXXX) local -i z=0 ShowAsCommand "$1" > "$2" DebugAsProc "exec: '$1'" if [[ $useropt_verbose = true ]]; then - eval "$1 > >($TEE_CMD $LOG_PATHFILE) 2>&1" # NOTE: `tee` buffers stdout here + eval "$1 > >($TEE_CMD $r_log_pathfile) 2>&1" # NOTE: `tee` buffers stdout here z=$? else - (eval "$1" > "$LOG_PATHFILE" 2>&1) # run in a subshell to suppress 'Terminated' message later + (eval "$1" > "$r_log_pathfile" 2>&1) # run in a subshell to suppress 'Terminated' message later z=$? fi - if [[ -e $LOG_PATHFILE ]]; then - ShowAsResultAndStdout "$z" "$(<"$LOG_PATHFILE")" >> "$2" - rm -f "$LOG_PATHFILE" 2> /dev/null + if [[ -e $r_log_pathfile ]]; then + ShowAsResultAndStdout "$z" "$(<"$r_log_pathfile")" >> "$2" + rm -f "$r_log_pathfile" 2> /dev/null else ShowAsResultAndStdout "$z" '' >> "$2" fi @@ -12804,7 +12810,7 @@ ShowTitle() # Only show ASCII title when no arguments have been specified. - if [[ -z ${ARGS_RAW[*]:-} ]]; then + if [[ -z ${r_args_raw[*]:-} ]]; then Display "$(ShowTitleArt)" else Display "$(ShowAsTitleName) $(ShowAsVersion)" @@ -12850,7 +12856,7 @@ ShowAsCopyrightBasic() ShowAsVersion() { - printf '%s' "v$THIS_SCRIPT_VER" + printf '%s' "v$r_this_script_ver" } @@ -12921,14 +12927,14 @@ ShowAsExitcode() ShowAsLogFilename() { - printf '%s' "${CHARS_RESULTS}log file: '${1:?${FUNCNAME[0]}'()': undefined filename}'" + printf '%s' "${r_chars_results}log file: '${1:?${FUNCNAME[0]}'()': undefined filename}'" } ShowAsCommand() { - echo "${CHARS_RESULTS}command: '${1:?${FUNCNAME[0]}'()': undefined commandstring}'" + echo "${r_chars_results}command: '${1:?${FUNCNAME[0]}'()': undefined commandstring}'" } @@ -12938,9 +12944,9 @@ ShowAsResultAndStdout() [[ -n ${1:-} ]] || return [[ -n ${2:-} ]] || return - local a=$CHARS_RESULTS + local a=$r_chars_results - [[ ${1:-0} -ne 0 ]] && a=$CHARS_ALERT + [[ ${1:-0} -ne 0 ]] && a=$r_chars_alert echo "${a}result_code: $(ShowAsExitcode "$1") ***** stdout/stderr begins below *****" echo "$2" @@ -12980,7 +12986,7 @@ DebugInfoMajSepr() # Debug info major separator. - DebugInfo "$(eval printf '%0.s=' "{1..$DEBUG_LOG_DATAWIDTH}")" # `seq` is unavailable in QTS, so must resort to `eval` trickery instead. + DebugInfo "$(eval printf '%0.s=' "{1..$r_debug_log_full_width}")" # `seq` is unavailable in QTS, so must resort to `eval` trickery instead. } @@ -12989,7 +12995,7 @@ DebugInfoMinSepr() # Debug info minor separator. - DebugInfo "$(eval printf '%0.s-' "{1..$DEBUG_LOG_DATAWIDTH}")" # `seq` is unavailable in QTS, so must resort to `eval` trickery instead. + DebugInfo "$(eval printf '%0.s-' "{1..$r_debug_log_full_width}")" # `seq` is unavailable in QTS, so must resort to `eval` trickery instead. } @@ -12998,7 +13004,7 @@ DebugExtLogMinSepr() # Debug external log minor separator. - DebugAsLog "$(eval printf '%0.s-' "{1..$DEBUG_LOG_DATAWIDTH}")" # `seq` is unavailable in QTS, so must resort to `eval` trickery instead. + DebugAsLog "$(eval printf '%0.s-' "{1..$r_debug_log_full_width}")" # `seq` is unavailable in QTS, so must resort to `eval` trickery instead. } @@ -13086,13 +13092,13 @@ DebugDetectTabld() # Debug detected tabulated. if [[ -z ${3:-} ]]; then # If $3 is nothing, then assume only 2 fields are required. - DebugAsDetect "$(printf "%${DEBUG_LOG_FIRST_COL_WIDTH}s: %${DEBUG_LOG_SECOND_COL_WIDTH}s\n" "${1:-}" "${2:-}")" + DebugAsDetect "$(printf "%${r_debug_log_first_column_width}s: %${r_debug_log_second_column_width}s\n" "${1:-}" "${2:-}")" elif [[ ${3:-} = ' ' ]]; then # If $3 is only a whitespace then print $2 with trailing colon and 'none' as third field. - DebugAsDetect "$(printf "%${DEBUG_LOG_FIRST_COL_WIDTH}s: %${DEBUG_LOG_SECOND_COL_WIDTH}s: none\n" "${1:-}" "${2:-}")" + DebugAsDetect "$(printf "%${r_debug_log_first_column_width}s: %${r_debug_log_second_column_width}s: none\n" "${1:-}" "${2:-}")" elif [[ ${3: -1} = ' ' ]]; then # If $3 has a trailing whitespace then print $3 without the trailing whitespace. - DebugAsDetect "$(printf "%${DEBUG_LOG_FIRST_COL_WIDTH}s: %${DEBUG_LOG_SECOND_COL_WIDTH}s: %-s\n" "${1:-}" "${2:-}" "$($SED_CMD 's| *$||' <<< "${3:-}")")" + DebugAsDetect "$(printf "%${r_debug_log_first_column_width}s: %${r_debug_log_second_column_width}s: %-s\n" "${1:-}" "${2:-}" "$($SED_CMD 's| *$||' <<< "${3:-}")")" else - DebugAsDetect "$(printf "%${DEBUG_LOG_FIRST_COL_WIDTH}s: %${DEBUG_LOG_SECOND_COL_WIDTH}s: %-s\n" "${1:-}" "${2:-}" "${3:-}")" + DebugAsDetect "$(printf "%${r_debug_log_first_column_width}s: %${r_debug_log_second_column_width}s: %-s\n" "${1:-}" "${2:-}" "${3:-}")" fi } @@ -13103,13 +13109,13 @@ DebugInfoTabld() # Debug info tabulated. if [[ -z ${3:-} ]]; then # If $3 is nothing, then assume only 2 fields are required. - DebugAsInfo "$(printf "%${DEBUG_LOG_FIRST_COL_WIDTH}s: %${DEBUG_LOG_SECOND_COL_WIDTH}s\n" "${1:-}" "${2:-}")" + DebugAsInfo "$(printf "%${r_debug_log_first_column_width}s: %${r_debug_log_second_column_width}s\n" "${1:-}" "${2:-}")" elif [[ ${3:-} = ' ' ]]; then # If $3 is only a whitespace then print $2 with trailing colon and 'none' as third field. - DebugAsInfo "$(printf "%${DEBUG_LOG_FIRST_COL_WIDTH}s: %${DEBUG_LOG_SECOND_COL_WIDTH}s: none\n" "${1:-}" "${2:-}")" + DebugAsInfo "$(printf "%${r_debug_log_first_column_width}s: %${r_debug_log_second_column_width}s: none\n" "${1:-}" "${2:-}")" elif [[ ${3: -1} = ' ' ]]; then # If $3 has a trailing whitespace then print $3 without the trailing whitespace. - DebugAsInfo "$(printf "%${DEBUG_LOG_FIRST_COL_WIDTH}s: %${DEBUG_LOG_SECOND_COL_WIDTH}s: %-s\n" "${1:-}" "${2:-}" "$($SED_CMD 's| *$||' <<< "${3:-}")")" + DebugAsInfo "$(printf "%${r_debug_log_first_column_width}s: %${r_debug_log_second_column_width}s: %-s\n" "${1:-}" "${2:-}" "$($SED_CMD 's| *$||' <<< "${3:-}")")" else - DebugAsInfo "$(printf "%${DEBUG_LOG_FIRST_COL_WIDTH}s: %${DEBUG_LOG_SECOND_COL_WIDTH}s: %-s\n" "${1:-}" "${2:-}" "${3:-}")" + DebugAsInfo "$(printf "%${r_debug_log_first_column_width}s: %${r_debug_log_second_column_width}s: %-s\n" "${1:-}" "${2:-}" "${3:-}")" fi } @@ -13120,13 +13126,13 @@ DebugWarningTabld() # Debug warning tabulated. if [[ -z ${3:-} ]]; then # If $3 is nothing, then assume only 2 fields are required - DebugAsWarn "$(printf "%${DEBUG_LOG_FIRST_COL_WIDTH}s: %${DEBUG_LOG_SECOND_COL_WIDTH}s\n" "${1:-}" "${2:-}")" + DebugAsWarn "$(printf "%${r_debug_log_first_column_width}s: %${r_debug_log_second_column_width}s\n" "${1:-}" "${2:-}")" elif [[ ${3:-} = ' ' ]]; then # If $3 is only a whitespace then print $2 with trailing colon and 'none' as third field - DebugAsWarn "$(printf "%${DEBUG_LOG_FIRST_COL_WIDTH}s: %${DEBUG_LOG_SECOND_COL_WIDTH}s: none\n" "${1:-}" "${2:-}")" + DebugAsWarn "$(printf "%${r_debug_log_first_column_width}s: %${r_debug_log_second_column_width}s: none\n" "${1:-}" "${2:-}")" elif [[ ${3: -1} = ' ' ]]; then # If $3 has a trailing whitespace then print $3 without the trailing whitespace - DebugAsWarn "$(printf "%${DEBUG_LOG_FIRST_COL_WIDTH}s: %${DEBUG_LOG_SECOND_COL_WIDTH}s: %-s\n" "${1:-}" "${2:-}" "$($SED_CMD 's| *$||' <<< "${3:-}")")" + DebugAsWarn "$(printf "%${r_debug_log_first_column_width}s: %${r_debug_log_second_column_width}s: %-s\n" "${1:-}" "${2:-}" "$($SED_CMD 's| *$||' <<< "${3:-}")")" else - DebugAsWarn "$(printf "%${DEBUG_LOG_FIRST_COL_WIDTH}s: %${DEBUG_LOG_SECOND_COL_WIDTH}s: %-s\n" "${1:-}" "${2:-}" "${3:-}")" + DebugAsWarn "$(printf "%${r_debug_log_first_column_width}s: %${r_debug_log_second_column_width}s: %-s\n" "${1:-}" "${2:-}" "${3:-}")" fi } @@ -13137,13 +13143,13 @@ DebugErrorTabld() # Debug error tabulated. if [[ -z ${3:-} ]]; then # If $3 is nothing, then assume only 2 fields are required. - DebugAsError "$(printf "%${DEBUG_LOG_FIRST_COL_WIDTH}s: %${DEBUG_LOG_SECOND_COL_WIDTH}s\n" "${1:-}" "${2:-}")" + DebugAsError "$(printf "%${r_debug_log_first_column_width}s: %${r_debug_log_second_column_width}s\n" "${1:-}" "${2:-}")" elif [[ ${3:-} = ' ' ]]; then # If $3 is only a whitespace then print $2 with trailing colon and 'none' as third field. - DebugAsError "$(printf "%${DEBUG_LOG_FIRST_COL_WIDTH}s: %${DEBUG_LOG_SECOND_COL_WIDTH}s: none\n" "${1:-}" "${2:-}")" + DebugAsError "$(printf "%${r_debug_log_first_column_width}s: %${r_debug_log_second_column_width}s: none\n" "${1:-}" "${2:-}")" elif [[ ${3: -1} = ' ' ]]; then # If $3 has a trailing whitespace then print $3 without the trailing whitespace. - DebugAsError "$(printf "%${DEBUG_LOG_FIRST_COL_WIDTH}s: %${DEBUG_LOG_SECOND_COL_WIDTH}s: %-s\n" "${1:-}" "${2:-}" "$($SED_CMD 's| *$||' <<< "${3:-}")")" + DebugAsError "$(printf "%${r_debug_log_first_column_width}s: %${r_debug_log_second_column_width}s: %-s\n" "${1:-}" "${2:-}" "$($SED_CMD 's| *$||' <<< "${3:-}")")" else - DebugAsError "$(printf "%${DEBUG_LOG_FIRST_COL_WIDTH}s: %${DEBUG_LOG_SECOND_COL_WIDTH}s: %-s\n" "${1:-}" "${2:-}" "${3:-}")" + DebugAsError "$(printf "%${r_debug_log_first_column_width}s: %${r_debug_log_second_column_width}s: %-s\n" "${1:-}" "${2:-}" "${3:-}")" fi } @@ -13205,8 +13211,8 @@ FuncInit() # Debug function entry. - local -r VAR_NAME=${FUNCNAME[1]}_STARTNANOSECONDS - local var_safe_name=${VAR_NAME//[.-]/_} + local -r r_var_name=${FUNCNAME[1]}_STARTNANOSECONDS + local var_safe_name=${r_var_name//[.-]/_} var_safe_name=${var_safe_name//:/_} eval "$var_safe_name=$(ConvertNowToNanoseconds)" @@ -13220,8 +13226,8 @@ FuncExit() # Debug function exit. - local -r VAR_NAME=${FUNCNAME[1]}_STARTNANOSECONDS - local var_safe_name=${VAR_NAME//[.-]/_} + local -r r_var_name=${FUNCNAME[1]}_STARTNANOSECONDS + local var_safe_name=${r_var_name//[.-]/_} var_safe_name=${var_safe_name//:/_} DebugAsFuncEx "${1:-0}" "$(ConvertMillisecondsToFuncDuration "$(CalcMillisecondsDiffFromNanoseconds "${!var_safe_name}" "$(ConvertNowToNanoseconds)")")" @@ -13239,11 +13245,11 @@ FuncForkInit() # Redirect debug output to a temporary log, then add it to session log before exiting. This will keep action log progress in-order. original_sess_active_pathfile=$sess_active_pathfile - MakePath "$ACTION_LOGS_PATH" 'action logs' - sess_active_pathfile=$($MKTEMP_CMD "$ACTION_LOGS_PATH"/"${FUNCNAME[1]}"_XXXXXX) + MakePath "$r_action_logs_path" 'action logs' + sess_active_pathfile=$($MKTEMP_CMD "$r_action_logs_path"/"${FUNCNAME[1]}"_XXXXXX) - local -r VAR_NAME=${FUNCNAME[1]}_STARTNANOSECONDS - local var_safe_name=${VAR_NAME//[.-]/_} + local -r r_var_name=${FUNCNAME[1]}_STARTNANOSECONDS + local var_safe_name=${r_var_name//[.-]/_} var_safe_name=${var_safe_name//:/_} eval "$var_safe_name=$(ConvertNowToNanoseconds)" @@ -13256,8 +13262,8 @@ FuncForkExit() # Debug forked function exit. - local -r VAR_NAME=${FUNCNAME[1]}_STARTNANOSECONDS - local var_safe_name=${VAR_NAME//[.-]/_} + local -r r_var_name=${FUNCNAME[1]}_STARTNANOSECONDS + local var_safe_name=${r_var_name//[.-]/_} var_safe_name=${var_safe_name//:/_} SendActionStatus ex @@ -13601,7 +13607,7 @@ ShowAsProc() # $2 = trailing task (after the ellipsis) (optional). If specified, $useropt_terse will be ignored. # Inputs: (global) - # $CHARS_ELLIPSIS + # $r_chars_ellipsis # $useropt_terse # $useropt_verbose @@ -13612,9 +13618,9 @@ ShowAsProc() [[ -n ${2:-} ]] && b=${2:-} if [[ ${useropt_verbose:=false} = false && ${useropt_terse:=true} = true ]] || [[ ${useropt_verbose:=false} = false && -n ${2:-} ]]; then - OpStepClearWait "$(TextBrightYellow proc)" "$a $CHARS_ELLIPSIS $b" + OpStepClearWait "$(TextBrightYellow proc)" "$a $r_chars_ellipsis $b" else - OpStepClear "$(TextBrightYellow proc)" "$a $CHARS_ELLIPSIS $b" + OpStepClear "$(TextBrightYellow proc)" "$a $r_chars_ellipsis $b" fi WriteToLog proc "${a}${b}" @@ -13757,17 +13763,17 @@ ShowAsPercentProgress() # $5 = fail count # $6 = total count - local -r a=${1:-} + local -r r_a=${1:-} local -i b=${3:-0} local -i c=${4:-0} local -i d=${5:-0} local -i e=${6:-0} - local -r f=$(PercFrac "$b" "$c" "$d" "$e") + local -r r_f=$(PercFrac "$b" "$c" "$d" "$e") if [[ ${2:-} != long ]]; then - ShowAsProc "$a" "$f" + ShowAsProc "$r_a" "$r_f" else - ShowAsProcLong "$a" "$f" + ShowAsProcLong "$r_a" "$r_f" fi [[ $((b+c+d)) -ge $e ]] && sleep 0.5 @@ -13819,19 +13825,19 @@ ShowAsIterativeProgress() # $5 = suffix2 "packages" # $6 = expected action duration: 'long' (optional) 'short' (default) - local -r a=${1:?${FUNCNAME[0]}'()': undefined action} + local -r r_a=${1:?${FUNCNAME[0]}'()': undefined action} local -i b=${2:-0} - local -r c=${3:?${FUNCNAME[0]}'()': undefined suffix1} + local -r r_c=${3:?${FUNCNAME[0]}'()': undefined suffix1} local -i d=${4:-0} - local -r e=${5:?${FUNCNAME[0]}'()': undefined suffix2} + local -r r_e=${5:?${FUNCNAME[0]}'()': undefined suffix2} local f='' - f="$(TextBrightWhite "$b") ${c}$(Pluralise "$b") ($(TextBrightWhite "$d") ${e}$(Pluralise "$d"))" + f="$(TextBrightWhite "$b") ${r_c}$(Pluralise "$b") ($(TextBrightWhite "$d") ${r_e}$(Pluralise "$d"))" if [[ ${6:-short} != long ]]; then - ShowAsProc "$a" "$f" + ShowAsProc "$r_a" "$f" else - ShowAsProcLong "$a" "$f" + ShowAsProcLong "$r_a" "$f" fi return 0 @@ -14161,7 +14167,7 @@ Tableise() print cell[row,nf[row]] } - }' FS='|' OFS="$(printf "%$((COLUMN_SPACING))s")" + }' FS='|' OFS="$(printf "%$((r_report_column_spacing))s")" } @@ -14172,7 +14178,7 @@ StripANSICodes() if [[ ${sed_ext_regex_supported:=false} = true ]]; then echo -en "${1:-}" | /bin/sed -r 's/\x1b\[[0-9;]*m//g' # https://superuser.com/a/380778 - elif [[ -e /opt/bin/sed && -L /opt/etc/passwd ]]; then # Try to ensure Entware is active first. + elif [[ -e /opt/bin/sed && -L /opt/etc/passwd ]]; then # Try to ensure Entware is active first. echo -en "${1:-}" | /opt/bin/sed -r 's/\x1b\[[0-9;]*m//g' # https://superuser.com/a/380778 else echo -en "${1:-}" # Can't strip, so pass thru original message unaltered. @@ -14289,16 +14295,16 @@ LoadObjects() LoadLists if [[ ! -e $PWD/dont-refresh-objects ]]; then - if [[ ! -e $OBJECTS_PATHFILE ]] || ! IsThisFileRecent "$OBJECTS_PATHFILE" "$FILE_CHANGE_THRESHOLD_MINUTES"; then + if [[ ! -e $r_objects_pathfile ]] || ! IsThisFileRecent "$r_objects_pathfile" "$r_file_change_threshold_minutes"; then ShowAsProc 'download objects' - if $CURL_CMD --silent --fail "$OBJECTS_ARCHIVE_URL" > "$OBJECTS_ARCHIVE_PATHFILE"; then - $TAR_CMD --extract --gzip --no-same-owner --file="$OBJECTS_ARCHIVE_PATHFILE" --directory="$CACHE_PATH" + if $CURL_CMD --silent --fail "$r_objects_archive_url" > "$r_objects_archive_pathfile"; then + $TAR_CMD --extract --gzip --no-same-owner --file="$r_objects_archive_pathfile" --directory="$r_cache_path" fi fi fi - if [[ ! -e $OBJECTS_PATHFILE ]]; then + if [[ ! -e $r_objects_pathfile ]]; then ShowAsAbort 'objects missing' FuncExit 1; exit @@ -14306,11 +14312,11 @@ LoadObjects() ShowAsProc objects - . "$OBJECTS_PATHFILE" + . "$r_objects_pathfile" objects_loaded=true - readonly OBJECTS_VER - DebugVar OBJECTS_VER + readonly r_objects_version + DebugVar r_objects_version FuncExit @@ -14330,18 +14336,18 @@ LoadPackages() LoadObjects if [[ ! -e $PWD/dont-refresh-packages ]]; then - if [[ ! -e $PACKAGES_PATHFILE ]] || ! IsThisFileRecent "$PACKAGES_PATHFILE" "$FILE_CHANGE_THRESHOLD_MINUTES"; then + if [[ ! -e $r_packages_pathfile ]] || ! IsThisFileRecent "$r_packages_pathfile" "$r_file_change_threshold_minutes"; then ShowAsProc 'download QPKG list' - if $CURL_CMD --silent --fail "$PACKAGES_ARCHIVE_URL" > "$PACKAGES_ARCHIVE_PATHFILE"; then - $TAR_CMD --extract --gzip --no-same-owner --file="$PACKAGES_ARCHIVE_PATHFILE" --directory="$CACHE_PATH" + if $CURL_CMD --silent --fail "$r_packages_archive_url" > "$r_packages_archive_pathfile"; then + $TAR_CMD --extract --gzip --no-same-owner --file="$r_packages_archive_pathfile" --directory="$r_cache_path" fi InitQPKGsTiers fi fi - if [[ ! -e $PACKAGES_PATHFILE ]]; then + if [[ ! -e $r_packages_pathfile ]]; then ShowAsAbort 'QPKG list missing' FuncExit 1; exit @@ -14352,106 +14358,109 @@ LoadPackages() # Supported QPKG details - parallel arrays. # First, clear existing list arrays (if-any). - unset QPKG_ABBRVS - unset QPKG_APPL_AUTHOR - unset QPKG_APPL_AUTHOR_EMAIL - unset QPKG_APPL_VERSION - unset QPKG_ARCH - unset QPKG_AUTHOR - unset QPKG_AUTHOR_EMAIL - unset QPKG_CAN_BACKUP - unset QPKG_CAN_CLEAN - unset QPKG_CAN_LOG - unset QPKG_CAN_RESTART_TO_UPDATE - unset QPKG_CONFLICTS_WITH - unset QPKG_DEPENDS_ON - unset QPKG_DESC - unset QPKG_HASH - unset QPKG_MAX_OS_VERSION - unset QPKG_MIN_OS_VERSION - unset QPKG_MIN_RAM_KB - unset QPKG_NAME - unset QPKG_NOTE - unset QPKG_REQUIRES_IPKS - unset QPKG_TEST_FOR_ACTIVE - unset QPKG_URL - unset QPKG_VERSION - - PACKAGES_EPOCH=undefined + + unset r_qpkg_abbrvs + unset r_qpkg_appl_author + unset r_qpkg_appl_author_email + unset r_qpkg_appl_version + unset r_qpkg_arch + unset r_qpkg_author + unset r_qpkg_author_email + unset r_qpkg_can_backup + unset r_qpkg_can_clean + unset r_qpkg_can_log + unset r_qpkg_can_restart_to_update + unset r_qpkg_conflicts_with + unset r_qpkg_depends_on + unset r_qpkg_description + unset r_qpkg_hash + unset r_qpkg_is_sherpa_compatible + unset r_qpkg_max_os_version + unset r_qpkg_min_os_version + unset r_qpkg_min_ram_kb + unset r_qpkg_name + unset r_qpkg_note + unset r_qpkg_requires_ipks + unset r_qpkg_test_for_active + unset r_qpkg_url + unset r_qpkg_version + + r_packages_epoch=undefined # Second, create an index 0 element for each array. This element is used to indicate no matching QPKG when searching array. - QPKG_ABBRVS+=('') # If set, this package is user-installable, and these abbreviations may be used to specify app. - QPKG_APPL_AUTHOR+=('') # Name of the person or group maintaining the internal application. - QPKG_APPL_AUTHOR_EMAIL+=('') # Email address for the internal application developer. - QPKG_APPL_VERSION+=('') # The application version contained within this QPKG. QPKGs can update their own versions in 'qpkg.conf'. Use 'version' if the application version is the same as QPKG_VERSION. - QPKG_ARCH+=('') # QPKG supports this architecture. Use 'all' if every arch is supported. Use 'none' to disable installation. - QPKG_AUTHOR+=('') # Name of the person or group maintaining this QPKG. - QPKG_AUTHOR_EMAIL+=('') # Email address of the package maintainer. - QPKG_CAN_BACKUP+=('') # 'true'/'false': this QPKG service-script supports configuration 'backup' and 'restore' actions. - QPKG_CAN_CLEAN+=('') # 'true'/'false': the internal application can be cleaned and re-downloaded. - QPKG_CAN_LOG+=('') # 'true'/'false': the service-script has a log. - QPKG_CAN_RESTART_TO_UPDATE+=('') # 'true'/'false': the internal application can be updated by restarting the QPKG. - QPKG_CONFLICTS_WITH+=('') # Abort if these QPKGs are installed. - QPKG_DEPENDS_ON+=('') # Require these QPKGs to be installed first. Use 'none' if package is independent. Separate alternatives with '|'. - QPKG_DESC+=('') # QPKG description. - QPKG_HASH+=('') # MD5 checksum. - QPKG_IS_SHERPA_COMPATIBLE+=('') # 'true'/'false': the service-script responds to enhanced sherpa actions. - QPKG_MAX_OS_VERSION+=('') # The maximum QTS/QuTS version supported by this QPKG. - QPKG_MIN_OS_VERSION+=('') # The minimum QTS/QuTS version supported by this QPKG. - QPKG_MIN_RAM_KB+=('') # QPKG requires at-least this much RAM installed in kiB. Use 'none' if no minimum. - QPKG_NAME+=('') # Internal QPKG name. - QPKG_NOTE+=('') # An additional note to be prominently displayed. - QPKG_REQUIRES_IPKS+=('') # Require these IPKs to be installed first. - QPKG_TEST_FOR_ACTIVE+=('') # Test command-string to determine if this QPKG is active or inactive. Use 'builtin' if QPKG has its own status tests. - QPKG_URL+=('') # Remote URL. - QPKG_VERSION+=('') # QPKG version. + + r_qpkg_abbrvs+=('') # If set, this package is user-installable, and these abbreviations may be used to specify app. + r_qpkg_appl_author+=('') # Name of the person or group maintaining the internal application. + r_qpkg_appl_author_email+=('') # Email address for the internal application developer. + r_qpkg_appl_version+=('') # The application version contained within this QPKG. QPKGs can update their own versions in 'qpkg.conf'. Use 'version' if the application version is the same as $r_qpkg_version. + r_qpkg_arch+=('') # QPKG supports this architecture. Use 'all' if every arch is supported. Use 'none' to disable installation. + r_qpkg_author+=('') # Name of the person or group maintaining this QPKG. + r_qpkg_author_email+=('') # Email address of the package maintainer. + r_qpkg_can_backup+=('') # 'true'/'false': this QPKG service-script supports configuration 'backup' and 'restore' actions. + r_qpkg_can_clean+=('') # 'true'/'false': the internal application can be cleaned and re-downloaded. + r_qpkg_can_log+=('') # 'true'/'false': the service-script has a log. + r_qpkg_can_restart_to_update+=('') # 'true'/'false': the internal application can be updated by restarting the QPKG. + r_qpkg_conflicts_with+=('') # Abort if these QPKGs are installed. + r_qpkg_depends_on+=('') # Require these QPKGs to be installed first. Use 'none' if package is independent. Separate alternatives with '|'. + r_qpkg_description+=('') # QPKG description. + r_qpkg_hash+=('') # MD5 checksum. + r_qpkg_is_sherpa_compatible+=('') # 'true'/'false': the service-script responds to enhanced sherpa actions. + r_qpkg_max_os_version+=('') # The maximum QTS/QuTS version supported by this QPKG. + r_qpkg_min_os_version+=('') # The minimum QTS/QuTS version supported by this QPKG. + r_qpkg_min_ram_kb+=('') # QPKG requires at-least this much RAM installed in kiB. Use 'none' if no minimum. + r_qpkg_name+=('') # Internal QPKG name. + r_qpkg_note+=('') # An additional note to be prominently displayed. + r_qpkg_requires_ipks+=('') # Require these IPKs to be installed first. + r_qpkg_test_for_active+=('') # Test command-string to determine if this QPKG is active or inactive. Use 'builtin' if QPKG has its own status tests. + r_qpkg_url+=('') # Remote URL. + r_qpkg_version+=('') # QPKG version. # Third, source remaining elements from packages file. - . "$PACKAGES_PATHFILE" - # Add translated datetime to string. + . "$r_packages_pathfile" # Fourth, lock list arrays and values. - readonly QPKG_ABBRVS - readonly QPKG_APPL_AUTHOR - readonly QPKG_APPL_AUTHOR_EMAIL - readonly QPKG_APPL_VERSION - readonly QPKG_ARCH - readonly QPKG_AUTHOR - readonly QPKG_AUTHOR_EMAIL - readonly QPKG_CAN_BACKUP - readonly QPKG_CAN_CLEAN - readonly QPKG_CAN_LOG - readonly QPKG_CAN_RESTART_TO_UPDATE - readonly QPKG_CONFLICTS_WITH - readonly QPKG_DEPENDS_ON - readonly QPKG_DESC - readonly QPKG_HASH - readonly QPKG_IS_SHERPA_COMPATIBLE - readonly QPKG_MAX_OS_VERSION - readonly QPKG_MIN_OS_VERSION - readonly QPKG_MIN_RAM_KB - readonly QPKG_NAME - readonly QPKG_NOTE - readonly QPKG_REQUIRES_IPKS - readonly QPKG_TEST_FOR_ACTIVE - readonly QPKG_URL - readonly QPKG_VERSION + + readonly r_qpkg_abbrvs + readonly r_qpkg_appl_author + readonly r_qpkg_appl_author_email + readonly r_qpkg_appl_version + readonly r_qpkg_arch + readonly r_qpkg_author + readonly r_qpkg_author_email + readonly r_qpkg_can_backup + readonly r_qpkg_can_clean + readonly r_qpkg_can_log + readonly r_qpkg_can_restart_to_update + readonly r_qpkg_conflicts_with + readonly r_qpkg_depends_on + readonly r_qpkg_description + readonly r_qpkg_hash + readonly r_qpkg_is_sherpa_compatible + readonly r_qpkg_max_os_version + readonly r_qpkg_min_os_version + readonly r_qpkg_min_ram_kb + readonly r_qpkg_name + readonly r_qpkg_note + readonly r_qpkg_requires_ipks + readonly r_qpkg_test_for_active + readonly r_qpkg_url + readonly r_qpkg_version packages_loaded=true - readonly BASE_QPKG_CONFLICTS_WITH - readonly BASE_QPKG_WARNINGS - readonly ESSENTIAL_IPKS - readonly ESSENTIAL_PIPS - readonly EXCLUSION_PIPS - readonly MIN_PERL_VER - readonly MIN_PYTHON_VER - readonly PACKAGES_EPOCH + readonly r_base_qpkg_conflicts_with + readonly r_base_qpkg_warnings + readonly r_essential_ipks + readonly r_essential_pips + readonly r_exclusion_pips + readonly r_min_perl_version + readonly r_min_python_version + readonly r_packages_epoch - DebugVar PACKAGES_EPOCH + DebugVar r_packages_epoch - for qpkg_name in "${QPKG_NAME[@]}"; do # Ensure only first entry for each QPKG name is added to "GRall" array. + for qpkg_name in "${r_qpkg_name[@]}"; do # Ensure only first entry for each QPKG name is added to "GRall" array. [[ $previous = "$qpkg_name" ]] && continue || previous=$qpkg_name QPKGs-GRall:Add "$qpkg_name" done @@ -14467,13 +14476,13 @@ CaughtSIGINT() trap - SIGINT - [[ -n ${DISPLAY_INHIBIT_PATHFILE:-} ]] && [[ -d $($DIRNAME_CMD "$DISPLAY_INHIBIT_PATHFILE") ]] && /bin/touch "$DISPLAY_INHIBIT_PATHFILE" - [[ -n ${ACTION_ABORT_PATHFILE:-} ]] && [[ -d $($DIRNAME_CMD "$ACTION_ABORT_PATHFILE") ]] && /bin/touch "$ACTION_ABORT_PATHFILE" + [[ -n ${r_display_inhibit_pathfile:-} ]] && [[ -d $($DIRNAME_CMD "$r_display_inhibit_pathfile") ]] && /bin/touch "$r_display_inhibit_pathfile" + [[ -n ${r_action_abort_pathfile:-} ]] && [[ -d $($DIRNAME_CMD "$r_action_abort_pathfile") ]] && /bin/touch "$r_action_abort_pathfile" EraseThisLine ShowAsAbort 'caught SIGINT' CloseActionMsgPipe - # TODO: send SIGTERM to each PID in $ASYNC_PROCS_PATH here. + # TODO: send SIGTERM to each PID in $r_async_procs_path here. exit @@ -14490,7 +14499,7 @@ CaughtEXIT() } -readonly SCRIPT_STARTSECONDS=$(ConvertNowToSeconds) +readonly r_script_startseconds=$(ConvertNowToSeconds) trap CaughtSIGINT SIGINT trap CaughtEXIT EXIT diff --git a/workshop/ideas.txt b/workshop/ideas.txt index 0cbeb7f15..f46cd9ffa 100644 --- a/workshop/ideas.txt +++ b/workshop/ideas.txt @@ -1,3 +1,5 @@ +* Convert backup files report to autowidth. + * Check OOM killed pids against inactive daemons and report as-such on status report. * Takes 3.5 to 6 seconds to build QPKG states on Laura. diff --git a/workshop/issues.txt b/workshop/issues.txt index 6d3dd8673..ff33de494 100644 --- a/workshop/issues.txt +++ b/workshop/issues.txt @@ -1,5 +1,8 @@ Observed issues: + * If an action fork fails (such as with "unbound variable" error), main loop stalls. + - Must save stderr to file, and exit main loop. + * Will need a new method to detect if QTS 5.2.0 is still starting QPKGs due to async starts. * 'sherpa enable-auto-update active' is not running 'enable-auto-update' action.