Skip to content
Snippets Groups Projects
Commit d2ebb15c authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

move included files into subfolder

parent e479a50e
No related branches found
No related tags found
1 merge request!129Db Profiles
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
# 2022-11-04 ah v1.2 rename hooks # 2022-11-04 ah v1.2 rename hooks
# ================================================================================ # ================================================================================
. $( dirname "$0" )/jobhelper.sh . $( dirname "$0" )/includes/jobhelper.sh
. `dirname $0`/inc_bash.sh . `dirname $0`/includes/inc_bash.sh
typeset -i rcBackup=0 typeset -i rcBackup=0
typeset -i rcTransfer=0 typeset -i rcTransfer=0
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
# 2023-09-04 ah v1.6 fix perfdata dirs-del= # 2023-09-04 ah v1.6 fix perfdata dirs-del=
# ============================================================================== # ==============================================================================
. $(dirname $0)/jobhelper.sh . $(dirname $0)/includes/jobhelper.sh
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# CONFIG # CONFIG
......
#!/bin/bash #!/bin/bash
# ==================================================================== # ====================================================================
# #
# P O C * Detect a database type # Detect a database type
# #
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# ah: <www.axel-hahn.de> # ah: <www.axel-hahn.de>
...@@ -11,10 +11,12 @@ ...@@ -11,10 +11,12 @@
cd $( dirname $0 ) cd $( dirname $0 )
. vendor/ini.class.sh || exit 1 . vendor/ini.class.sh || exit 1
. vendor/color.class.sh || exit 1
. $(dirname $0)/includes/dbdetect.class.sh . $(dirname $0)/includes/dbdetect.class.sh
DBD_DEBUG=0 DBD_DEBUG=0
showInfos=0
USAGE="Detect profiles for databases which are located in USAGE="Detect profiles for databases which are located in
$DBD_BASEDIR. $DBD_BASEDIR.
...@@ -24,15 +26,17 @@ This script helps you to define / verify custom profiles. ...@@ -24,15 +26,17 @@ This script helps you to define / verify custom profiles.
SYNTAX: $( basename $0) [OPTIONS] [FILTER] SYNTAX: $( basename $0) [OPTIONS] [FILTER]
OPTIONS: OPTIONS:
-d|--debug show debug information
-h|--help Show this help -h|--help Show this help
-i|--infos Show infos about detected profiles
-v|--verbose Show debug information during detection. This helps to find
out why a profile was skipped.
PARAMETERS: PARAMETERS:
FILTER a string / regex to filter profilenames. FILTER a string / regex to filter profilenames.
SXYNTAX: SXYNTAX:
$( basename $0) -d Test all profiles with debug output
$( basename $0) mysql Test profiles matching 'mysql' only $( basename $0) mysql Test profiles matching 'mysql' only
$( basename $0) -v Test all profiles with debug output
" "
# -------------------------------------------------------------------- # --------------------------------------------------------------------
...@@ -40,36 +44,43 @@ SXYNTAX: ...@@ -40,36 +44,43 @@ SXYNTAX:
# MAIN # MAIN
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
echo echo ';' >&2
echo " --==##| DATABASE PROFILE DETECTOR |##==-- " echo '; --==##| DATABASE PROFILE DETECTOR |##==-- '
echo echo ';' >&2
while [[ "$#" -gt 0 ]]; do case $1 in while [ "$#" -gt 0 ]; do case $1 in
-d|--debug) DBD_DEBUG=1;;
-h|--help) echo "$USAGE"; exit 0;; -h|--help) echo "$USAGE"; exit 0;;
-i|--infos) showInfos=1; shift 1;;
-v|--verbose) DBD_DEBUG=1; shift 1;;
*) if grep "^-" <<< "$1" >/dev/null ; then *) if grep "^-" <<< "$1" >/dev/null ; then
echo; echo "ERROR: Unknown parameter: $1"; echo; _showHelp; exit 2 echo; echo "ERROR: Unknown parameter: $1"; echo; echo "$USAGE"; exit 2
fi fi
break; break;
;; ;;
esac; done esac; done
sFilter="${1:-.}"
test ! "${sFilter}" = "." && ( echo -n "Filter enabled: "; color.echo "blue" "${sFilter}"; echo ';' >&2)
dbdetect._wd "------" dbdetect._wd "------"
for config in $(dbdetect.getConfigs | grep "${1:-.}"); do for config in $(dbdetect.getConfigs | grep "${sFilter}"); do
dbdetect._wd "----- $config" dbdetect._wd "----- $config"
if dbdetect.exists $config; then if dbdetect.exists $config; then
echo "FOUND: $config" color.print "green" "FOUND"; echo ": $config"
if [ "$showInfos" -gt "0" ]; then
echo " Type : $( dbdetect.getType $config )" echo " Type : $( dbdetect.getType $config )"
echo " Target dir : $( dbdetect.getProfile $config )" echo " Target dir : $( dbdetect.getProfile $config )"
echo " runas : $( dbdetect.runas )" echo " runas : $( dbdetect.runas )"
echo " Params : $( dbdetect.getParams )" echo " Params : $( dbdetect.getParams )"
echo echo " Env : $( dbdetect.setenv )"
echo " Files : $( dbdetect.getFiles | grep -c '.' )"
echo ';'
fi
else else
echo "SKIP : $config" echo "SKIP : $config"
fi fi
dbdetect._wd dbdetect._wd
done done
echo
# -------------------------------------------------------------------- # --------------------------------------------------------------------
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
# it analyzes all ini files with database profiles and sets # it analyzes all ini files with database profiles and sets
# variables / environment to perform database backup/ restore # variables / environment to perform database backup/ restore
# #
# Remark:
# The script that sources this file must source vendor/ini.class.sh
# before using these functions.
#
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# ====================================================================== # ======================================================================
...@@ -24,13 +28,13 @@ declare -A DBD_PARAMS ...@@ -24,13 +28,13 @@ declare -A DBD_PARAMS
# write debug output if DBD_DEBUG is enabled # write debug output if DBD_DEBUG is enabled
# param string text to show # param string text to show
function dbdetect._wd(){ function dbdetect._wd(){
test "$DBD_DEBUG" -eq "1" && echo "DEBUG: $*" >&2 test "$DBD_DEBUG" -ne "0" && color.echo "darkgray" "DEBUG: $*" >&2
} }
# get a list of all config files # get a list of all config files
# param string full path of ini file # param string full path of ini file
function dbdetect.getConfigs(){ function dbdetect.getConfigs(){
find ${DBD_BASEDIR} -type f -name "*.ini" find ${DBD_BASEDIR} -type f -name "*.ini" | sort
} }
# get type from given ini file # get type from given ini file
...@@ -115,12 +119,16 @@ function dbdetect.exists(){ ...@@ -115,12 +119,16 @@ function dbdetect.exists(){
for myfile in $( ini.value "file[]" ) for myfile in $( ini.value "file[]" )
do do
if ! file -b "${myfile}" | grep -i "$filetype" >/dev/null; then if ! file -b "${myfile}" | grep -i "$filetype" >/dev/null; then
dbdetect._wd "... File ${myfile} is no type $filetype" dbdetect._wd "... File ${myfile} is not of type $filetype"
return 1 return 1
fi fi
dbdetect._wd "... File ${myfile} is type $filetype" dbdetect._wd "... File ${myfile} is type $filetype"
myfiles+="${myfile}|" myfiles+="${myfile}|"
done done
if [ -z "${myfiles}" ]; then
dbdetect._wd "... No files for type [${filetype}] were added"
return 1
fi
fi fi
# --- OK, everything was found ... we initialize it # --- OK, everything was found ... we initialize it
...@@ -135,7 +143,7 @@ function dbdetect.exists(){ ...@@ -135,7 +143,7 @@ function dbdetect.exists(){
for mykey in su env params for mykey in su env params
do do
value="$( ini.value "$mykey" )" value="$( ini.value "$mykey" )"
value="${value//\{\{tcp\}\}/$tcpport}" value="${value//\{\{tcp-port\}\}/$tcpport}"
value="${value//\{\{tcp-target\}\}/$tcptarget}" value="${value//\{\{tcp-target\}\}/$tcptarget}"
value="${value//\{\{dbuser\}\}/$dbuser}" value="${value//\{\{dbuser\}\}/$dbuser}"
value="${value//\{\{dbpassword\}\}/$dbpassword}" value="${value//\{\{dbpassword\}\}/$dbpassword}"
......
File moved
File moved
...@@ -31,10 +31,12 @@ ...@@ -31,10 +31,12 @@
# CONFIG VARS # CONFIG VARS
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
. $(dirname $0)/jobhelper.sh
. $(dirname $0)/inc_bash.sh
. $(dirname $0)/vendor/ini.class.sh . $(dirname $0)/vendor/ini.class.sh
. $(dirname $0)/vendor/color.class.sh
. $(dirname $0)/includes/jobhelper.sh
. $(dirname $0)/includes/inc_bash.sh | exit 1
. $(dirname $0)/includes/dbdetect.class.sh . $(dirname $0)/includes/dbdetect.class.sh
# if [ -r ~/.backup.conf ]; then # if [ -r ~/.backup.conf ]; then
......
...@@ -33,8 +33,8 @@ ...@@ -33,8 +33,8 @@
# . `dirname $0`/inc_config.sh # . `dirname $0`/inc_config.sh
. $(dirname $0)/jobhelper.sh . $(dirname $0)/includes/jobhelper.sh
. $(dirname $0)/inc_bash.sh . $(dirname $0)/includes/inc_bash.sh
# --- load a transfer plugin # --- load a transfer plugin
STORAGE_BIN=$(_j_getvar ${STORAGEFILE} "bin") STORAGE_BIN=$(_j_getvar ${STORAGEFILE} "bin")
......
...@@ -48,8 +48,8 @@ ...@@ -48,8 +48,8 @@
# . `dirname $0`/inc_config.sh # . `dirname $0`/inc_config.sh
. $(dirname $0)/jobhelper.sh . $(dirname $0)/includes/jobhelper.sh
. $(dirname $0)/inc_bash.sh . $(dirname $0)/includes/inc_bash.sh
typeset -i rc=0 typeset -i rc=0
typeset -i doBackup=1 typeset -i doBackup=1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment