- Default library:

- Normalize some function names: version_print(), help_print(), str_quote(), str_escape(), echo_line(), echo_error() & cmd_exec()
    - Normalise some global variables: VERBOSE & DRY_RUN,
    - Add default options: errexit, pipefail & nounset,
    - Add GPL headers,
- ISL:
    - Move ISL to docker_tools.
This commit is contained in:
2026-03-28 17:54:27 +01:00
parent 97c05c4606
commit 0be015d53f
5 changed files with 161 additions and 236 deletions

View File

@@ -1,3 +1,17 @@
------------------------------------------------------------------------------------------------------------------------------------
Rx3-Base V 1.1.0 - A. GIBERT - 2026/03/28
------------------------------------------------------------------------------------------------------------------------------------
- Default library:
- Normalize some function names: version_print(), help_print(), str_quote(), str_escape(), echo_line(), echo_error() & cmd_exec()
- Normalise some global variables: VERBOSE & DRY_RUN,
- Add default options: errexit, pipefail & nounset,
- Add GPL headers,
- ISL:
- Move ISL to docker_tools.
------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------
Rx3-Base V 1.0.0 - A. GIBERT - 2026/03/17 Rx3-Base V 1.0.0 - A. GIBERT - 2026/03/17
------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------

View File

@@ -1,6 +1,31 @@
#-----------------------------------------------------------------------------------------------------------------------------------
#
# Rx3 Base
#
# Copyright (C) 2026 Arnaud G. GIBERT
# mailto:arnaud@rx3.net
#
# This is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; If not, see
# <https://www.gnu.org/licenses/>.
#
#-----------------------------------------------------------------------------------------------------------------------------------
%define name rx3-base %define name rx3-base
%define version 1.0.0 %define version 1.1.0
%define release %mkrel 1rx3 %define release %mkrel 1rx3
@@ -98,5 +123,8 @@ cp usr/lib/rx3/*.bash %{buildroot}%{_prefix}/lib/rx3
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
%changelog %changelog
* Sat Mar 28 2026 Arnaud G. GIBERT <arnaud@rx3.net> - 1.1.0-1rx3.mga9
- Update to 1.1.0
* Tue Mar 17 2026 Arnaud G. GIBERT <arnaud@rx3.net> - 1.0.0-1rx3.mga9 * Tue Mar 17 2026 Arnaud G. GIBERT <arnaud@rx3.net> - 1.0.0-1rx3.mga9
- Initial release - Initial release

View File

@@ -1,5 +1,29 @@
#!/bin/bash
#-----------------------------------------------------------------------------------------------------------------------------------
#
# Rx3 Base Profile
#
# Copyright (C) 2000-2026 Arnaud G. GIBERT
# mailto:arnaud@rx3.net
#
# This is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; If not, see
# <https://www.gnu.org/licenses/>.
#
#-----------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------
# Global Variable # Global Variable
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
@@ -11,6 +35,7 @@ export EDITOR=emacs
#-----------------------------------------------------------------------------------------------------------------------------------
# CatVal # CatVal
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
@@ -29,29 +54,7 @@ export -f cateval
# Print
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
print()
{
if [[ "$1" == "-i" ]]
then
shift
str="%s"'\\n'
else
str="%s"'\n'
fi
printf "${str}" "$*"
}
export -f print
# File Enable # File Enable
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
@@ -81,15 +84,17 @@ export -f file_enable
#-----------------------------------------------------------------------------------------------------------------------------------
# Include # Include
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
. /usr/lib/rx3/isl.bash # None
#-----------------------------------------------------------------------------------------------------------------------------------
# Aliases # Aliases
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------

View File

@@ -1,4 +1,26 @@
#!/bin/bash #!/bin/bash
#-----------------------------------------------------------------------------------------------------------------------------------
#
# Default Library
#
# Copyright (C) 2017-2026 Arnaud G. GIBERT
# mailto:arnaud@rx3.net
#
# This is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; If not, see
# <https://www.gnu.org/licenses/>.
#
#-----------------------------------------------------------------------------------------------------------------------------------
if [[ "${DEFAULT_BASH}" != "" ]] if [[ "${DEFAULT_BASH}" != "" ]]
then then
@@ -9,69 +31,84 @@ fi
# Global Variable
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
declare -g LOG_FILE=""
declare -g LOG_LOCK=""
declare -g LOG_ECHO=""
declare -g LOG_TRACE="DISABLED"
# Default Options # Default Options
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
set -o errexit -o pipefail -o nounset
shopt -s extglob shopt -s extglob
# Print Version #-----------------------------------------------------------------------------------------------------------------------------------
# Global Variable
#-----------------------------------------------------------------------------------------------------------------------------------
declare -g VERSION=""
declare -g NAME=""
declare -g HELP=""
declare -g VERBOSE="FALSE"
declare -g DRY_RUN="FALSE"
declare -g LOG_FILE=""
declare -g LOG_LOCK=""
declare -g LOG_ECHO=""
declare -g LOG_TRACE="DISABLED"
#-----------------------------------------------------------------------------------------------------------------------------------
# Version Print
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
version_print() version_print()
{ {
echo "$VERSION" | sed -e 's/.*: //' -e 's/-/ /' -e 's/_/\./g' -e 's/\$$//' # echo "${VERSION}" | sed -e 's/.*: //' -e 's/-/ /' -e 's/_/\./g' -e 's/\$$//'
echo "${NAME} V${VERSION}"
} }
# Prin Help #-----------------------------------------------------------------------------------------------------------------------------------
# Help Print
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
help_print() help_print()
{ {
echo "${NAME} ${HELP}" echo "${NAME} ${HELP}"
} }
# Quote Str #-----------------------------------------------------------------------------------------------------------------------------------
# Str Quote
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
quote_str() str_quote()
{ {
local quoted=${1//\'/\'\\\'\'} local quoted=${1//\'/\'\\\'\'}
printf "'%s'" "$quoted"
printf "'%s'" "${quoted}"
} }
# Escape Str #-----------------------------------------------------------------------------------------------------------------------------------
# Str Escape
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
escape_str() str_escape()
{ {
echo "$*" | sed -e "s/\"/\\\\\"/g" echo "$*" | sed -e "s/\"/\\\\\"/g"
} }
@@ -80,14 +117,16 @@ escape_str()
# Line Echo #-----------------------------------------------------------------------------------------------------------------------------------
# Echo Line
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
line_echo() echo_line()
{ {
string="$1" local string="$1"
count="$2" local count="$2"
echo -en "\e[2K\r" echo -en "\e[2K\r"
if [[ "${count}" != "" ]] if [[ "${count}" != "" ]]
@@ -101,10 +140,11 @@ line_echo()
# Err Echo #-----------------------------------------------------------------------------------------------------------------------------------
# Echo Error
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
err_echo() echo_error()
{ {
echo "$@" 1>&2 echo "$@" 1>&2
} }
@@ -113,20 +153,21 @@ err_echo()
# Exec CMD #-----------------------------------------------------------------------------------------------------------------------------------
# Cmd Exec
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
exec_cmd() cmd_exec()
{ {
cmd="$1" local cmd="$1"
if [[ "${verbose}" == "true" ]] if [[ "${VERBOSE}" == "TRUE" ]]
then then
echo "${cmd}" 1>&2 echo "${cmd}" 1>&2
fi fi
if [[ "${dry_run}" != "true" ]] if [[ "${DRY_RUN}" != "TRUE" ]]
then then
eval "${cmd}" eval "${cmd}"
fi fi
@@ -136,7 +177,7 @@ exec_cmd()
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
# tab_assign # Tab Assign
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
tab_assign() tab_assign()
@@ -159,7 +200,7 @@ tab_assign()
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
# var_assign # Var Assign
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
var_assign() var_assign()
@@ -187,7 +228,7 @@ var_assign()
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
# file_dir_init # File Dir Init
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
file_dir_init() file_dir_init()
@@ -230,7 +271,7 @@ file_dir_init()
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
# file_lock # File Lock
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
file_lock() file_lock()
@@ -267,7 +308,7 @@ file_lock()
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
# file_unlock # File Unlock
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
file_unlock() file_unlock()
@@ -290,7 +331,7 @@ file_unlock()
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
# log_set # Log Set
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
log_set() log_set()
@@ -301,14 +342,14 @@ log_set()
local log_trace="$4" local log_trace="$4"
LOG_FILE="${log_file}" LOG_FILE="${log_file}"
LOG_LOCK="${lock_file}" LOG_LOCK="${lock_file}"
LOG_ECHO="${echo_function}" LOG_ECHO="${echo_function}"
if [[ ${log_trace} != "" ]] if [[ ${log_trace} != "" ]]
then then
LOG_TRACE="${log_trace}" LOG_TRACE="${log_trace}"
fi fi
} }
@@ -316,7 +357,7 @@ log_set()
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
# log_print # Log Print
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
log_print() log_print()
@@ -356,7 +397,7 @@ log_print()
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
# log_trace # Log Trace
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
log_trace() log_trace()
@@ -369,7 +410,7 @@ log_trace()
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
# log_info # Log Info
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
log_info() log_info()
@@ -382,7 +423,7 @@ log_info()
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
# log_warning # Log Warning
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
log_warning() log_warning()
@@ -395,7 +436,7 @@ log_warning()
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
# log_error # Log Error
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
log_error() log_error()

View File

@@ -1,163 +0,0 @@
#-----------------------------------------------------------------------------------------------------------------------------------
# ISL: Image Stack Log
#-----------------------------------------------------------------------------------------------------------------------------------
# Global Variable
#-----------------------------------------------------------------------------------------------------------------------------------
export ISL_FILE=/etc/img_stack_log
# ISL Add
#-----------------------------------------------------------------------------------------------------------------------------------
isl_add()
{
url="$1"
reg=${url%%/*}
if [[ "${reg}" == *.* ]]
then
url=${url#*/}
else
reg="-"
fi
tag=${url/*:}
name=${url%:*}
if [[ "${tag}" == "${name}" ]]
then
echo "Bad tag format in URL!"
return 1
fi
ts=$(date -u +"%Y/%m/%d %H:%M:%S")
if [[ ! -e ${ISL_FILE} ]]
then
id=1
else
id=$(( $(wc -l <${ISL_FILE}) + 1))
fi
str="${id} ${ts} ${reg} ${name} ${tag}"
if [[ $id == "1" ]]
then
echo "${str}" >${ISL_FILE}
else
sed -i '1i\'"${str}" ${ISL_FILE}
fi
}
export -f isl_add
# ISL Top
#-----------------------------------------------------------------------------------------------------------------------------------
isl_top()
{
line=$( head -1 ${ISL_FILE})
if [[ "$1" == "-i" ]]
then
set ${line}
echo "$5:$6"
else
echo "${line}"
fi
}
export -f isl_top
# ISL Cat
#-----------------------------------------------------------------------------------------------------------------------------------
isl_cat()
{
if [[ "$1" == "-r" ]]
then
tac ${ISL_FILE}
else
cat ${ISL_FILE}
fi
}
export -f isl_cat
# ISL HTML Dump
#-----------------------------------------------------------------------------------------------------------------------------------
isl_html_dump()
{
r_flag=""
i_flag=""
while [[ $# -gt 0 ]]
do
if [[ "$1" == "-r" ]]
then
r_flag="$1"
else
if [[ "$1" == "-i" ]]
then
i_flag="-i"
fi
fi
shift
done
i=1
isl_cat "${r_flag}" | while read line
do
set $line
if [[ $(( $i % 2)) -eq 0 ]]
then
print "${i_flag}" ' <tr class="shade">'
else
print "${i_flag}" " <tr>"
fi
j=1
while [[ $j -lt 7 ]]
do
if [[ "$j" == "1" ]]
then
print "${i_flag}" " <th>${!j}</th>"
else
print "${i_flag}" " <td>${!j}</td>"
fi
j=$(( $j + 1))
done
print "${i_flag}" " </tr>"
i=$(( $i + 1))
done
}
export -f isl_html_dump