Skip to content
This repository was archived by the owner on Jan 25, 2022. It is now read-only.

Commit 2d245b2

Browse files
committed
Added $WPLIB_BOX_CLI_DEBUG_LOG_FILE and updated box self-update to use it.
1 parent 1125b77 commit 2d245b2

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

commands/self-update

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
# all the git commands.
77
# This will be exec at the very end ensuring itself wont be changed during the update.
88

9-
109
# Don't reference common variables as they may not exist.
1110
WPLIB_BOX_SCRIPTS_REPO="https://github.com/wplib/box-scripts"
1211
WPLIB_BOX_CLI_DIR="/opt/box"
1312
WPLIB_BOX_CLI_VERSION_FILE="/opt/box/version"
13+
WPLIB_BOX_CLI_DEBUG_LOG_FILE="/opt/box/log/cli-debug.log"
1414
DEFAULT_VERSION="master"
1515

16-
1716
# Determine version to run.
1817
if [ "$1" == "" ]
1918
then
@@ -29,16 +28,15 @@ fi
2928
echo "# WPLib-Box: Updating ${WPLIB_BOX_CLI_DIR} with version ${VERSION}"
3029
if [ -d "${WPLIB_BOX_CLI_DIR}" ]
3130
then
32-
if [ -d "${WPLIB_BOX_CLI_DIR}-LAST" ]
33-
then
34-
sudo rm -rf "${WPLIB_BOX_CLI_DIR}-LAST"
31+
if [ -d "${WPLIB_BOX_CLI_DIR}-LAST" ] ; then
32+
sudo rm -rf "${WPLIB_BOX_CLI_DIR}-LAST" >> $WPLIB_BOX_CLI_DEBUG_LOG_FILE
3533
fi
36-
sudo mv "${WPLIB_BOX_CLI_DIR}" "${WPLIB_BOX_CLI_DIR}-LAST"
34+
sudo mv "${WPLIB_BOX_CLI_DIR}" "${WPLIB_BOX_CLI_DIR}-LAST" >> $WPLIB_BOX_CLI_DEBUG_LOG_FILE
3735
fi
38-
sudo mkdir -p ${WPLIB_BOX_CLI_DIR}
39-
sudo git clone -q ${WPLIB_BOX_SCRIPTS_REPO} ${WPLIB_BOX_CLI_DIR} > /dev/null
40-
cd ${WPLIB_BOX_CLI_DIR}
41-
sudo git checkout -q --force ${VERSION} > /dev/null
36+
sudo mkdir -p ${WPLIB_BOX_CLI_DIR} >> $WPLIB_BOX_CLI_DEBUG_LOG_FILE
37+
sudo git clone -q ${WPLIB_BOX_SCRIPTS_REPO} ${WPLIB_BOX_CLI_DIR} >> $WPLIB_BOX_CLI_DEBUG_LOG_FILE
38+
cd ${WPLIB_BOX_CLI_DIR} >> $WPLIB_BOX_CLI_DEBUG_LOG_FILE
39+
sudo git checkout -q --force ${VERSION} >> $WPLIB_BOX_CLI_DEBUG_LOG_FILE
4240

4341
if [ ! -f "${WPLIB_BOX_CLI_VERSION_FILE}" ]
4442
then
@@ -47,8 +45,7 @@ then
4745
echo $VERSION > "${WPLIB_BOX_CLI_VERSION_FILE}"
4846
fi
4947

50-
sudo chown -R vagrant:vagrant "${WPLIB_BOX_CLI_DIR}"
51-
48+
sudo chown -R vagrant:vagrant "${WPLIB_BOX_CLI_DIR}" >> $WPLIB_BOX_CLI_DEBUG_LOG_FILE
5249

5350

5451
exit

includes/constants

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ export WPLIB_BOX_PLUGINS_DIR=$(find_wp_plugins_dir)
3131
export WPLIB_BOX_MU_PLUGINS_DIR=$(find_wp_mu_plugins_dir)
3232
export WPLIB_BOX_VENDOR_DIR=$(find_composer_vendor_dir)
3333

34+
export WPLIB_BOX_DIR="/vagrant"
35+
36+
export WPLIB_BOX_LOG_DIR="${WPLIB_BOX_CLI_DIR}/log"
37+
export WPLIB_BOX_CLI_DEBUG_LOG_FILE="${WPLIB_BOX_LOG_DIR}/cli-debug.log"
38+
39+
#
40+
# Deleted once the box has a log dir and an empty cli-debug.log
41+
#
42+
mkdir -p "${WPLIB_BOX_LOG_DIR}"
43+
chown vagrant:vagrant "${WPLIB_BOX_LOG_DIR}"
44+
touch "${WPLIB_BOX_CLI_DEBUG_LOG_FILE}"
3445

3546

3647
#

0 commit comments

Comments
 (0)