This repository was archived by the owner on Jan 25, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 11 files changed +214
-39
lines changed Expand file tree Collapse file tree 11 files changed +214
-39
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ check_image()
2222
2323SCRIPT=" ` basename $0 ` "
2424REQVERS=" ` echo $SCRIPT | sed -r ' s/composer-([0-9]*\.[0-9]*)/\1/' ` "
25- EXEC=" /usr/local /bin/composer-$REQVERS "
25+ EXEC=" /opt/box /bin/composer-$REQVERS "
2626
2727
2828if [ -x " $EXEC " ]
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ check_image ()
4+ {
5+ # VERSION="`docker container ls -af label=container.class="database" -f "status=running" --format='wplib/{{.Label "container.name"}}:{{.Label "container.version"}}' 2>/dev/null`"
6+ VERSION=" ` docker container ls -af label=container.class=" database" -f " status=running" --format=' {{.Label "container.version"}}' 2> /dev/null` "
7+
8+ if [ " $VERSION " == " " ]
9+ then
10+ echo " WPLib: No MySQL database running."
11+ return 1
12+ fi
13+
14+ MAJORVERSION=" ` docker container ls -af label=container.class=" database" -f " status=running" --format=' {{.Label "container.majorversion"}}' 2> /dev/null` "
15+ IP=" ` docker inspect -f ' {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mysql-${VERSION} ` "
16+
17+ return 0
18+ }
19+
20+
21+ if check_image
22+ then
23+ exec box container shell wplib/mysql:${MAJORVERSION} mysql -h ${IP} " $@ "
24+ fi
25+
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ check_image()
2222
2323SCRIPT=" ` basename $0 ` "
2424REQVERS=" ` echo $SCRIPT | sed -r ' s/php-([0-9]*\.[0-9]*)/\1/' ` "
25- EXEC=" /usr/local /bin/php-$REQVERS "
25+ EXEC=" /opt/box /bin/php-$REQVERS "
2626
2727
2828if [ -x " $EXEC " ]
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ check_image()
2222
2323SCRIPT=" ` basename $0 ` "
2424REQVERS=" ` echo $SCRIPT | sed -r ' s/wp-([0-9]*\.[0-9]*)/\1/' ` "
25- EXEC=" /usr/local /bin/wp-$REQVERS "
25+ EXEC=" /opt/box /bin/wp-$REQVERS "
2626
2727
2828if [ -x " $EXEC " ]
Original file line number Diff line number Diff line change @@ -312,7 +312,15 @@ d_shell()
312312 error_cni
313313 else
314314 # echo "$ECHO_PREFIX ${GREEN}Shell to container: ${CYAN}${IMAGE}${RESET}" 1>&2
315- docker run --name ${CONTAINER_NAME} -shell --rm -i -t ${IMAGE_NETWORK} ${IMAGE_ARGS} ${IMAGE_VOLUMES} ${IMAGE} " $@ "
315+ if [ -t 0 ]
316+ then
317+ # TTY allocated.
318+ docker run --name ${CONTAINER_NAME} -shell --rm -i -t ${IMAGE_NETWORK} ${IMAGE_ARGS} ${IMAGE_VOLUMES} ${IMAGE} " $@ "
319+ else
320+ # TTY not allocated.
321+ docker run --name ${CONTAINER_NAME} -exec --rm -i ${IMAGE_NETWORK} ${IMAGE_ARGS} ${IMAGE_VOLUMES} ${IMAGE} " $@ "
322+ fi
323+
316324 if [ " $? " == " 1" ]
317325 then
318326 error_ccbi
Original file line number Diff line number Diff line change @@ -156,24 +156,29 @@ function database_import() {
156156
157157 fi
158158
159+ if [ ! $( has_arg --no-backup) ]; then
159160 database_backup " ${basefile} .bak"
160-
161161 if [ $? -ne 0 ]; then
162162 output " Error when backing up to ${basefile} .bak"
163163 return 4
164+ fi
164165 fi
165166
166- output " Dropping any prior tables "
167+ if [ ! $( has_arg --no-droptables ) ] ; then
167168
168- if [ ! $( has_arg --dryrun) ]; then
169- box container exec ${database} mysql -h ${DB_HOST_IP} -u wordpress -pwordpress -Nse " show tables;" wordpress 2>&1 | grep -v " Warning:" > /tmp/mysql-table-list.txt
170- cat /tmp/mysql-table-list.txt | while read table
171- do
169+ output " Dropping any prior tables"
170+
171+ if [ ! $( has_arg --dryrun) ]; then
172+ box container exec ${database} mysql -h ${DB_HOST_IP} -u wordpress -pwordpress -Nse " show tables;" wordpress 2>&1 | grep -v " Warning:" > /tmp/mysql-table-list.txt
173+ cat /tmp/mysql-table-list.txt | while read table
174+ do
172175 box container exec ${database} mysql -h ${DB_HOST_IP} -u wordpress -pwordpress -e " drop table $table " wordpress 2>&1 | grep -v " Warning:"
173- done
174- rm /tmp/mysql-table-list.txt
176+ done
177+ rm /tmp/mysql-table-list.txt
178+ fi
179+ output " Tables dropped"
180+
175181 fi
176- output " Tables dropped"
177182
178183 if [ " " != " $( cat " ${importfilepath} " | grep " utf8mb4_unicode_520_ci" ) " ]; then
179184 #
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ ${YELLOW}WPLib Box ${GREEN}CLI${RESET} usage:
77box ${GREEN} database${RESET} [<args>] - Manage databases.
88box ${GREEN} container${RESET} [<args>] - Manage Docker containers.
99
10- box ${GREEN} start ${RESET} - Start Docker containers found in project.json's services object.
10+ box ${GREEN} startup ${RESET} - Start Docker containers found in project.json's services object.
1111box ${GREEN} restart${RESET} - Restart Docker containers found in project.json's services object.
1212box ${GREEN} shutdown${RESET} - Shutdown all Docker containers.
1313
Original file line number Diff line number Diff line change 5656
5757
5858chmod a+x /tmp/self-update.$$
59- exec bash /tmp/self-update.$$
59+ exec sudo /tmp/self-update.$$
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22
33source " ${WPLIB_BOX_INCLUDES_DIR} /read-json"
4- box container stop $database $webserver $processvm $kvstore $cache $sqladmin $webadmin
5- # box container shutdown
4+ # box container stop $database $webserver $processvm $kvstore $cache $sqladmin $webadmin
5+ box container shutdown
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments