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()
22
22
23
23
SCRIPT=" ` basename $0 ` "
24
24
REQVERS=" ` 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 "
26
26
27
27
28
28
if [ -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()
22
22
23
23
SCRIPT=" ` basename $0 ` "
24
24
REQVERS=" ` 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 "
26
26
27
27
28
28
if [ -x " $EXEC " ]
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ check_image()
22
22
23
23
SCRIPT=" ` basename $0 ` "
24
24
REQVERS=" ` 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 "
26
26
27
27
28
28
if [ -x " $EXEC " ]
Original file line number Diff line number Diff line change @@ -312,7 +312,15 @@ d_shell()
312
312
error_cni
313
313
else
314
314
# 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
+
316
324
if [ " $? " == " 1" ]
317
325
then
318
326
error_ccbi
Original file line number Diff line number Diff line change @@ -156,24 +156,29 @@ function database_import() {
156
156
157
157
fi
158
158
159
+ if [ ! $( has_arg --no-backup) ]; then
159
160
database_backup " ${basefile} .bak"
160
-
161
161
if [ $? -ne 0 ]; then
162
162
output " Error when backing up to ${basefile} .bak"
163
163
return 4
164
+ fi
164
165
fi
165
166
166
- output " Dropping any prior tables "
167
+ if [ ! $( has_arg --no-droptables ) ] ; then
167
168
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
172
175
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
+
175
181
fi
176
- output " Tables dropped"
177
182
178
183
if [ " " != " $( cat " ${importfilepath} " | grep " utf8mb4_unicode_520_ci" ) " ]; then
179
184
#
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ ${YELLOW}WPLib Box ${GREEN}CLI${RESET} usage:
7
7
box ${GREEN} database${RESET} [<args>] - Manage databases.
8
8
box ${GREEN} container${RESET} [<args>] - Manage Docker containers.
9
9
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.
11
11
box ${GREEN} restart${RESET} - Restart Docker containers found in project.json's services object.
12
12
box ${GREEN} shutdown${RESET} - Shutdown all Docker containers.
13
13
Original file line number Diff line number Diff line change 56
56
57
57
58
58
chmod 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 1
1
#! /usr/bin/env bash
2
2
3
3
source " ${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