Cleanup sz-doctor's output

This commit is contained in:
Gal Szkolnik 2022-06-20 08:28:50 -04:00
parent 5a4d780cbd
commit 3fe408a661
1 changed files with 33 additions and 27 deletions

View File

@ -6,6 +6,7 @@ SUGGESTED=()
APT_OK=$([[ -e $(type -fP apt) ]] && [[ -x $(type -fP apt | head -1) ]] && echo 'true' || echo 'false')
# TODO: Implement a test for specific Package Sources per package check
PACKAGE_SOURCES=$( \
grep -h ^deb /etc/apt/sources.list /etc/apt/sources.list.d/* \
| sed 's/\[.*\] //; s/^deb //' \
@ -71,45 +72,50 @@ function check-exist() {
#### Output starts here
PROD_NAME=$( sudo dmidecode --type 200 2> /dev/null | tail +5 | tail -2 | head -1 | awk '{print $1}')
printf "%-15s %-20s %-44s %-20s\n" "Manufacturer" "Model family" "CPU" "BIOS Firmware"
printf "%-15s %-20s %-44s %-20s\n" "$(
MACHINE_INFO_FORMAT='%-14s %-19s %-13s %-11s %s\n'
MACHINE_INFO_FIELDS=("Manufacturer" "Model family" "Model/MTM" "S/N" "BIOS Firmware")
printf "$MACHINE_INFO_FORMAT" "${MACHINE_INFO_FIELDS[@]}"
printf "$MACHINE_INFO_FORMAT" "$(
sudo dmidecode -s system-manufacturer
)" "$(sudo dmidecode -s system-family
)" "$(sudo dmidecode -s processor-version
)" "$(sudo dmidecode -s bios-version)"
printf " Model ID (or MTM): %-44s S/N: %s\n" "${PROD_NAME:-$(
)" "${PROD_NAME:-$(
sudo dmidecode -s system-product-name
)}" "$(sudo dmidecode -s system-serial-number)"
)}" "$(sudo dmidecode -s system-serial-number
)" "$(sudo dmidecode -s bios-version)"
printf " CPU: %s\n" "$(
sudo dmidecode -s processor-version
)"
echo ''
echo "Shell: $SHELL"
echo "Shell: $SHELL (availabe: $(echo $(cat /etc/shells | grep -v 'shells:' | sed "s/^\(.*\/\)*//" | sort -u)))"
echo ''
#_ALT_EDITOR=$( update-alternatives --get-selections | grep '^editor' | sed 's:^editor\W\+\w\+\W\+/:/:' )
_ALT_EDITOR=$( update-alternatives --query editor | grep '^Value:' | cut -d: -f2 | sed 's: *\(.*\) *:\1:g' )
print-result "System prefered editor" "$_ALT_EDITOR"
print-result "System prefered editor" "$_ALT_EDITOR" "(Available: $(echo $(update-alternatives --query editor | grep Alternative: | cut -d: -f2 | sed 's/^\(.*\/\)//')))"
( echo $_ALT_EDITOR | grep "nano$" >/dev/null ) && echo "Recommended to run: update-alternatives --set editor $(type -fP nvim vim.basic vim.tiny vi | head -1)"
echo "editors found:"
update-alternatives --query editor | grep Alternative: | cut -d: -f2
echo ''
print-result 'Executable `apt`' $(test-print $APT_OK "Found" "Missing") "$(test-print $APT_OK '' "$(printf 'repair by running:\n%-41sfix-apt.sh')" )"
echo ''
check-exist "Byobu" "/usr/bin/byobu-launch" || MISSING_APT_PACKAGES+=('byobu')
check-exist "oh-my-posh"
check-exist "~/.poshtheme.omp.json" "~/.poshtheme.omp.json" "-r"
check-exist "tmux" || MISSING_APT_PACKAGES+=('tmux')
check-exist "git" || MISSING_APT_PACKAGES+=('git')
check-exist "emacs" || MISSING_APT_PACKAGES+=('emacs')
check-exist "monit" || MISSING_APT_PACKAGES+=('monit')
check-exist "direnv" || MISSING_APT_PACKAGES+=('direnv')
check-exist "terraform" '' '' '' "$( \
check-exist 'Byobu' '/usr/bin/byobu-launch' || MISSING_APT_PACKAGES+=('byobu')
check-exist 'oh-my-posh'
check-exist '~/.poshtheme.omp.json' "~/.poshtheme.omp.json" "-r"
check-exist 'tmux' || MISSING_APT_PACKAGES+=('tmux')
check-exist 'git' || MISSING_APT_PACKAGES+=('git')
check-exist 'emacs' || MISSING_APT_PACKAGES+=('emacs')
check-exist 'monit' || MISSING_APT_PACKAGES+=('monit')
check-exist 'direnv' || MISSING_APT_PACKAGES+=('direnv')
check-exist 'terraform' '' '' '' "$( \
[[ -r /usr/share/keyrings/apt.releases.hashicorp.com.gpg ]] \
&& MISSING_APT_PACKAGES+=('terraform') \
|| echo 'fix missing repos (See SUGGESTED below)' \
)" \
|| SUGGESTED+=( 'sz-add-my-apt-repos' '# followed by:' 'sudo apt install terraform', '' )
check-exist "setxkbmap" || MISSING_APT_PACKAGES+=('setxkbmap')
|| SUGGESTED+=(
'sz-add-my-apt-repos' '# followed by:' 'sudo apt install terraform', ''
)
check-exist "setxkbmap" '' '' '(Optional)' \
|| MISSING_APT_PACKAGES+=('setxkbmap')
check-exist "chezmoi" '' '' '' 'wget -O- chezmoi.io/get | bash # or
# wget -O- lksz.me/dotfiles | bash'
check-exist "gcloud" '' '' '' "$( \