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 #19 from wplib/0.16.0
0.16.0
- Loading branch information
Showing
91 changed files
with
1,006 additions
and
835 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,18 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo | ||
echo WPLib Box CLI Usage: | ||
echo | ||
echo " - box <command>" | ||
echo | ||
echo WPLib Box CLI Commands: | ||
echo | ||
for file in $WPLIB_BOX_COMMANDS_DIR/*; do | ||
if [ -f "${file}" ]; then | ||
basename=$(basename "$file") | ||
echo " - ${basename}" | ||
fi | ||
done | ||
echo | ||
echo IMPORTANT! These commands WILL BE CHANGING in a future release of WPLib Box. Be warned! | ||
cat <<EOF | ||
${YELLOW}WPLib Box ${GREEN}CLI${RESET} usage: | ||
box ${GREEN}database${RESET} [<args>] - Manage databases. | ||
box ${GREEN}container${RESET} [<args>] - Manage Docker containers. | ||
box ${GREEN}start${RESET} - Start Docker containers found in project.json's services object. | ||
box ${GREEN}restart${RESET} - Restart Docker containers found in project.json's services object. | ||
box ${GREEN}shutdown${RESET} - Shutdown all Docker containers. | ||
box ${GREEN}status${RESET} - Output status of WPLib Box's standard containers. | ||
box ${GREEN}version${RESET} - Display the current version of this WPLib Box VM. | ||
box ${GREEN}self-update${RESET} - Update this CLI tool to the latest version for this Box version. | ||
box ${GREEN}test${RESET} - Update this CLI tool to the latest version for this Box version. | ||
box [${GREEN}help${RESET}] - Display the above information. | ||
EOF |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
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,6 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
# source "${WPLIB_BOX_COMMANDS_DIR}/readJSON" | ||
# box container stop $mail $proxy $database $webserver $processvm $kvstore $cache $sqladmin $webadmin | ||
box container shutdown | ||
|
||
source "${WPLIB_BOX_INCLUDES_DIR}/read-json" | ||
box container stop $database $webserver $processvm $kvstore $cache $sqladmin $webadmin | ||
box container shutdown |
Empty file.
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,4 +1,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
source "${WPLIB_BOX_COMMANDS_DIR}/readJSON" | ||
source "${WPLIB_BOX_INCLUDES_DIR}/read-json" | ||
box container start $mail $proxy $database $webserver $processvm $kvstore $cache $sqladmin $webadmin | ||
|
||
if [[ ! -e "${WPLIB_BOX_CLI_DIR}/PROVISION" && -e "${WPLIB_BOX_SQL_DIR}/provision.sql" ]] ; then | ||
|
||
sudo bash -c "date +'%Y%m%d %H%M%S' > \"${WPLIB_BOX_CLI_DIR}/PROVISION\"" | ||
box database import provision.sql | ||
|
||
# | ||
# @todo check return value and if error delete ${WPLIB_BOX_CLI_DIR}/PROVISION | ||
# | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
source "${WPLIB_BOX_COMMANDS_DIR}/readJSON" | ||
source "${WPLIB_BOX_INCLUDES_DIR}/read-json" | ||
box container ls $database $webserver $processvm $kvstore $cache $sqladmin $webadmin |
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,196 @@ | ||
#!/bin/bash | ||
# | ||
# Master test script. | ||
# | ||
|
||
|
||
DEFAULT_PROJECT="wplib" | ||
|
||
# Return codes from functions. | ||
RETURN_OK="0" | ||
RETURN_NOK="1" | ||
RETURN_NOSCRIPT="2" | ||
RETURN_NOEXEC="3" | ||
VALID_RETURN=42 | ||
|
||
|
||
exec_cmd() | ||
{ | ||
EXECTMPFILE="`mktemp /tmp/BoxTest.XXX`" | ||
|
||
echo "$ECHO_PREFIX ${RESET} - EXEC: \"${CYAN}$@${RESET}\"" | ||
$@ >& $EXECTMPFILE | ||
RETURN="$?" | ||
if [ "$RETURN" == "$RETURN_OK" ] | ||
then | ||
echo "$ECHO_PREFIX ${RESET} - ${GREEN}EXEC: RETURN($RETURN)${RESET}" | ||
cat $EXECTMPFILE | sed "s/^/$ECHO_PREFIX ${RESET} - ${GREEN}EXEC:${RESET} /" | ||
else | ||
echo "$ECHO_PREFIX ${RESET} - ${RED}EXEC: RETURN($RETURN)${RESET}" | ||
cat $EXECTMPFILE | sed "s/^/$ECHO_PREFIX ${RESET} - ${RED}EXEC:${RESET} /" | ||
fi | ||
|
||
return $RETURN | ||
} | ||
|
||
|
||
echo_info() | ||
{ | ||
echo "$ECHO_PREFIX ${RESET} - INFO: $@" | ||
|
||
return 0 | ||
} | ||
|
||
|
||
echo_warning() | ||
{ | ||
echo "$ECHO_PREFIX ${RESET} - ${YELLOW}INFO: $@" | ||
|
||
return 1 | ||
} | ||
|
||
|
||
echo_error() | ||
{ | ||
echo "$ECHO_PREFIX ${RESET} - ${RED}INFO: $@" | ||
|
||
return 2 | ||
} | ||
|
||
|
||
################################################################################ | ||
# OK. This is where things get funky, so I need to explain the flow | ||
# 1. THIS script will call scripts within /opt/box/tests. | ||
# 2. Each of those scripts will SOURCE THIS script to pick up some common functions. | ||
# | ||
# So place everything above here that should be included in called scripts. | ||
# This means the following will avoid an endless loop. | ||
if [ "$AVOID_LOOP" == "OK" ] | ||
then | ||
return | ||
fi | ||
AVOID_LOOP="OK" | ||
export AVOID_LOOP | ||
|
||
|
||
ctrl_c() | ||
{ | ||
tput sgr0 | ||
echo "" | ||
echo "$ECHO_PREFIX Aborting script." | ||
exit | ||
} | ||
|
||
trap ctrl_c INT | ||
|
||
|
||
error_nts() | ||
{ | ||
RETURN="$?" | ||
echo "$ECHO_PREFIX ${YELLOW}Unknown command.${RESET}" | ||
return $RETURN | ||
} | ||
|
||
|
||
d_ls() | ||
{ | ||
for SCRIPT in $ALLSCRIPTS | ||
do | ||
if [[ -x "/opt/box/tests/$SCRIPT" && -f "/opt/box/tests/$SCRIPT" ]] | ||
then | ||
STDOUT="`/opt/box/tests/$SCRIPT info`" | ||
if [ "$?" == "$VALID_RETURN" ] | ||
then | ||
echo "$STDOUT" | ||
fi | ||
fi | ||
done | ||
|
||
return $RETURN_OK | ||
} | ||
|
||
|
||
d_exec() | ||
{ | ||
SCRIPT="$1" | ||
shift | ||
|
||
if [ ! -r "/opt/box/tests/$SCRIPT" ] | ||
then | ||
echo "$ECHO_PREFIX ${YELLOW}NO SCRIPT - ${CYAN}${SCRIPT}${RESET}" | ||
return $RETURN_NOSCRIPT | ||
fi | ||
|
||
if [ ! -x "/opt/box/tests/$SCRIPT" ] | ||
then | ||
echo "$ECHO_PREFIX ${YELLOW}NO EXEC - ${CYAN}${SCRIPT}${RESET}" | ||
return $RETURN_NOEXEC | ||
fi | ||
|
||
echo "################################################################################" | ||
echo "$ECHO_PREFIX ${YELLOW}Run${RESET} - ${CYAN}${SCRIPT}${RESET}" | ||
/opt/box/tests/$SCRIPT "$@" | ||
RETURN="$?" | ||
if [ "$RETURN" == "$RETURN_OK" ] | ||
then | ||
echo "$ECHO_PREFIX ${GREEN}OK${RESET} - ${CYAN}${SCRIPT}${RESET}" | ||
else | ||
echo "$ECHO_PREFIX ${RED}FAILED($RETURN)${RESET} - ${CYAN}${SCRIPT}${RESET}" | ||
fi | ||
echo "" | ||
|
||
return $RETURN_OK | ||
} | ||
|
||
|
||
d_help() | ||
{ | ||
cat <<EOF | ||
box test - Show this help. | ||
box test ${GREEN}list${RESET} - List all scripts in /opt/box/tests. | ||
box test ${GREEN}run${RESET} - Run all tests in /opt/box/tests. | ||
box test ${GREEN}run [script]${RESET} - Run a specific test. | ||
EOF | ||
} | ||
|
||
|
||
################################################################################ | ||
ALLSCRIPTS="`ls -1 /opt/box/tests`" | ||
|
||
CMD="$1" | ||
shift | ||
SCRIPTS="$@" | ||
|
||
case $CMD in | ||
'list'|'ls') | ||
d_ls | ||
;; | ||
|
||
''|'help') | ||
d_help | ||
;; | ||
|
||
'run') | ||
if [ "$1" == "" ] | ||
then | ||
SCRIPTS="$ALLSCRIPTS" | ||
fi | ||
;; | ||
|
||
*) | ||
error_nts | ||
d_help | ||
exit 1 | ||
;; | ||
esac | ||
|
||
|
||
for SCRIPT in $SCRIPTS | ||
do | ||
d_exec $SCRIPT | ||
done | ||
|
||
rm -f /tmp/BoxTest.* | ||
|
||
exit 0 | ||
|
File renamed without changes.
Oops, something went wrong.