Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit deed8d7

Browse files
committed
Updating all shell scripts for the library_load function
1 parent 0964563 commit deed8d7

17 files changed

+73
-140
lines changed

src/pluginops/pluginops.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,12 @@ def linked_post_snapshot(staged_source,repository,source_config,snapshot_paramet
459459
def linked_status(staged_source, repository, source_config):
460460
logger.debug("Checking status of Staging DB")
461461
library_script=pkgutil.get_data('resources','library.sh')
462+
binary_path=staged_source.staged_connection.environment.host.binary_path
462463
logger.debug(" Staging Port >>: "+staged_source.parameters.staging_port)
463464
environment_vars={
464465
"DLPX_LIBRARY_SOURCE" : library_script,
465-
"STAGINGPORT":staged_source.parameters.staging_port
466+
"STAGINGPORT":staged_source.parameters.staging_port,
467+
"DLPX_BIN" : binary_path
466468
}
467469
status_script = pkgutil.get_data('resources', 'statusStaged.sh')
468470
result = libs.run_bash(staged_source.staged_connection, status_script,environment_vars,check=True)

src/resources/library.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,8 @@ buildConnectionString () {
485485
#
486486
# Keep for Library Verification ...
487487
#
488-
function hey {
489-
echo "there"
488+
function library_load {
489+
echo "LOADED"
490490
}
491491

492492
###########################################################

src/resources/provision.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ PGM_NAME='provision.sh'
1414
# Load Library ...
1515
#
1616
eval "${DLPX_LIBRARY_SOURCE}"
17-
result=`hey`
18-
log "------------------------- Start"
19-
log "Library Loaded ... hey $result"
17+
result=`library_load`
18+
log "Start ${PGM_NAME}"
19+
log "Library Load Status: $result"
2020

2121
DT=`date '+%Y%m%d%H%M%S'`
2222

src/resources/recordVirtual.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ PGM_NAME='recordVirtual.sh'
1414
# Load Library ...
1515
#
1616
eval "${DLPX_LIBRARY_SOURCE}"
17-
result=`hey`
18-
log "------------------------- Start"
19-
log "Library Loaded ... hey $result"
17+
result=`library_load`
18+
log "Start ${PGM_NAME}"
19+
log "Library Load Status: $result"
2020

2121
ID=$$
2222
TMP1="${DLPX_DATA_DIRECTORY}/data"

src/resources/repoDiscovery.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ PGM_NAME="repoDiscovery.sh" # used in log and errorLog
1616
# Load Library ...
1717
#
1818
eval "${DLPX_LIBRARY_SOURCE}"
19-
result=`hey`
20-
log "------------------------- Start"
21-
log "Library Loaded ... hey $result"
19+
result=`library_load`
20+
log "Start ${PGM_NAME}"
21+
log "Library Load Status: $result"
22+
2223
WHO=`whoami`
2324
log "whoami: ${WHO}"
2425

src/resources/restore.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ PGM_NAME='restore.sh'
1515
# Load Library ...
1616
#
1717
eval "${DLPX_LIBRARY_SOURCE}"
18-
result=`hey`
19-
log "------------------------- Start"
20-
log "Library Loaded ... hey $result"
18+
result=`library_load`
19+
log "Start ${PGM_NAME}"
20+
log "Library Load Status: $result"
2121

2222
who=`whoami`
2323
log "whoami: $who"

src/resources/restore_stage.sh

Lines changed: 25 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
#!/bin/sh
2-
#
32
# Copyright (c) 2018 by Delphix. All rights reserved.
4-
#
5-
6-
##DEBUG## In Delphix debug.log
7-
#set -x
8-
9-
#
10-
# Program Name ...
11-
#
123
PGM_NAME='restore_stage.sh'
134

14-
#
155
# Load Library ...
16-
#
176
eval "${DLPX_LIBRARY_SOURCE}"
18-
result=`hey`
19-
log "------------------------- Start"
20-
log "Library Loaded ... hey $result"
7+
result=`library_load`
8+
log "Start ${PGM_NAME}"
9+
log "Library Load Status: $result"
2110

2211
who=`whoami`
2312
log "whoami: $who"
@@ -29,23 +18,17 @@ log "awk: ${AWK}"
2918

3019
DT=`date '+%Y%m%d%H%M%S'`
3120

32-
#
33-
# Software Binaries ...
34-
#
21+
# Software Binaries
3522
INSTALL_BIN="${SOURCEBASEDIR}/bin"
3623
log "Binaries: ${INSTALL_BIN}"
3724

38-
#
39-
# Ports ...
40-
#
25+
# Ports
4126
SOURCE_PORT=${SOURCEPORT}
4227
TARGET_PORT=${STAGINGPORT}
4328
log "Source Port: ${SOURCE_PORT}"
4429
log "Staging Port: ${TARGET_PORT}"
4530

46-
#
4731
# Backup File Location ...
48-
#
4932
if [[ "${BACKUP_PATH}" == "" ]]
5033
then
5134
BKUP_FILE="/tmp/dump_${SOURCE_PORT}.sql"
@@ -54,9 +37,7 @@ else
5437
fi
5538
log "Backup File: ${BKUP_FILE}"
5639

57-
#
5840
# Staging Connection for Install/Configuration ...
59-
#
6041
STAGINGPASS=`echo "'"${STAGINGPASS}"'"`
6142

6243
log "Staging Connection: ${STAGINGCONN}"
@@ -65,9 +46,7 @@ echo "${RESULTS}" | $DLPX_BIN_JQ --raw-output ".string"
6546
STAGING_CONN=`echo "${RESULTS}" | $DLPX_BIN_JQ --raw-output ".string"`
6647
log "Staging Connection: ${STAGING_CONN}"
6748

68-
#
6949
# Replication Variables ...
70-
#
7150
log "========= Replication Variables ==========="
7251
log "Staging Host: ${STAGINGHOSTIP}"
7352
MASTER_HOST="${SOURCEIP}"
@@ -78,9 +57,7 @@ MASTER_PORT="${SOURCEPORT}"
7857
log "MASTER_PORT: ${MASTER_PORT}"
7958
MASTER_PASS="${REPLICATION_PASS}"
8059

81-
#
8260
# Directory Paths ...
83-
#
8461
NEW_MOUNT_DIR="${STAGINGDATADIR}"
8562
log "Staging Base Directory: ${NEW_MOUNT_DIR}"
8663

@@ -93,95 +70,56 @@ NEW_SERVER_ID="${STAGINGSERVERID}"
9370

9471
###########################################################
9572
## On Staging Server ...
96-
9773
# scp from source server the ${BKUP_FILE}
98-
99-
#
10074
# Get master log file and position ...
10175
#
10276
log "LogSync Enabled: ${LOGSYNC}"
10377
if [[ "${LOGSYNC}" == "true" ]]
10478
then
105-
10679
#head ${BKUP_FILE} -n80 | grep "MASTER_LOG_POS"
10780
STR=$( head ${BKUP_FILE} -n80 | grep "MASTER_LOG_POS" )
108-
##echo "${STR}"
10981
BINLOG_FILENAME=`echo "${STR}" | ${AWK} -F"=" '{print $2}' | cut -d"," -f1 | tr -d \'`
11082
BINLOG_POSITION=`echo "${STR}" | ${AWK} -F"=" '{print $3}' | cut -d";" -f1`
11183
log "BackupFile: ${BKUP_FILE}"
11284
log "MasterLogFile: ${BINLOG_FILENAME}"
11385
log "MasterLogPosition: ${BINLOG_POSITION}"
114-
11586
fi
11687

117-
#
11888
# Create Initial Database ...
119-
#
12089
log "MySQL Version: ${MYSQLVER}"
121-
#MYSQLVER="5.7.20"
122-
#MYSQLVER="5.6.28-76.1"
123-
#10.1.32-MariaDB
124-
#echo ${MYSQLVER:0:3}
125-
#5.6
126-
12790
log "Source --basedir=${SOURCEBASEDIR}"
12891
log "Source --datadir=${SOURCEDATADIR}"
92+
log "Creating Initial Database"
12993

130-
#
131-
# Change MySQL Database Tables ...
132-
#
133-
#log "Checking for Customer Initial Database ..."
134-
#if [[ -f "${DLPX_TOOLKIT}/install_db.zip" ]]
135-
#then
136-
# log "Installing ${DLPX_TOOLKIT}/install_db.zip into ${NEW_MOUNT_DIR}"
137-
# unzip ${DLPX_TOOLKIT}/install_db.zip -d ${NEW_MOUNT_DIR}
138-
#else
139-
# #die "Error: Missing Initial Database zip file ... ${DLPX_TOOLKIT}/install_db.zip"
140-
# log "Missing Initial Database zip file ... ${DLPX_TOOLKIT}/install_db.zip"
141-
142-
log "Creating Initial Database ..."
143-
144-
#
145-
# Create Initial Database 5.7 or later ...
146-
#
147-
log "Using mysqld --initialize ..."
148-
149-
log "${MYSQLD}/mysqld --initialize --user=mysql --datadir=${NEW_DATA_DIR} --log-error=${NEW_DATA_DIR}/mysqld.log"
150-
${MYSQLD}/mysqld --initialize --user=mysql --datadir=${NEW_DATA_DIR} --log-error=${NEW_DATA_DIR}/mysqld.log 1>>${DEBUG_LOG} 2>&1
151-
152-
PWD_LINE=`cat ${NEW_DATA_DIR}/mysqld.log | grep 'temporary password'`
153-
# sudo grep 'temporary password' ${NEW_DATA_DIR}/mysqld.log`
154-
# 2019-04-11T14:40:34.032576Z 1 [Note] A temporary password is generated for root@localhost: L0qXNZ8?C3Us
155-
log "init temporary password: ${PWD_LINE}"
156-
157-
TMP_PWD=`echo "${PWD_LINE}" | ${AWK} -F": " '{print $2}' | xargs`
158-
#
159-
# These temporary passwords contain special characters so need to wrap in single / literal quotes ...
160-
#
161-
TMP_PWD=`echo "'"$TMP_PWD"'"`
162-
log "Temporary Password: ${TMP_PWD}"
94+
# Create Initial Database 5.7 or later ...
95+
log "Using mysqld --initialize"
16396

164-
log "Staging Connection: ${STAGINGCONN}"
165-
RESULTS=$( buildConnectionString "${STAGINGCONN}" "${TMP_PWD}" "${STAGINGPORT}" "${STAGINGHOSTIP}" )
166-
echo "${RESULTS}" | $DLPX_BIN_JQ --raw-output ".string"
167-
STAGING_CONN=`echo "${RESULTS}" | $DLPX_BIN_JQ --raw-output ".string"`
168-
log "Staging Connection: ${STAGING_CONN}"
97+
log "${MYSQLD}/mysqld --initialize --user=mysql --datadir=${NEW_DATA_DIR} --log-error=${NEW_DATA_DIR}/mysqld.log"
98+
${MYSQLD}/mysqld --initialize --user=mysql --datadir=${NEW_DATA_DIR} --log-error=${NEW_DATA_DIR}/mysqld.log 1>>${DEBUG_LOG} 2>&1
16999

170-
# fi # end if customer install_db.zip ...
100+
PWD_LINE=`cat ${NEW_DATA_DIR}/mysqld.log | grep 'temporary password'`
101+
# sudo grep 'temporary password' ${NEW_DATA_DIR}/mysqld.log`
102+
# 2019-04-11T14:40:34.032576Z 1 [Note] A temporary password is generated for root@localhost: L0qXNZ8?C3Us
103+
log "init temporary password: ${PWD_LINE}"
171104

105+
TMP_PWD=`echo "${PWD_LINE}" | ${AWK} -F": " '{print $2}' | xargs`
106+
# These temporary passwords contain special characters so need to wrap in single / literal quotes ...
107+
TMP_PWD=`echo "'"$TMP_PWD"'"`
108+
log "Temporary Password: ${TMP_PWD}"
109+
log "Staging Connection: ${STAGINGCONN}"
110+
RESULTS=$( buildConnectionString "${STAGINGCONN}" "${TMP_PWD}" "${STAGINGPORT}" "${STAGINGHOSTIP}" )
111+
echo "${RESULTS}" | $DLPX_BIN_JQ --raw-output ".string"
112+
STAGING_CONN=`echo "${RESULTS}" | $DLPX_BIN_JQ --raw-output ".string"`
113+
log "Staging Connection: ${STAGING_CONN}"
172114
log "Creation Results: ${RESULTS}"
173115

174116
############################################################
175-
##
176-
log "Creating Staging Directories on NFS Mounted Path from Delphix ..."
177-
117+
log "Creating Staging Directories on NFS Mounted Path from Delphix"
178118
mkdir -p ${NEW_DATA_DIR}
179119
mkdir -p ${NEW_LOG_DIR}
180120
mkdir -p ${NEW_TMP_DIR}
181121

182-
#
183122
# This snippet creates a config file if one has not been provided.
184-
#
185123
log "my.cnf file location > ${NEW_MY_CNF}"
186124

187125
if [[ -f "${DLPX_TOOLKIT}/my.cnf" ]]
@@ -220,15 +158,9 @@ log "my.cnf exists? ${CMD}"
220158

221159
if [[ -f "${NEW_MY_CNF}" ]]
222160
then
223-
#
224161
# Replace all tabs with spaces ...
225-
#
226162
sed -i 's/\t/ /g' ${NEW_MY_CNF}
227-
228-
#
229163
# Update Parameters ...
230-
#
231-
232164
log "Parameter port = $TARGET_PORT"
233165
CHK=`cat ${NEW_MY_CNF} | grep "^port"`
234166
if [[ "${CHK}" != "" ]]
@@ -238,7 +170,6 @@ then
238170
else
239171
echo "port = ${TARGET_PORT}" >> ${NEW_MY_CNF}
240172
fi
241-
242173
log "Parameter server-id = ${NEW_SERVER_ID}"
243174
CHK=`cat ${NEW_MY_CNF} | grep "^server-id"`
244175
if [[ "${CHK}" != "" ]]
@@ -640,5 +571,5 @@ export DLPX_LIBRARY_SOURCE=""
640571
export REPLICATION_PASS=""
641572
export STAGINGPASS=""
642573
env | sort >>$DEBUG_LOG
643-
log "------------------------- End"
574+
log " <<<End"
644575
exit 0

src/resources/restore_stage_bi.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ PGM_NAME='restore_stage_bi.sh'
1515
# Load Library ...
1616
#
1717
eval "${DLPX_LIBRARY_SOURCE}"
18-
result=`hey`
19-
log "---Start----"
20-
log "Library Loaded ... hey $result"
18+
result=`library_load`
19+
log "Start ${PGM_NAME}"
20+
log "Library Load Status: $result"
2121

2222
who=`whoami`
2323
log "whoami: $who"

src/resources/restore_stage_si.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ PGM_NAME='restore_stage_si.sh'
1515
# Load Library ...
1616
#
1717
eval "${DLPX_LIBRARY_SOURCE}"
18-
result=`hey`
19-
log "------------------------- Start"
20-
log "Library Loaded ... hey $result"
18+
result=`library_load`
19+
log "Start ${PGM_NAME}"
20+
log "Library Load Status: $result"
2121

2222
who=`whoami`
2323
log "whoami: $who"

src/resources/sourceConfigDiscovery.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ PGM_NAME="sourceConfigDiscovery.sh" # used in log and errorLog
1717
# Load Library ...
1818
#
1919
eval "${DLPX_LIBRARY_SOURCE}"
20-
result=`hey`
21-
log "------------------------- Start"
22-
log "Library Loaded ... hey $result"
20+
result=`library_load`
21+
log "Start ${PGM_NAME}"
22+
log "Library Load Status: $result"
2323

2424
#
2525
# create empty output list

0 commit comments

Comments
 (0)