Improvements in .templates/bin scripts:
* obsolescent egrep calls have removed; * /usr/local/bin has been added to PATH for cron calls.
This commit is contained in:
@@ -28,6 +28,9 @@
|
|||||||
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
||||||
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
||||||
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
|
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
|
||||||
|
# 2026-05-04 v1.1
|
||||||
|
# mod: the obsolescent egrep calls have been changed to POSIX grep -E calls.
|
||||||
|
# fix: /usr/local/bin was missing from the PATH for cron calls.
|
||||||
# 2023-06-18 v1.0
|
# 2023-06-18 v1.0
|
||||||
# new: forked from the "SMARTERP_skeleton" repository.
|
# new: forked from the "SMARTERP_skeleton" repository.
|
||||||
# mod: "instance" => "service"
|
# mod: "instance" => "service"
|
||||||
@@ -95,14 +98,14 @@ if [ -n "$CRON" ]; then
|
|||||||
# Ubuntu gets the initial environment from a separate file.
|
# Ubuntu gets the initial environment from a separate file.
|
||||||
if [ -r "/etc/environment" ]; then
|
if [ -r "/etc/environment" ]; then
|
||||||
# Extracts from this file, strips the right part w/o quotes.
|
# Extracts from this file, strips the right part w/o quotes.
|
||||||
includepath=$(cat "/etc/environment" | $(which egrep) '^PATH=')
|
includepath=$(cat "/etc/environment" | $(which grep) -E '^PATH=')
|
||||||
includepath=${includepath:5}
|
includepath=${includepath:5}
|
||||||
includepath="${includepath%\"}"; includepath="${includepath#\"}"
|
includepath="${includepath%\"}"; includepath="${includepath#\"}"
|
||||||
[[ -n "$includepath" ]] && PATH="$PATH:$includepath"
|
[[ -n "$includepath" ]] && PATH="$PATH:$includepath"
|
||||||
unset includepath
|
unset includepath
|
||||||
fi
|
fi
|
||||||
# We need the $HOME/bin as well.
|
# We need the $HOME/bin and /usr/local/bin paths as well.
|
||||||
PATH="$HOME/bin:$PATH"
|
PATH="$HOME/bin:/usr/local/bin:$PATH"
|
||||||
fi
|
fi
|
||||||
# We need also the sbin directories.
|
# We need also the sbin directories.
|
||||||
if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"; fi
|
if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"; fi
|
||||||
@@ -111,7 +114,6 @@ if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin
|
|||||||
#
|
#
|
||||||
TR=$(which tr 2>/dev/null)
|
TR=$(which tr 2>/dev/null)
|
||||||
if [ -z "$TR" ]; then echo "$MSG_MISSINGDEP tr."; exit 1 ; fi
|
if [ -z "$TR" ]; then echo "$MSG_MISSINGDEP tr."; exit 1 ; fi
|
||||||
#for item in basename df egrep head mail printf sleep
|
|
||||||
for item in basename printf sleep
|
for item in basename printf sleep
|
||||||
do
|
do
|
||||||
if [ -n "$(which $item)" ]
|
if [ -n "$(which $item)" ]
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
||||||
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
||||||
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
|
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
|
||||||
|
# 2026-05-04 v1.2
|
||||||
|
# fix: /usr/local/bin was missing from the PATH for cron calls.
|
||||||
# 2026-05-01 v1.1
|
# 2026-05-01 v1.1
|
||||||
# new: dnf support has been added for Oracle/RHEL compatibility.
|
# new: dnf support has been added for Oracle/RHEL compatibility.
|
||||||
# mod: the egrep calls have been replaced by grep -E command
|
# mod: the egrep calls have been replaced by grep -E command
|
||||||
@@ -66,8 +68,8 @@ if [ -n "$CRON" ]; then
|
|||||||
[[ -n "$includepath" ]] && PATH="$PATH:$includepath"
|
[[ -n "$includepath" ]] && PATH="$PATH:$includepath"
|
||||||
unset includepath
|
unset includepath
|
||||||
fi
|
fi
|
||||||
# We need the $HOME/bin as well.
|
# We need the $HOME/bin and /usr/local/bin paths as well.
|
||||||
PATH="$HOME/bin:$PATH"
|
PATH="$HOME/bin:/usr/local/bin:$PATH"
|
||||||
fi
|
fi
|
||||||
# We need also the sbin directories.
|
# We need also the sbin directories.
|
||||||
if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"; fi
|
if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"; fi
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
||||||
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
||||||
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
|
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
|
||||||
|
# 2026-05-04 v1.1
|
||||||
|
# mod: the obsolescent egrep calls have been changed to POSIX grep -E calls.
|
||||||
|
# fix: /usr/local/bin was missing from the PATH for cron calls.
|
||||||
# 2023-06-18 v1.0
|
# 2023-06-18 v1.0
|
||||||
# new: forked from the "SMARTERP_skeleton" repository.
|
# new: forked from the "SMARTERP_skeleton" repository.
|
||||||
# mod: "instance" => "service"
|
# mod: "instance" => "service"
|
||||||
@@ -45,14 +48,14 @@ if [ -n "$CRON" ]; then
|
|||||||
# Ubuntu gets the initial environment from a separate file.
|
# Ubuntu gets the initial environment from a separate file.
|
||||||
if [ -r "/etc/environment" ]; then
|
if [ -r "/etc/environment" ]; then
|
||||||
# Extracts from this file, strips the right part w/o quotes.
|
# Extracts from this file, strips the right part w/o quotes.
|
||||||
includepath=$(cat "/etc/environment" | $(which egrep) '^PATH=')
|
includepath=$(cat "/etc/environment" | $(which grep) -E '^PATH=')
|
||||||
includepath=${includepath:5}
|
includepath=${includepath:5}
|
||||||
includepath="${includepath%\"}"; includepath="${includepath#\"}"
|
includepath="${includepath%\"}"; includepath="${includepath#\"}"
|
||||||
[[ -n "$includepath" ]] && PATH="$PATH:$includepath"
|
[[ -n "$includepath" ]] && PATH="$PATH:$includepath"
|
||||||
unset includepath
|
unset includepath
|
||||||
fi
|
fi
|
||||||
# We need the $HOME/bin as well.
|
# We need the $HOME/bin and /usr/local/bin paths as well.
|
||||||
PATH="$HOME/bin:$PATH"
|
PATH="$HOME/bin:/usr/local/bin:$PATH"
|
||||||
fi
|
fi
|
||||||
# We need also the sbin directories.
|
# We need also the sbin directories.
|
||||||
if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"; fi
|
if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"; fi
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
||||||
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
||||||
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
|
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
|
||||||
|
# 2026-05-04 v1.1
|
||||||
|
# mod: the obsolescent egrep calls have been changed to POSIX grep -E calls.
|
||||||
|
# fix: /usr/local/bin was missing from the PATH for cron calls.
|
||||||
# 2023-06-18 v1.0
|
# 2023-06-18 v1.0
|
||||||
# new: forked from the "SMARTERP_skeleton" repository.
|
# new: forked from the "SMARTERP_skeleton" repository.
|
||||||
# mod: "instance" => "service"
|
# mod: "instance" => "service"
|
||||||
@@ -45,14 +48,14 @@ if [ -n "$CRON" ]; then
|
|||||||
# Ubuntu gets the initial environment from a separate file.
|
# Ubuntu gets the initial environment from a separate file.
|
||||||
if [ -r "/etc/environment" ]; then
|
if [ -r "/etc/environment" ]; then
|
||||||
# Extracts from this file, strips the right part w/o quotes.
|
# Extracts from this file, strips the right part w/o quotes.
|
||||||
includepath=$(cat "/etc/environment" | $(which egrep) '^PATH=')
|
includepath=$(cat "/etc/environment" | $(which grep) -E '^PATH=')
|
||||||
includepath=${includepath:5}
|
includepath=${includepath:5}
|
||||||
includepath="${includepath%\"}"; includepath="${includepath#\"}"
|
includepath="${includepath%\"}"; includepath="${includepath#\"}"
|
||||||
[[ -n "$includepath" ]] && PATH="$PATH:$includepath"
|
[[ -n "$includepath" ]] && PATH="$PATH:$includepath"
|
||||||
unset includepath
|
unset includepath
|
||||||
fi
|
fi
|
||||||
# We need the $HOME/bin as well.
|
# We need the $HOME/bin and /usr/local/bin paths as well.
|
||||||
PATH="$HOME/bin:$PATH"
|
PATH="$HOME/bin:/usr/local/bin:$PATH"
|
||||||
fi
|
fi
|
||||||
# We need also the sbin directories.
|
# We need also the sbin directories.
|
||||||
if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"; fi
|
if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"; fi
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
||||||
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
||||||
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
|
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
|
||||||
|
# 2026-05-04 v1.1
|
||||||
|
# mod: the obsolescent egrep calls have been changed to POSIX grep -E calls.
|
||||||
# 2023-06-18 v1.0
|
# 2023-06-18 v1.0
|
||||||
# new: forked from the "SMARTERP_skeleton" repository.
|
# new: forked from the "SMARTERP_skeleton" repository.
|
||||||
# 2022-11-03 v0.4
|
# 2022-11-03 v0.4
|
||||||
@@ -131,7 +133,7 @@ done; shift $((OPTIND -1))
|
|||||||
# Common dependencies.
|
# Common dependencies.
|
||||||
TR=$(which tr 2>/dev/null)
|
TR=$(which tr 2>/dev/null)
|
||||||
if [ -z "$TR" ]; then echo "$MSG_MISSINGDEP tr."; exit 1 ; fi
|
if [ -z "$TR" ]; then echo "$MSG_MISSINGDEP tr."; exit 1 ; fi
|
||||||
for item in basename df date dirname egrep grep gzip hostname id \
|
for item in basename df date dirname grep gzip hostname id \
|
||||||
pwd sed tail tee $additem
|
pwd sed tail tee $additem
|
||||||
do
|
do
|
||||||
if [ -n "$(which $item)" ]
|
if [ -n "$(which $item)" ]
|
||||||
@@ -346,8 +348,8 @@ else
|
|||||||
# 1st the schema with some arbitrary conversions.
|
# 1st the schema with some arbitrary conversions.
|
||||||
"$PG_DUMP" $CONNECT \
|
"$PG_DUMP" $CONNECT \
|
||||||
$PGDUMPACLS --schema-only -d "$PGDATABASE" | \
|
$PGDUMPACLS --schema-only -d "$PGDATABASE" | \
|
||||||
"$EGREP" -iv '^SET idle_in_transaction_session_timeout =' | \
|
"$GREP" -E -iv '^SET idle_in_transaction_session_timeout =' | \
|
||||||
"$EGREP" -iv '^SET default_table_access_method =' | \
|
"$GREP" -E -iv '^SET default_table_access_method =' | \
|
||||||
"$SED" 's/FUNCTION =/PROCEDURE = /' | \
|
"$SED" 's/FUNCTION =/PROCEDURE = /' | \
|
||||||
"$SED" "s/CURRENT_DATE/\('now'::text\)::date/g"
|
"$SED" "s/CURRENT_DATE/\('now'::text\)::date/g"
|
||||||
# 2nd the data as COPY statements.
|
# 2nd the data as COPY statements.
|
||||||
@@ -358,8 +360,8 @@ else
|
|||||||
# 1st the schema with some arbitrary conversions.
|
# 1st the schema with some arbitrary conversions.
|
||||||
"$PG_DUMP" $CONNECT \
|
"$PG_DUMP" $CONNECT \
|
||||||
$PGDUMPACLS --schema-only -d "$PGDATABASE" | \
|
$PGDUMPACLS --schema-only -d "$PGDATABASE" | \
|
||||||
"$EGREP" -iv '^SET idle_in_transaction_session_timeout =' | \
|
"$GREP" -E -iv '^SET idle_in_transaction_session_timeout =' | \
|
||||||
"$EGREP" -iv '^SET default_table_access_method =' | \
|
"$GREP" -E -iv '^SET default_table_access_method =' | \
|
||||||
"$SED" 's/FUNCTION =/PROCEDURE = /' | \
|
"$SED" 's/FUNCTION =/PROCEDURE = /' | \
|
||||||
"$SED" "s/CURRENT_DATE/\('now'::text\)::date/g" \
|
"$SED" "s/CURRENT_DATE/\('now'::text\)::date/g" \
|
||||||
>"$PGDUMPFILE" 2>>"$logfile"; result=$?
|
>"$PGDUMPFILE" 2>>"$logfile"; result=$?
|
||||||
|
|||||||
@@ -55,6 +55,8 @@
|
|||||||
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
||||||
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
||||||
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
|
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
|
||||||
|
# 2026-05-04 v1.4
|
||||||
|
# mod: the obsolescent egrep calls have been changed to POSIX grep -E calls.
|
||||||
# 2025-09-15 v1.3
|
# 2025-09-15 v1.3
|
||||||
# fix: now correctly handles "zero elements to keep" directives.
|
# fix: now correctly handles "zero elements to keep" directives.
|
||||||
# 2025-08-12 v1.2
|
# 2025-08-12 v1.2
|
||||||
@@ -127,7 +129,7 @@ done
|
|||||||
# Checks the dependencies.
|
# Checks the dependencies.
|
||||||
TR=$(which tr 2>/dev/null)
|
TR=$(which tr 2>/dev/null)
|
||||||
if [ -z "$TR" ]; then echo "$MSG_MISSINGDEP tr."; exit 1 ; fi
|
if [ -z "$TR" ]; then echo "$MSG_MISSINGDEP tr."; exit 1 ; fi
|
||||||
for item in basename date dirname egrep sed seq sort stat xargs
|
for item in basename date dirname grep sed seq sort stat xargs
|
||||||
do
|
do
|
||||||
if [ -n "$(which $item)" ]
|
if [ -n "$(which $item)" ]
|
||||||
then export $(echo $item | "$TR" '[:lower:]' '[:upper:]')=$(which $item)
|
then export $(echo $item | "$TR" '[:lower:]' '[:upper:]')=$(which $item)
|
||||||
@@ -219,11 +221,11 @@ function rotate_class {
|
|||||||
if [ -z "$CLASSES_PATTERN" ]; then
|
if [ -z "$CLASSES_PATTERN" ]; then
|
||||||
# All non-hidden files but no subfolders, symlinks, etc.
|
# All non-hidden files but no subfolders, symlinks, etc.
|
||||||
files=$(cd "$BACKUP_FOLDER"; \
|
files=$(cd "$BACKUP_FOLDER"; \
|
||||||
ls -1 -t --file-type | "$XARGS" -0 | "$EGREP" -v '[/=>@|$]$' )
|
ls -1 -t --file-type | "$XARGS" -0 | "$GREP" -E -v '[/=>@|$]$' )
|
||||||
else
|
else
|
||||||
# Non-hidden files (but no subfolders, symlinks, etc.) matching to the pattern.
|
# Non-hidden files (but no subfolders, symlinks, etc.) matching to the pattern.
|
||||||
files=$(cd "$BACKUP_FOLDER"; \
|
files=$(cd "$BACKUP_FOLDER"; \
|
||||||
ls -1 -t --file-type | "$XARGS" -0 | "$EGREP" "$CLASSES_PATTERN" )
|
ls -1 -t --file-type | "$XARGS" -0 | "$GREP" -E "$CLASSES_PATTERN" )
|
||||||
fi
|
fi
|
||||||
# Lack of files gives it up here.
|
# Lack of files gives it up here.
|
||||||
[[ -z "$files" ]] && return
|
[[ -z "$files" ]] && return
|
||||||
@@ -401,7 +403,7 @@ function rotate_classes {
|
|||||||
# Tries to validate the pattern.
|
# Tries to validate the pattern.
|
||||||
# Test calls simulate the later use.
|
# Test calls simulate the later use.
|
||||||
if [ -n "$CLASSES_PATTERN" ]; then
|
if [ -n "$CLASSES_PATTERN" ]; then
|
||||||
echo "test" | "$EGREP" "$CLASSES_PATTERN" >/dev/null 2>&1
|
echo "test" | "$GREP" -E "$CLASSES_PATTERN" >/dev/null 2>&1
|
||||||
[[ $? -gt 1 ]] && return # unusable
|
[[ $? -gt 1 ]] && return # unusable
|
||||||
fi
|
fi
|
||||||
# Does contain unexplored classifiers?
|
# Does contain unexplored classifiers?
|
||||||
@@ -413,7 +415,7 @@ function rotate_classes {
|
|||||||
# Needs further exploring.
|
# Needs further exploring.
|
||||||
# Non-hidden files (but no subfolders, symlinks, etc.) matching to the pattern.
|
# Non-hidden files (but no subfolders, symlinks, etc.) matching to the pattern.
|
||||||
local files=$(cd "$BACKUP_FOLDER"; \
|
local files=$(cd "$BACKUP_FOLDER"; \
|
||||||
ls -1 -t --file-type | "$XARGS" -0 | "$EGREP" "$CLASSES_PATTERN" )
|
ls -1 -t --file-type | "$XARGS" -0 | "$GREP" -E "$CLASSES_PATTERN" )
|
||||||
# Selects the qualifier substrings which actually have matching files.
|
# Selects the qualifier substrings which actually have matching files.
|
||||||
local classes=$(echo -e "$files" | "$SED" -E "s/$CLASSES_PATTERN/\1/" | "$SORT" -u)
|
local classes=$(echo -e "$files" | "$SED" -E "s/$CLASSES_PATTERN/\1/" | "$SORT" -u)
|
||||||
# Enumerates these qualifiers.
|
# Enumerates these qualifiers.
|
||||||
@@ -434,7 +436,7 @@ if [ -z "$CLASSES_PATTERN" ]; then
|
|||||||
rotate_class
|
rotate_class
|
||||||
else
|
else
|
||||||
# Tries to validate the pattern (loosely).
|
# Tries to validate the pattern (loosely).
|
||||||
echo "test" | "$EGREP" "$CLASSES_PATTERN" >/dev/null 2>&1
|
echo "test" | "$GREP" -E "$CLASSES_PATTERN" >/dev/null 2>&1
|
||||||
[[ $? -gt 1 ]] && echo -e "$MSG_BADPATTERN $CLASSES_PATTERN" >&2 && exit 1
|
[[ $? -gt 1 ]] && echo -e "$MSG_BADPATTERN $CLASSES_PATTERN" >&2 && exit 1
|
||||||
# Seems to be valid, go on!
|
# Seems to be valid, go on!
|
||||||
rotate_classes "$CLASSES_PATTERN"
|
rotate_classes "$CLASSES_PATTERN"
|
||||||
|
|||||||
Reference in New Issue
Block a user