Skip to content

Commit

Permalink
Update system_report.sh
Browse files Browse the repository at this point in the history
Summary:
Moves system_report.sh to a bin/ directory
Adds khan-dotfiles/bin to the PATH so system_report.sh can be called from anywhere
Creates a symlink so it can continue to be used as it previously was
Adds a .txt extension to the file created
Records the OSX version (ie 10.15 for Catalina)
Warns if the version is out of date
Records the result of `make check_setup` in the webapp directory

Issue: INFRA-5842

Test Plan:
Run system_report.sh from khan-dotfiles
Run system_report.sh from webapp

Reviewers: #devops, ebrown, boris

Reviewed By: #devops, ebrown, boris

Subscribers: boris, ebrown, csilvers

Differential Revision: https://phabricator.khanacademy.org/D68569
  • Loading branch information
dbraley committed Jan 19, 2021
1 parent 80267e8 commit b950e25
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 160 deletions.
1 change: 1 addition & 0 deletions .profile.khan
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export PATH="$KA_DEVROOT/our-lovely-cli/bin:$PATH"
export PATH="$KA_DEVROOT/ka-clone/bin:$PATH"
export PATH="$KA_DEVROOT/khan-linter/bin:$PATH"
export PATH="$KA_DEVROOT/google-cloud-sdk/bin:$PATH"
export PATH="$KA_DEVROOT/khan-dotfiles/bin:$PATH"

export MANPATH="$KA_DEVROOT/our-lovely-cli/man:$MANPATH"

Expand Down
185 changes: 185 additions & 0 deletions bin/system_report.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
#!/bin/bash

# This file represents the entrypoint of a tool create a report of the local
# development environment, for the purpose of identifying potential problems.

# Make a temporary file to dump the report into
tmpfile="$(mktemp -u /tmp/system-report.XXXXXX).txt"
: >"$tmpfile"
echo "Putting report into tempfile ${tmpfile}"

# logging functions
header() {
printf "\n\t%s:\n" "$1" >> "${tmpfile}"
}

kv() {
printf "%-20s %s\n" "$1:" "$2" >> "${tmpfile}"
}

kv_multiline() {
printf "%s\n%s\n\n" "$1:" "$2" >> "${tmpfile}"
}

tool_version() {
tool=$1
version_cmd=$2
if loc="$(which "${tool}")" ; then
# If it's a link, show where it links to
if [[ -L "${loc}" ]] ; then
loc="${loc} -> $(readlink "${loc}")"
fi
kv "${tool}" "$("${tool}" "${version_cmd}" 2>&1) (${loc})"
else
kv "${tool}" "Not present!"
fi
}


# System level information
header "System"
uname_os="$(uname -s)"
kv "OS" "${uname_os}"
kv "Release" "$(uname -r)"
kv "Hardware" "$(uname -m)"
kv "Hostname" "$(uname -n)"
kv "Version" "$(uname -v)"

# OSX Version
if [ "${uname_os}" = "Darwin" ]; then
header "OSX"
# Should be 10.15.x or 11.x
osx_version=$(sw_vers -productVersion)
kv "Version" "${osx_version}"
# We support EXACTLY 10.15.x and 11.x.x
if echo "$osx_version" | grep -q -v -e '^10.15' -e '^11' ; then
kv "!!! WARNING!!!" "Please update to OSX 10.15 Catalina!!!"

fi
fi

# Environmental information
header "Environment"
kv "User" "$(whoami)"
kv "Shell" "$SHELL"
kv "PATH" "$PATH"


# XCode, a big pain point on Mac
if [ "${uname_os}" = "Darwin" ]; then
header "OSX - XCode"
# DEV-245 - Should be 11.x
kv_multiline "Xcode Version" "$(xcodebuild -version)"
kv_multiline "Avaliable Versions" "$(system_profiler SPDeveloperToolsDataType)"
fi

# TODO(dbraley): (A) check profile

header "GCC"
kv "LDFLAGS" "$LDFLAGS"
kv "LD_LIBRARY_PATH" "$LD_LIBRARY_PATH"
kv "CPPFLAGS" "$CPPFLAGS"
kv "CFLAGS" "$CFLAGS"

# Brew, another pain point on Mac
header "Brew"
tool_version brew --version
if which brew >/dev/null ; then
kv_multiline "Brew Installs" "$(brew list --formula -l)"
kv_multiline "Brew Services" "$(brew services list)"
kv_multiline "Brew Doctor Output" "$(brew doctor 2>&1)"
fi

# TODO(dbraley): (m) check wget

header "Node/JS"
tool_version node --version
tool_version npm --version
tool_version yarn --version

header "Go"
tool_version go version

header "Rust"
tool_version cargo --version

header "PostgreSQL"
tool_version postgres --version
tool_version psql --version

# TODO(dbraley): (A) check nginx
# TODO(dbraley): (A) check redis
# TODO(dbraley): (A) check image_utils

header "Java"
tool_version java -version

# TODO(dbraley): (A) check protoc
# TODO(dbraley): (A) check watchman
# TODO(dbraley): (A) check mac apps

# Python tooling
header "Python"
tool_version python --version
tool_version python2 --version
tool_version python3 --version
tool_version pip --version
kv "VIRTUAL_ENV" "$VIRTUAL_ENV"
kv "sys.path" "$(python2 -c 'import sys; print sys.path')"

# TODO(dbraley): (l) check software-properties-common
# TODO(dbraley): (l) check apt-trasport-https
# TODO(dbraley): (l) check libfreetype etc
# TODO(dbraley): (l) check libncurses-dev, libreadline-dev
# TODO(dbraley): (l) check clock
# TODO(dbraley): (l) check inotify
# TODO(dbraley): (l) check curl

# GCloud
header "GCloud"
tool_version gcloud --version

# TODO(dbraley): (A) check repos

# Make sure the user can access the things they need
header "File Access Rights"
# DEV-246 - This should be empty
if [ -d "${VIRTUAL_ENV}" ] ; then
kv_multiline "Root Owned VEnv Files" "$(find "$VIRTUAL_ENV" -user root -ls)"
fi

# TODO(dbraley): (m) check readline validity (DEV-242,238)
# TODO(dbraley): (A) check secrets.py validity (DEV-241)

header "SSH Config"
kv "SSH_AUTH_SOCK" "${SSH_AUTH_SOCK}"
kv_multiline "Fingerprints" "$(ssh-add -l)"

header "Git Config"
tool_version git --version
# DEV-232
kv "user.email" "$(git config user.email)"
kv "ssh access" "$(ssh -o StrictHostKeyChecking=no -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null -T [email protected] 2>&1)"

header "Arcanist"
tool_version arc version

header "Required Tools"
# DEV-229
tool_version jq --version

header "OpenSSL"
tool_version openssl version

header "Routing"
kv_multiline "Hosts File" "$(cat /etc/hosts)"

header "Webapp"
# Allow user to specifiy WEBAPP_ROOT
: "${WEBAPP_ROOT:=$HOME/khan/webapp}"
kv "WEBAPP_ROOT" "$WEBAPP_ROOT"
if [ -d "$WEBAPP_ROOT" ]; then
kv_multiline "make check_setup" "$( (cd "$WEBAPP_ROOT" && make check_setup) )"
else
kv "!!! WARNING !!!" "$WEBAPP_ROOT could not be found!"
fi
160 changes: 0 additions & 160 deletions system_report.sh

This file was deleted.

1 change: 1 addition & 0 deletions system_report.sh

0 comments on commit b950e25

Please sign in to comment.