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
f7f878f6
Commit
f7f878f6
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
shell fixes in dbdetect functions
parent
0e96a36c
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
includes/dbdetect.class.sh
+29
-26
29 additions, 26 deletions
includes/dbdetect.class.sh
with
29 additions
and
26 deletions
includes/dbdetect.class.sh
+
29
−
26
View file @
f7f878f6
...
@@ -11,6 +11,9 @@
...
@@ -11,6 +11,9 @@
# before using these functions.
# before using these functions.
#
#
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# ah - Axel Hahn <axel.hahn@unibe.ch>
#
# 2024-03-15 ah v1.0 first public version
# ======================================================================
# ======================================================================
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
...
@@ -20,7 +23,7 @@
...
@@ -20,7 +23,7 @@
DBD_BASEDIR
=
plugins/localdump/profiles
DBD_BASEDIR
=
plugins/localdump/profiles
declare
-A
DBD_PARAMS
declare
-A
DBD_PARAMS
DBD_INI
=
DBD_INI
FILE
=
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
...
@@ -37,19 +40,19 @@ function dbdetect._wd(){
...
@@ -37,19 +40,19 @@ function dbdetect._wd(){
# param string regex to find in ps -ef output
# param string regex to find in ps -ef output
# param bool flag to skip; default: none = abort on miss
# param bool flag to skip; default: none = abort on miss
function
dbdetect._requireProcess
(){
function
dbdetect._requireProcess
(){
# echo "CHECK process $1"
# echo "CHECK process $1"
# ps -ef | grep -v grep | grep -E "$1" >/dev/null
# ps -ef | grep -v grep | grep -E "$1" >/dev/null
pgrep
-l
"
$1
"
>
/dev/null
pgrep
-l
"
$1
"
>
/dev/null
rcself
=
$?
rcself
=
$?
if
[
$rcself
-ne
0
]
;
then
if
[
$rcself
-ne
0
]
;
then
rc
=
$rc
+
$rcself
rc
=
$rc
+
$rcself
echo
"INFO: missing process
$1
"
echo
"INFO: missing process
$1
"
if
[
-z
"
$2
"
]
;
then
if
[
-z
"
$2
"
]
;
then
exit
4
exit
4
fi
return
1
fi
fi
return
1
return
0
fi
return
0
}
}
# get a list of all config files
# get a list of all config files
...
@@ -77,7 +80,7 @@ function dbdetect.validate(){
...
@@ -77,7 +80,7 @@ function dbdetect.validate(){
local
_config
=
"
${
1
:-
$DBD_INIFILE
}
"
local
_config
=
"
${
1
:-
$DBD_INIFILE
}
"
# show errors in profile ini files
# show errors in profile ini files
ini.validate
"
$_config
"
"
$(
dirname
$0
)
/includes/dbdetect_validate_profile_ini.sh"
0
&&
dbdetect._wd
"OK: Validation of '
$_config
' successful"
ini.validate
"
$_config
"
"
$(
dirname
"
$0
"
)
/includes/dbdetect_validate_profile_ini.sh"
0
&&
dbdetect._wd
"OK: Validation of '
$_config
' successful"
}
}
# check if the requirements for a database match
# check if the requirements for a database match
...
@@ -85,7 +88,7 @@ function dbdetect.validate(){
...
@@ -85,7 +88,7 @@ function dbdetect.validate(){
function
dbdetect.exists
(){
function
dbdetect.exists
(){
local
_config
=
"
$1
"
local
_config
=
"
$1
"
DBD_PARAMS
=
DBD_PARAMS
=
()
local
_found
=
0
local
_found
=
0
...
@@ -101,14 +104,14 @@ function dbdetect.exists(){
...
@@ -101,14 +104,14 @@ function dbdetect.exists(){
# --- check tcp
# --- check tcp
local
tcpport
;
tcpport
=
$(
ini.value
"tcp-port"
)
local
tcpport
;
tcpport
=
$(
ini.value
"tcp-port"
)
if
[
-n
"
$tcpport
"
]
;
then
if
[
-n
"
$tcpport
"
]
;
then
local
tcptarget
;
tcptarget
=
$(
ini.value
"tcp-target"
)
local
tcptarget
;
tcptarget
=
$(
ini.value
"tcp-target"
)
tcptarget
=
${
tcptarget
:-
localhost
}
tcptarget
=
${
tcptarget
:-
localhost
}
if
{
!
>
/dev/tcp/
$tcptarget
/
$tcpport
;
}
>
/dev/null 2>&1
;
then
if
{
!
>
/dev/tcp/
$tcptarget
/
$tcpport
;
}
>
/dev/null 2>&1
;
then
# echo "No port tcp $tcpport available"
# echo "No port tcp $tcpport available"
dbdetect._wd
"... No port tcp
$tcpport
available on
$tcptarget
"
dbdetect._wd
"... No port tcp
$tcpport
available on
$tcptarget
"
return
1
return
1
fi
fi
dbdetect._wd
"... Found tcp
$tcpport
on
$tcptarget
."
dbdetect._wd
"... Found tcp
$tcpport
on
$tcptarget
."
fi
fi
# --- check tcp process
# --- check tcp process
...
@@ -140,7 +143,7 @@ function dbdetect.exists(){
...
@@ -140,7 +143,7 @@ function dbdetect.exists(){
local
filetype
;
filetype
=
$(
ini.value
"type"
)
local
filetype
;
filetype
=
$(
ini.value
"type"
)
if
[
-n
"
${
filetype
}
"
]
;
then
if
[
-n
"
${
filetype
}
"
]
;
then
local
myfiles
;
declare
-a
myfiles
local
myfiles
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
...
@@ -173,8 +176,8 @@ function dbdetect.exists(){
...
@@ -173,8 +176,8 @@ function dbdetect.exists(){
ini.set
"
$_config
"
"set"
ini.set
"
$_config
"
"set"
local
value
local
value
local
dbuser
=
$(
ini.value
"dbuser"
)
local
dbuser
;
dbuser
=
$(
ini.value
"dbuser"
)
local
dbpassword
=
$(
ini.value
"dbpassword"
)
local
dbpassword
;
dbpassword
=
$(
ini.value
"dbpassword"
)
for
mykey
in
env
params
for
mykey
in
env
params
do
do
...
...
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