Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
7bc67e0b
Commit
7bc67e0b
authored
Dec 21, 2009
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mysql databases handled in reload.sh
parent
a40d8b02
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
289 additions
and
83 deletions
+289
-83
src/exp/com/src/os_linux/reload.sh
src/exp/com/src/os_linux/reload.sh
+289
-83
No files found.
src/exp/com/src/os_linux/reload.sh
View file @
7bc67e0b
...
...
@@ -31,6 +31,130 @@ let reload__loaddb=4
let
pass__continue
=
1
let
pass__execute
=
2
reload_dblist_read
()
{
local
volume
local
volid
local
volclass
local
volcnf
local
volenum
local
volserver
local
dbfile
local
db
let
i
=
0
let
j
=
0
let
k
=
0
pwrc_status
=
$pwrc__success
if
[
-n
"
${
db_array
[*]
}
"
]
;
then
unset
db_array
fi
dbfile
=
$pwrp_root
/src/db/pwrp_cnf_volumelist.dat
if
[
!
-e
$dbfile
]
;
then
echo
"Can't find
$dbfile
"
return
fi
while
read
volume volid volclass volcnf volenum volserver
;
do
if
[
-n
"
$volume
"
]
&&
[
"
${
volume
:0:1
}
"
!=
"!"
]
;
then
if
[
$volcnf
==
"cnf"
]
;
then
if
[
$volclass
==
"ClassVolume"
]
;
then
if
[
$volenum
-eq
0
]
;
then
wbl_array[
$k
]=
`
eval echo
$volume
|
tr
"[:upper:]"
"[:lower:]"
`
k
=
$k
+1
elif
[
$volenum
-eq
1
]
;
then
db_array[
$i
]=
`
eval echo
$volume
|
tr
"[:upper:]"
"[:lower:]"
`
i
=
$i
+1
elif
[
$volenum
-eq
2
]
;
then
dbms_array[
$j
]=
`
eval echo
$volume
|
tr
"[:upper:]"
"[:lower:]"
`
dbms_server_array[
$j
]=
$volserver
j
=
$j
+1
fi
else
if
[
$volenum
-eq
0
]
;
then
db_array[
$i
]=
`
eval echo
$volume
|
tr
"[:upper:]"
"[:lower:]"
`
i
=
$i
+1
elif
[
$volenum
-eq
1
]
;
then
dbms_array[
$j
]=
`
eval echo
$volume
|
tr
"[:upper:]"
"[:lower:]"
`
dbms_server_array[
$j
]=
$volserver
j
=
$j
+1
fi
fi
fi
fi
done
<
$dbfile
}
reload_restoredb
()
{
echo
file
$1
if
[
-z
$pwrp_db
/
$1
]
;
then
echo
"** Database backup not found"
reload_status
=
$reload__success
return
fi
db
=
${
1
%.[1-9]
}
reload_dblist_read
if
[
"
${
db
#[a-z]*.
}
"
==
"dbms"
]
;
then
echo
"Restore mysql database
$db
"
found
=
0
idx
=
0
i
=
0
while
[
"
${
dbms_array
[
$i
]
}
"
!=
""
]
;
do
if
[
"
${
dbms_array
[
$i
]
}
"
==
"
${
db
%.[a-z]*
}
"
]
;
then
found
=
1
idx
=
$i
break
fi
i
=
$i
+1
done
if
[
$found
-eq
0
]
;
then
echo
"** Volume
${
db
%.[a-z]*
}
is not configured"
reload_exit
fi
if
[
-e
$pwrp_db
/
$db
]
;
then
# Delete the current database
echo
-n
"Do you want to delete
$db
? [y/n] "
read
repl
if
[
"
$repl
"
!=
"y"
]
;
then
reload_exit
fi
echo
"-- Deleting
${
dbms_array
[
$idx
]
}
on server
${
dbms_server_array
[
$idx
]
}
"
dbname
=
"pwrp_"
$pwrp_projectname
"__"
${
dbms_array
[
$idx
]
}
mysqladmin
-h
${
dbms_server_array
[
$idx
]
}
-upwrp
drop
-f
$dbname
rm
-r
$pwrp_db
/
$db
fi
dbname
=
"pwrp_"
$pwrp_projectname
"__"
${
dbms_array
[
$idx
]
}
if
[
!
-e
$pwrp_db
/
$1
/
$dbname
.mysqldump
]
;
then
echo
"** No mysql dump found,
$pwrp_db
/
$1
/
$dbname
.mysqldump"
reload_exit
fi
mv
$pwrp_db
/
$1
$pwrp_db
/
$db
mysqladmin
-h
${
dbms_server_array
[
$idx
]
}
-upwrp
create
$dbname
cat
$pwrp_db
/
$db
/
$dbname
.mysqldump | mysql
-h
${
dbms_server_array
[
$idx
]
}
-upwrp
-D
$dbname
elif
[
"
${
db
#[a-z]*.
}
"
==
"db"
]
;
then
echo
"Restore BerkeleyDb database
$db
"
fi
}
reload_classvolumes
()
{
reload_checkpass
"classvolumes"
$start_pass
...
...
@@ -58,6 +182,7 @@ reload_classvolumes()
list
=
`
eval ls
-1d
$pwrp_db
/
*
.wb_load
`
for
file
in
$list
;
do
if
[
${
file
##/*/
}
!=
"directory.wb_load"
]
;
then
volume
=
`
eval grep
pwr_eClass_ClassVolume
$file
|
awk
'{ print $2 }'
`
volumelow
=
`
eval grep
pwr_eClass_ClassVolume
$file
|
awk
'{ print tolower($2) }'
`
if
[
"
$volume
"
==
""
]
;
then
...
...
@@ -74,7 +199,7 @@ reload_classvolumes()
return
fi
if
wb_cmd
create snapshot/file
=
\"
$file
\"
/out
=
\"
$pwrp_load
/
$volumelow
.dbs
\"
if
wb_cmd
-q
create snapshot/file
=
\"
$file
\"
/out
=
\"
$pwrp_load
/
$volumelow
.dbs
\"
then
reload_status
=
$reload__success
else
...
...
@@ -82,6 +207,7 @@ reload_classvolumes()
return
fi
fi
fi
done
}
...
...
@@ -96,18 +222,38 @@ reload_dumpdb()
reload_continue
"Pass dump database"
# Rename old dumpfiles
dmpfiles
=
`
eval ls
-1
$pwrp_db
/
*
.wb_dmp
`
dmpfiles
=
`
eval ls
-1
$pwrp_db
/
*
.wb_dmp
2> /dev/null
`
for
dmpfile
in
$dmpfiles
;
do
reload_save_file
$dmpfile
done
for
cdb
in
$databases
;
do
if
[
$arg_found
-eq
1
]
;
then
# Dump supplied database
if
[
$arg_db
-eq
1
]
;
then
cdb
=
${
db_array
[
$arg_idx
]
}
else
cdb
=
${
dbms_array
[
$arg_idx
]
}
fi
dump_file
=
$pwrp_db
/
$cdb
.wb_dmp
echo
"Dumping volume
$cdb
in
$dump_file
"
wb_cmd
-v
$cdb
wb dump/nofocode/out
=
\"
$dump_file
\"
echo
"-- Dumping volume
$cdb
into
$dump_file
"
wb_cmd
-q
-v
$cdb
wb dump/nofocode/out
=
\"
$dump_file
\"
else
# Dump all databases
i
=
0
while
[
"
${
db_array
[
$i
]
}
"
!=
""
]
;
do
dump_file
=
$pwrp_db
/
${
db_array
[
$i
]
}
.wb_dmp
echo
"-- Dumping volume
${
db_array
[
$i
]
}
into
$dump_file
"
wb_cmd
-q
-v
${
db_array
[
$i
]
}
wb dump/nofocode/out
=
\"
$dump_file
\"
i
=
$i
+1
done
i
=
0
while
[
"
${
dbms_array
[
$i
]
}
"
!=
""
]
;
do
dump_file
=
$pwrp_db
/
${
dbms_array
[
$i
]
}
.wb_dmp
echo
"-- Dumping volume
${
dbms_array
[
$i
]
}
into
$dump_file
"
wb_cmd
-q
-v
${
dbms_array
[
$i
]
}
wb dump/nofocode/out
=
\"
$dump_file
\"
i
=
$i
+1
done
fi
}
reload_renamedb
()
...
...
@@ -120,9 +266,38 @@ reload_renamedb()
reload_continue
"Pass rename old database"
for
cdb
in
$databases
;
do
reload_save_file
$pwrp_db
/
$cdb
.db
if
[
$arg_found
-eq
1
]
;
then
# Rename supplied database
if
[
$arg_db
-eq
1
]
;
then
reload_save_file
$pwrp_db
/
${
db_array
[
$arg_idx
]
}
.db
else
dbname
=
"pwrp_"
$pwrp_projectname
"__"
${
dbms_array
[
$arg_idx
]
}
mysqldump
-h
${
dbms_server_array
[
$arg_idx
]
}
-upwrp
$dbname
>
$pwrp_db
/
${
dbms_array
[
$arg_idx
]
}
.dbms/
$dbname
.mysqldump
mysqladmin
-h
${
dbms_server_array
[
$arg_idx
]
}
-upwrp
drop
-f
$dbname
reload_save_file
$pwrp_db
/
${
dbms_array
[
$arg_idx
]
}
.dbms
fi
else
# Rename all databases
i
=
0
while
[
"
${
db_array
[
$i
]
}
"
!=
""
]
;
do
reload_save_file
$pwrp_db
/
${
db_array
[
$i
]
}
.db
i
=
$i
+1
done
i
=
0
while
[
"
${
dbms_array
[
$i
]
}
"
!=
""
]
;
do
dbname
=
"pwrp_"
$pwrp_projectname
"__"
${
dbms_array
[
$i
]
}
mysqldump
-h
${
dbms_server_array
[
$i
]
}
-upwrp
$dbname
>
$pwrp_db
/
${
dbms_array
[
$i
]
}
.dbms/
$dbname
.mysqldump
mysqladmin
-h
${
dbms_server_array
[
$i
]
}
-upwrp
drop
-f
$dbname
reload_save_file
$pwrp_db
/
${
dbms_array
[
$i
]
}
.dbms
i
=
$i
+1
done
fi
}
reload_dirvolume
()
...
...
@@ -139,8 +314,8 @@ reload_dirvolume()
reload_continue
"Pass dirvolume"
wb_cmd create volume/directory
wb_cmd wb load /load
=
\"
$pwrp_db
/directory.wb_dmp
\"
wb_cmd
-q
create volume/directory
wb_cmd
-q
wb load /load
=
\"
$pwrp_db
/directory.wb_dmp
\"
}
reload_loaddb
()
...
...
@@ -153,34 +328,18 @@ reload_loaddb()
reload_continue
"Pass load database"
if
[
-z
"
$1
"
]
;
then
tmp
=
`
eval ls
-1
$pwrp_db
/
*
.wb_dmp
`
databases
=
""
for
db
in
$tmp
;
do
db
=
${
db
##/*/
}
db
=
"
${
db
%.*
}
"
if
[
"
$db
"
!=
"directory"
]
;
then
databases
=
"
$databases
$db
"
fi
done
else
databases
=
$@
fi
for
cdb
in
$databases
;
do
if
[
$cdb
!=
"directory"
]
;
then
echo
"-- Loading volume
$cdb
"
dump_file
=
$pwrp_db
/
$cdb
.wb_dmp
list_file
=
$pwrp_db
/
$cdb
.lis
if
wb_cmd
wb load/nofocode/load
=
\"
$dump_file
\"
/out
=
\"
$list_file
\"
if
wb_cmd
-q
wb load/nofocode/load
=
\"
$dump_file
\"
/out
=
\"
$list_file
\"
then
reload_status
=
$reload__success
else
cat
$list_file
reload_status
=
$reload__loaddb
fi
fi
done
}
...
...
@@ -195,9 +354,7 @@ reload_compile()
reload_continue
"Pass compile plcprograms"
for
cdb
in
$databases
;
do
if
[
$cdb
!=
"directory"
]
;
then
wb_cmd
-v
$cdb
compile /all
fi
wb_cmd
-q
-v
$cdb
compile /all
done
reload_status
=
$reload__success
...
...
@@ -213,9 +370,6 @@ reload_removeload()
reload_continue
"Pass remove old loadfiles"
# Remove all old loadfiles
echo
"-- Removing old loadfiles"
rm
$pwrp_load
/ld_vol
*
.dat
reload_status
=
$reload__success
}
...
...
@@ -229,15 +383,9 @@ reload_createload()
reload_continue
"Pass create loadfiles"
# Remove all old loadfiles
echo
"-- Removing old loadfiles"
rm
$pwrp_load
/ld_vol
*
.dat
for
cdb
in
$databases
;
do
if
[
$cdb
!=
"directory"
]
;
then
echo
"-- Creating loadfiles for database
$cdb
"
wb_cmd
-v
$cdb
create load
fi
wb_cmd
-q
-v
$cdb
create load
done
reload_status
=
$reload__success
}
...
...
@@ -253,13 +401,12 @@ reload_createboot()
reload_continue
"Pass create bootfiles"
echo
"-- Creating bootfiles for all nodes"
wb_cmd create boot/all
wb_cmd
-q
create boot/all
reload_status
=
$reload__success
}
reload_exit
()
{
source
pwrp_env.sh setdb
exit
$reload_status
}
...
...
@@ -357,19 +504,78 @@ fi
let
reload_status
=
$reload__success
let
check_status
=
0
let
go
=
0
let
arg_found
=
0
let
arg_dbms
=
0
let
arg_db
=
0
let
arg_wbl
=
0
let
arg_idx
=
0
if
[
-z
"
$1
"
]
;
then
tmp
=
`
eval ls
-1d
$pwrp_db
/
*
.db
`
databases
=
""
for
db
in
$tmp
;
do
db
=
${
db
##/*/
}
db
=
"
${
db
%.*
}
"
if
[
"
$db
"
!=
"rt_eventlog"
]
;
then
databases
=
"
$databases
$db
"
reload_dblist_read
if
[
"
$1
"
==
"restore"
]
;
then
if
[
$#
-ne
2
]
;
then
echo
"Invalid arguments"
reload_exit
fi
shift
reload_restoredb
$1
reload_exit
fi
if
[
"
$1
"
!=
""
]
;
then
i
=
0
while
[
"
${
db_array
[
$i
]
}
"
!=
""
]
;
do
if
[
$1
==
${
db_array
[
$i
]
}
]
;
then
arg_found
=
1
arg_idx
=
i
arg_db
=
1
databases
=
${
db_array
[
$i
]
}
break
fi
i
=
$i
+1
done
i
=
0
while
[
"
${
dbms_array
[
$i
]
}
"
!=
""
]
;
do
if
[
$1
==
${
dbms_array
[
$i
]
}
]
;
then
arg_found
=
1
arg_idx
=
i
arg_dbms
=
1
databases
=
${
dbms_array
[
$i
]
}
break
fi
i
=
$i
+1
done
i
=
0
while
[
"
${
wbl_array
[
$i
]
}
"
!=
""
]
;
do
if
[
$1
==
${
wbl_array
[
$i
]
}
]
;
then
arg_found
=
1
arg_idx
=
1
arg_wbl
=
1
break
fi
i
=
$i
+1
done
if
[
$arg_found
-eq
0
]
;
then
echo
"** No such database"
reload_exit
fi
if
[
$arg_wbl
-eq
1
]
;
then
echo
"** Database has wb_load format, no reload possible"
reload_exit
fi
else
databases
=
$@
i
=
0
databases
=
""
while
[
"
${
db_array
[
$i
]
}
"
!=
""
]
;
do
databases
=
"
$databases
${
db_array
[
$i
]
}
"
i
=
$i
+1
done
i
=
0
while
[
"
${
dbms_array
[
$i
]
}
"
!=
""
]
;
do
databases
=
"
$databases
${
dbms_array
[
$i
]
}
"
i
=
$i
+1
done
fi
usage
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment