Last active
June 23, 2022 15:00
-
-
Save DonRichards/f23d333517db7a8da09df2a5641b36ec to your computer and use it in GitHub Desktop.
isle-dc debug info
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
#!/usr/bin/env bash | |
# To run this script | |
# bash <(curl -sL https://gist.githubusercontent.com/DonRichards/f23d333517db7a8da09df2a5641b36ec/raw/isle-dc_debug_info.sh) | tee output.txt | |
echo -e "\n\n--------- --------- ---------" | |
CURRENT_DIRECTORY_NAME=$(basename "$PWD") | |
# Check if the current directory contains isle-dc in the name | |
if [[ $CURRENT_DIRECTORY_NAME == *"isle-dc"* ]]; then | |
echo "Current directory is isle-dc" | |
else | |
echo "Run this from the root directory of isle-dc" | |
exit 1 | |
fi | |
echo -e "\n\n--------- Operating System" | |
uname -a | |
echo -e "\n\n--------- Free Disk Space" | |
echo "Free: $(df -Ph . | tail -1 | awk '{print $4}')" | |
echo -e "\n\n--------- Git information" | |
which git | |
git --version | |
echo -e "\n\n--------- MAKE information" | |
which make | |
make --version | |
echo -e "\n\n--------- Docker information" | |
echo "docker-compose vs docker compose versions" | |
which docker-compose | |
docker-compose version | |
which docker | |
docker compose version | |
echo "Docker Debug Output" | |
docker --debug info | |
echo -e "\n\n--------- Current state of the repository (git status)" | |
RAW_REPO_URL=$(git config --get remote.origin.url) | |
re="^(https|git)(:\/\/|@)([^\/:]+)[\/:]([^\/:]+)\/(.+)(.git)*$" | |
if [[ $RAW_REPO_URL =~ $re ]]; then | |
protocol=${BASH_REMATCH[1]} | |
separator=${BASH_REMATCH[2]} | |
hostname=${BASH_REMATCH[3]} | |
ORG=${BASH_REMATCH[4]} | |
REPO=${BASH_REMATCH[5]%%.git} | |
fi | |
ORIGIN_HEAD_REFERENCE=$(git symbolic-ref refs/remotes/origin/HEAD | cut -d '/' -f4) | |
LATEST_HASH="$(curl -s -L https://api.github.com/repos/${ORG}/${REPO}/git/refs/heads/${ORIGIN_HEAD_REFERENCE} | grep sha | cut -d '"' -f 4 | cut -c 1-7)" | |
echo "Most recent HASH: $LATEST_HASH" | |
if [[ "$(git log -100 --pretty=format:%h)" == *"${LATEST_HASH}"* ]]; then | |
echo "The most recent Github commit is in the git logs!" | |
else | |
echo "The most recent Github commit is missing from the git logs." | |
fi | |
echo -e "\n\n--------- List the docker-compose files" | |
ls -B | grep docker-compose | |
echo -e "\n\n--------- List the docker images" | |
docker images | |
echo -e "\n\n--------- Checking if docker images are up to date" | |
echo -e "If this script is not working, try using a VPN to avoid rate limits\n" | |
DOCKER_IMAGES=$(docker images --format "{{.Repository}}" | sort | uniq) | |
for image in $DOCKER_IMAGES; do | |
CURRENT_TAG=$(docker images --format "{{.ID}}" $image) | |
LATEST_TAG=$(docker images -q $image) | |
if [[ $CURRENT_TAG != $LATEST_TAG ]]; then | |
echo "Current tag does not match the latest: $CURRENT_TAG vs $LATEST_TAG" | |
else | |
echo -e "$(docker images --format "{{.Repository}}" $image) \n\t\t\t┗━━━━━━━━━━━━━━━━━━━━━━━━━━━ is current" | |
fi | |
done | |
echo -e "\n\n--------- .env file contents" | |
[ -f .env ] && cat .env || echo "No .env file found" | |
if [ -d "codebase" ]; then | |
echo -e "\n\n--------- Check the file permissions" | |
gitCHMODstate=$(git config --get core.fileMode) | |
if [[ $gitCHMODstate == "false" ]]; then | |
git config core.fileMode true | |
fi | |
DEFAULT_BRANCH_NAME=$(git branch -r --points-at refs/remotes/origin/HEAD | grep '\->' | cut -d' ' -f5 | cut -d/ -f2) | |
git ls-tree -r $(git rev-parse --short $DEFAULT_BRANCH_NAME) | while read mode _ _ fpath; do git diff "$fpath"; done | |
if [[ $gitCHMODstate == "false" ]]; then | |
git config core.fileMode false | |
fi | |
echo -e "\n\n--------- Is the vendor directory empty?" | |
[ "$(docker-compose exec drupal bash -lc 'ls -A vendor/')" ] || echo "Vendor directory is empty, composer needs to run to install dependencies" | |
[ -d "$(docker-compose exec drupal bash -lc 'ls -A vendor/')" ] || echo "Vendor directory is missing, composer needs to run to install dependencies" | |
echo -e "\n\n--------- Docker Container Error logs" | |
[ "$(docker container ls --format "{{.Names}}" | grep drupal)" ] && docker container logs $(docker container ls --format "{{.Names}}" | grep drupal) --details | |
echo -e "\n\n--------- Docker Compose Error logs" | |
docker-compose logs | grep -i 'error\|fail\|\s404\|warn\|not found\|exception\|authorize\|abort\|kill' | |
else | |
echo -e "\n\n--------- Codebase directory does not exist, skipping permissions check, composer install checks, and error logs" | |
fi | |
echo -e "\n\n--------- Done" | |
echo -e "\n\n Go to https://gist.github.com and paste output.txt in a new public gist and post that gist URL into the ticket or Slack channel." | |
cat <<'EOF' | |
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | |
88888888888888888888888888888888888888888888888888888 | |
8888"""""""""""""""8888888888888888888888888888888888 | |
8888 8888888888888888888888888888888888 | |
8888 8888888888888888888888888888888888 | |
8888 888888888888888888888888888888888" | |
8888aaaaaaaaaaaaaaa888888888888888888888888888888888a | |
88888888888888888888888888888888888888888888888888888 | |
88888888888888888888888888888888888888888888888888888 | |
88888888888888888888888888888888888888888888888888888 | |
88888888888888888888888":::::"88888888888888888888888 | |
888888888888888888888::;gPPRg;::888888888888888888888 | |
88888888888888888888::dP' `Yb::88888888888888888888 | |
88888888888888888888::8) (8::88888888888888888888 | |
88888888888888888888;:Yb dP:;88( )888888888888888 | |
888888888888888888888;:"8ggg8":;888888888888888888888 | |
88888888888888888888888aa:::aa88888888888888888888888 | |
88888888888888888888888888888888888888888888888888888 | |
88888888888888888888888888888888888888888888888888888 | |
88888888888888888888888888"88888888888888888888888888 | |
8888888888888888888888888:::8888888888888888888888888 | |
8888888888888888888888888:::8888888888888888888888888 | |
8888888888888888888888888:::8888888888888888888888888 | |
8888888888888888888888888:::8888888888888888888888888 | |
8888888888888888888888888:::8888888888888888888888888 | |
88888888888888888888888888a88888888888888888888888888 | |
"""""""""""""""""""' `"""""""""' `""""""""""""""""""" | |
More information on this script can be found at https://gist.github.com/DonRichards/f23d333517db7a8da09df2a5641b36ec | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment