Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iml-backup
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
iml-backup
Commits
ca2c6889
Commit
ca2c6889
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
update detector
parent
f96049ca
No related branches found
No related tags found
1 merge request
!129
Db Profiles
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
detector.sh
+28
-109
28 additions, 109 deletions
detector.sh
with
28 additions
and
109 deletions
detector.sh
+
28
−
109
View file @
ca2c6889
...
@@ -10,133 +10,52 @@
...
@@ -10,133 +10,52 @@
cd
$(
dirname
$0
)
cd
$(
dirname
$0
)
.
jobhelper.sh
||
exit
1
.
vendor/ini.class.sh
||
exit
1
.
vendor/ini.class.sh
||
exit
1
.
$(
dirname
$0
)
/includes/dbdetect.class.sh
DBD_BASEDIR
=
plugins/localdump/profiles/
declare
-A
DBD_PARAMS
DBD_DEBUG
=
0
DBD_DEBUG
=
0
# --------------------------------------------------------------------
USAGE
=
"Detect profiles for databases which are located in
#
$DBD_BASEDIR
.
# --------------------------------------------------------------------
# ---------- GETTER
function
dbdetect._wd
(){
test
"
$DBD_DEBUG
"
-eq
"1"
&&
echo
"DEBUG:
$*
"
}
function
dbdetect.getConfigs
(){
find
${
DBD_BASEDIR
}
-type
f
-name
"*.ini"
}
function
dbdetect.getType
(){
For detected profiles it shows its used parameters.
basename
"
$1
"
|
cut
-d
"_"
-f
1 |
sed
"s,
\.
ini
$,
,"
This script helps you to define / verify custom profiles.
}
function
dbdetect.getProfile
(){
basename
"
$1
"
|
cut
-d
"_"
-f
1- |
sed
"s,
\.
ini
$,
,"
}
SYNTAX:
$(
basename
$0
)
[OPTIONS] [FILTER]
function
dbdetect.exists
(){
OPTIONS:
local
_config
=
"
$1
"
-d|--debug show debug information
-h|--help Show this help
DBD_PARAMS
=
PARAMETERS:
FILTER a string / regex to filter profilenames.
local
_found
=
0
SXYNTAX:
$(
basename
$0
)
-d Test all profiles with debug output
# set file and inisection we read values from
$(
basename
$0
)
mysql Test profiles matching 'mysql' only
ini.set
"
$_config
"
"detect"
"
# --------------------------------------------------------------------
# --- check tcp
local
tcpport
;
tcpport
=
$(
ini.value
"tcp"
)
local
tcptarget
;
tcptarget
=
$(
ini.value
"tcp-target"
)
if
{
!
>
/dev/tcp/
$tcptarget
/
$tcpport
;
}
>
/dev/null 2>&1
;
then
# echo "No port tcp $tcpport available"
dbdetect._wd
"... No port tcp
$tcpport
available on
$tcptarget
"
return
1
fi
dbdetect._wd
"... Found tcp
$tcpport
on
$tcptarget
."
# --- check tcp process
local
tcpprocess
;
tcpprocess
=
$(
ini.value
"tcp-process"
)
if
[
-n
"
$tcpprocess
"
]
;
then
if
!
netstat
-tulpen
2>/dev/null |
grep
"^tcp.*:
${
tcpport
}
.*/
${
tcpprocess
}
"
>
/dev/null
;
then
# echo "No port tcp $tcpport available"
dbdetect._wd
"...
$tcpprocess
not found for tcp
${
tcpport
}
"
return
1
fi
dbdetect._wd
"... tcp
$tcpport
is used by
$tcpprocess
."
fi
# --- check binaries
local
binary
;
binary
=
$(
ini.value
"binary"
)
if
[
-n
"
${
binary
}
"
]
;
then
for
mybinary
in
$(
echo
"
${
binary
}
"
|
tr
","
" "
)
;
do
if
!
j_requireBinary
"
$mybinary
"
1
>
/dev/null 2>&1
;
then
dbdetect._wd
"... Missing binary:
${
mybinary
}
"
return
1
fi
dbdetect._wd
"... Binary:
${
mybinary
}
was found"
done
fi
# --- check process
local
process
;
process
=
$(
ini.value
"process"
)
if
[
-n
"
${
process
}
"
]
;
then
if
!
j_requireProcess
"
${
process
}
"
1
>
/dev/null
;
then
dbdetect._wd
"... Missing process:
${
process
}
"
return
1
fi
# if ! ps -eo command | grep -E "${process}" >/dev/null 2>&1; then
# dbdetect._wd "... Process ${process} was not found"
# return 1
# fi
dbdetect._wd
"... Process
${
process
}
was found"
fi
ini.set
"
$config
"
"set"
local
value
local
dbuser
=
$(
ini.value
"dbuser"
)
local
dbpassword
=
$(
ini.value
"dbpassword"
)
for
mykey
in
$(
ini.keys
)
do
# params = '--port={{tcp}} --password={{dbpassword}} --user={{dbuser}} --host={{tcp-target}}'
value
=
"
$(
ini.value
"
$mykey
"
)
"
value
=
"
${
value
//\{\{tcp\
}
\}
/
$tcpport
}"
value
=
"
${
value
//\{\{tcp-target\
}
\}
/
$tcptarget
}"
value
=
"
${
value
//\{\{dbuser\
}
\}
/
$dbuser
}"
value
=
"
${
value
//\{\{dbpassword\
}
\}
/
$dbpassword
}"
DBD_PARAMS[
$mykey
]=
"
$value
"
done
return
0
}
function
dbdetect.getParams
(){
echo
"
${
DBD_PARAMS
[
'params'
]
}
"
}
function
dbdetect.runas
(){
echo
"
${
DBD_PARAMS
[
'su'
]
}
"
}
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# MAIN
# MAIN
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
echo
echo
echo
" --==##|
POC *
DATABASE DETECTOR |##==-- "
echo
" --==##| DATABASE
PROFILE
DETECTOR |##==-- "
echo
echo
dbdetect._wd
while
[[
"$#"
-gt
0
]]
;
do case
$1
in
dbdetect._wd
"------"
-d
|
--debug
)
DBD_DEBUG
=
1
;;
-h
|
--help
)
echo
"
$USAGE
"
;
exit
0
;;
*
)
if
grep
"^-"
<<<
"
$1
"
>
/dev/null
;
then
echo
;
echo
"ERROR: Unknown parameter:
$1
"
;
echo
;
_showHelp
;
exit
2
fi
break
;
;;
esac
;
done
dbdetect._wd
"
>>>>>>>>>>
$module
"
dbdetect._wd
"
------
"
for
config
in
$(
dbdetect.getConfigs
)
;
do
for
config
in
$(
dbdetect.getConfigs
|
grep
"
${
1
:-
.
}
"
)
;
do
dbdetect._wd
"-----
$config
"
dbdetect._wd
"-----
$config
"
if
dbdetect.exists
$config
;
then
if
dbdetect.exists
$config
;
then
echo
"FOUND:
$config
"
echo
"FOUND:
$config
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment