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

Commit 1125b77

Browse files
committed
Used "${CONSTANTS}" in box self-update instead of "literal paths."
1 parent de73ed2 commit 1125b77

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

commands/self-update

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
# Don't reference common variables as they may not exist.
1111
WPLIB_BOX_SCRIPTS_REPO="https://github.com/wplib/box-scripts"
1212
WPLIB_BOX_CLI_DIR="/opt/box"
13+
WPLIB_BOX_CLI_VERSION_FILE="/opt/box/version"
1314
DEFAULT_VERSION="master"
1415

1516

1617
# Determine version to run.
1718
if [ "$1" == "" ]
1819
then
19-
VERSION="`cat ${WPLIB_BOX_CLI_DIR}/version`"
20+
VERSION="$(cat "${WPLIB_BOX_CLI_VERSION_FILE}")"
2021
if [ "$DEFAULT_VERSION" == "" ]
2122
then
2223
VERSION=${DEFAULT_VERSION}
@@ -25,7 +26,7 @@ else
2526
VERSION="$1"
2627
fi
2728

28-
echo "# WPLib-Box: Updating /opt/box with version ${VERSION}"
29+
echo "# WPLib-Box: Updating ${WPLIB_BOX_CLI_DIR} with version ${VERSION}"
2930
if [ -d "${WPLIB_BOX_CLI_DIR}" ]
3031
then
3132
if [ -d "${WPLIB_BOX_CLI_DIR}-LAST" ]
@@ -39,16 +40,14 @@ sudo git clone -q ${WPLIB_BOX_SCRIPTS_REPO} ${WPLIB_BOX_CLI_DIR} > /dev/null
3940
cd ${WPLIB_BOX_CLI_DIR}
4041
sudo git checkout -q --force ${VERSION} > /dev/null
4142

42-
if [ ! -f /opt/box/version ]
43+
if [ ! -f "${WPLIB_BOX_CLI_VERSION_FILE}" ]
4344
then
44-
sudo touch /opt/box/version
45-
sudo chown vagrant:vagrant /opt/box/version
46-
echo $VERSION > /opt/box/version
45+
sudo touch "${WPLIB_BOX_CLI_VERSION_FILE}"
46+
sudo chown vagrant:vagrant "${WPLIB_BOX_CLI_VERSION_FILE}"
47+
echo $VERSION > "${WPLIB_BOX_CLI_VERSION_FILE}"
4748
fi
4849

49-
sudo chown -R vagrant:vagrant /opt/box
50-
51-
50+
sudo chown -R vagrant:vagrant "${WPLIB_BOX_CLI_DIR}"
5251

5352

5453

includes/constants

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export WPLIB_BOX_PHPCLI=$(which php7.0)
77
export WPLIB_BOX_DIR="/vagrant"
88
export WPLIB_BOX_CLI_DIR="/opt/box"
99
export WPLIB_BOX_CLI_CMD="/opt/box/box"
10+
export WPLIB_BOX_CLI_VERSION_FILE="/opt/box/version"
11+
1012
export WPLIB_BOX_WEB_ROOT_DIR="/var/www"
1113
export WPLIB_BOX_WATCHERS_DIR="${WPLIB_BOX_WEB_ROOT_DIR}/watchers"
1214

0 commit comments

Comments
 (0)