Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add host utility scripts #6

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions bin/update-repos
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

function update_repos() {
echo "UPDATING PLUGIN AND THEME REPOSITORIES"
echo ""

local WP_CONTENT_DIR
WP_CONTENT_DIR=$(pwd)

local DIRECTORIES=(
"${WP_CONTENT_DIR}/client-mu-plugins"
"${WP_CONTENT_DIR}/mu-plugins"
"${WP_CONTENT_DIR}/plugins"
"${WP_CONTENT_DIR}/plugins/pmc-plugins"
)

# Find theme repos.
while IFS= read -r -d $'\0'; do
DIRECTORIES+=("$REPLY")
done < <(find "${WP_CONTENT_DIR}/themes" -maxdepth 2 -type d -iname "pmc-*" -print0)

# Check each directory and update if possible.
for DIR in "${DIRECTORIES[@]}"; do
echo "${DIR}"
if \
[ -z "$(git -C "${DIR}" -c core.fileMode=false status --porcelain)" ] && \
[ "$(git -C "${DIR}" remote show origin | grep 'HEAD branch' | sed 's/.*: //')" == "$(git -C "${DIR}" rev-parse --abbrev-ref HEAD)" ] \
; then
echo " -> Updating!"
git -C "${DIR}" -c core.fileMode=false pull --quiet --ff-only
else
echo " -> Not updating; directory either isn't on the default branch, or local changes were detected."
fi
done

echo ""
echo "DONE"
}

update_repos
12 changes: 12 additions & 0 deletions bin/vcd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

REL_PATH=$(pwd)

cd "${VVV_INSTANCE_DIR}" || exit 1

VAGRANT_PATH=${REL_PATH/$VVV_INSTANCE_DIR/\/srv}

CMD="cd ${VAGRANT_PATH}; bash"
printf "%s\n\n" "$CMD"

vagrant ssh -c "${CMD}; echo"
12 changes: 12 additions & 0 deletions bin/wp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

REL_PATH=$(pwd)

cd "${VVV_INSTANCE_DIR}" || exit 1

VAGRANT_PATH=${REL_PATH/$VVV_INSTANCE_DIR/\/srv}

CMD="cd ${VAGRANT_PATH}; wp $*"
printf "%s\n\n" "$CMD"

vagrant ssh -c "${CMD}; echo"
20 changes: 20 additions & 0 deletions bin/xdebug
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

cd "${VVV_INSTANCE_DIR}" || exit 1

case $1 in
on)
CMD="/srv/config/homebin/xdebug_on"
;;

off)
CMD="/srv/config/homebin/xdebug_off"
;;

*)
echo "Specify 'on' or 'off' as the first argument."
exit 1
;;
esac

vagrant ssh -c "export PATH=/srv/config/homebin:$PATH; ${CMD}"
2 changes: 1 addition & 1 deletion phpcs/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
PHPCS_DIR="/srv/www/phpcs"
PHPCS_CMD="${PHPCS_DIR}/bin/phpcs"

vvv_info " * Removing PHCPS provisioned by VVV..."
vvv_info " * Removing PHPCS provisioned by VVV..."
rm -rf $PHPCS_DIR

vvv_info " * Install PMC Codesniffer..."
Expand Down