This repository has been archived by the owner on Jan 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from wplib/0.16.1
0.16.1
- Loading branch information
Showing
11 changed files
with
214 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
check_image() | ||
{ | ||
# VERSION="`docker container ls -af label=container.class="database" -f "status=running" --format='wplib/{{.Label "container.name"}}:{{.Label "container.version"}}' 2>/dev/null`" | ||
VERSION="`docker container ls -af label=container.class="database" -f "status=running" --format='{{.Label "container.version"}}' 2>/dev/null`" | ||
|
||
if [ "$VERSION" == "" ] | ||
then | ||
echo "WPLib: No MySQL database running." | ||
return 1 | ||
fi | ||
|
||
MAJORVERSION="`docker container ls -af label=container.class="database" -f "status=running" --format='{{.Label "container.majorversion"}}' 2>/dev/null`" | ||
IP="`docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mysql-${VERSION}`" | ||
|
||
return 0 | ||
} | ||
|
||
|
||
if check_image | ||
then | ||
exec box container shell wplib/mysql:${MAJORVERSION} mysql -h ${IP} "$@" | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,4 +56,4 @@ EOF | |
|
||
|
||
chmod a+x /tmp/self-update.$$ | ||
exec bash /tmp/self-update.$$ | ||
exec sudo /tmp/self-update.$$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
source "${WPLIB_BOX_INCLUDES_DIR}/read-json" | ||
box container stop $database $webserver $processvm $kvstore $cache $sqladmin $webadmin | ||
# box container shutdown | ||
# box container stop $database $webserver $processvm $kvstore $cache $sqladmin $webadmin | ||
box container shutdown |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
#/usr/bin/env bash | ||
|
||
################################################################################ | ||
# Command completion for 'box' | ||
_box() | ||
{ | ||
local cur=${COMP_WORDS[COMP_CWORD]} | ||
local prev=${COMP_WORDS[COMP_CWORD-1]} | ||
|
||
|
||
case "${COMP_WORDS[1]}" in | ||
'container') | ||
# /opt/box/bin/box container help | ||
_box_container | ||
return 0 | ||
;; | ||
|
||
'database') | ||
COMPREPLY=($(compgen -W "backup import chunk unchunk credentials dbname username password" -- $cur)) | ||
return 0 | ||
;; | ||
|
||
'startup') | ||
COMPREPLY=($(compgen -W "" -- $cur)) | ||
return 0 | ||
;; | ||
|
||
'restart') | ||
COMPREPLY=($(compgen -W "" -- $cur)) | ||
return 0 | ||
;; | ||
|
||
'shutdown') | ||
COMPREPLY=($(compgen -W "" -- $cur)) | ||
return 0 | ||
;; | ||
|
||
'status') | ||
COMPREPLY=($(compgen -W "" -- $cur)) | ||
return 0 | ||
;; | ||
|
||
'shell') | ||
COMPREPLY=($(compgen -W "" -- $cur)) | ||
return 0 | ||
;; | ||
|
||
'version') | ||
COMPREPLY=($(compgen -W "" -- $cur)) | ||
return 0 | ||
;; | ||
|
||
'self-update') | ||
COMPREPLY=($(compgen -W "$(git --git-dir=/opt/box/.git tag)" -- $cur)) | ||
return 0 | ||
;; | ||
|
||
'test') | ||
COMPREPLY=($(compgen -W "$(find /opt/box/cli/tests -maxdepth 1 -type f -printf '%f\n')" -- $cur)) | ||
return 0 | ||
;; | ||
|
||
'help') | ||
COMPREPLY=($(compgen -W "" -- $cur)) | ||
return 0 | ||
;; | ||
esac | ||
|
||
COMPREPLY=($(compgen -W "database container startup restart shutdown status shell version self-update test help" -- $cur)) | ||
} | ||
complete -F _box box | ||
|
||
|
||
|
||
################################################################################ | ||
# Command completion for 'box container' | ||
_box_container() | ||
{ | ||
local cur=${COMP_WORDS[COMP_CWORD]} | ||
local prev=${COMP_WORDS[COMP_CWORD-1]} | ||
|
||
case "$prev" in | ||
'stop'|'restart') | ||
_box_container_running | ||
return 0 | ||
;; | ||
|
||
'start'|'restart'|'rm'|'clean'|'refresh') | ||
_box_container_stopped | ||
return 0 | ||
;; | ||
|
||
'ls'|'inspect'|'log') | ||
_box_container_all | ||
return 0 | ||
;; | ||
|
||
'pull'|'install') | ||
_box_container_dockerhub | ||
return 0 | ||
;; | ||
esac | ||
|
||
COMPREPLY=($(compgen -W "install ls start stop rm clean refresh update show shutdown reallyclean inspect log pull" -- $cur)) | ||
return 0 | ||
} | ||
|
||
_box_container_running() | ||
{ | ||
local cur=${COMP_WORDS[COMP_CWORD]} | ||
|
||
COMPREPLY=($(compgen -W "$(docker container ls -af label=container.project=wplib -f status=running --format='{{.Image}}')" -- $cur)) | ||
return 0 | ||
} | ||
|
||
|
||
_box_container_stopped() | ||
{ | ||
local cur=${COMP_WORDS[COMP_CWORD]} | ||
|
||
COMPREPLY=($(compgen -W "$(docker container ls -af label=container.project=wplib -f status=created -f status=exited --format='{{.Image}}')" -- $cur)) | ||
return 0 | ||
} | ||
|
||
|
||
_box_container_all() | ||
{ | ||
local cur=${COMP_WORDS[COMP_CWORD]} | ||
|
||
COMPREPLY=($(compgen -W "$(docker container ls -af label=container.project=wplib --format='{{.Image}}')" -- $cur)) | ||
return 0 | ||
} | ||
|
||
|
||
_box_container_dockerhub() | ||
{ | ||
local IMAGES | ||
local IMAGE_NAME | ||
local VERSIONS | ||
local IMAGE_VERSION | ||
local REPLY | ||
local cur=${COMP_WORDS[COMP_CWORD]} | ||
|
||
IMAGES="`jq -r '.results|.[]|.name' /opt/box/etc/respositories.json`" | ||
for IMAGE_NAME in $IMAGES | ||
do | ||
VERSIONS="`jq -r '.results|.[]|.name' /opt/box/etc/images/${IMAGE_NAME}.json`" | ||
for IMAGE_VERSION in $VERSIONS | ||
do | ||
REPLY="$REPLY wplib/${IMAGE_NAME}:$IMAGE_VERSION" | ||
done | ||
|
||
done | ||
|
||
COMPREPLY=($(compgen -W "$REPLY" -- $cur)) | ||
return 0 | ||
} | ||
|
||
|