Skip to content
Snippets Groups Projects

Db Profiles

Merged Hahn Axel (hahn) requested to merge db-detector into master
9 files
+ 55
34
Compare changes
  • Side-by-side
  • Inline

Files

+ 12
4
@@ -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}"
Loading