#!/bin/bash SIAB_LOCATION="$HOME/steem-docker" CONF_LOCATION="$SIAB_LOCATION/data/witness_node_data_dir/config.ini" LOG="/tmp/siab_check.log" SCAN_DIRS=( "$SIAB_LOCATION" "$SIAB_LOCATION/data" "$SIAB_LOCATION/data/witness_node_data_dir" "$SIAB_LOCATION/data/witness_node_data_dir/blockchain" ) print_dirs() { for d in "${SCAN_DIRS[@]}"; do echo " - $d" done } dump_dirs() { for d in "${SCAN_DIRS[@]}"; do echo "Dir: $d" >> "$LOG" ls -lha "$d" >> "$LOG" done } echo "This script will check your server and produce a debug log for someone to assist you." echo "Your full config will be uploaded, but we will replace your signing private key with '5xxxxxxxx', so do not worry about that" echo "The following information will be collected:" echo " - A copy of your steem-docker config @ $CONF_LOCATION (your signing private key(s) will be replaced by 5xxxxxxx in the log) - A directory listing of the following folders (the contents of these files will not be uploaded, only the list of files/folders, including sizes/permissions in each dir) $(print_dirs) - Your RAM usage and swap information (free -m) - The space used/available on all mount points (df -h), including /dev/shm and physical disks - Your Linux kernel version - Your linux distribution version (/etc/lsb-release) - Your docker version (docker -v) - A list of docker images installed (docker images) - A list of all created docker containers, including stopped ones (docker ps -a) " while true; do echo "First, the log will be generated to $LOG. Once the script has finished, we'll ask you if you'd like to upload it to termbin (a paste bin)." echo "You'll have the opportunity to edit the file before it's uploaded if you're concerned about the contents." read -p "Do you want to continue (generate the log. will not upload yet)? (y)es/(n)o) > " yn case $yn in [Yy]* ) break;; [Nn]* ) exit 1 break;; * ) echo "Please answer yes (y) or no (n).";; esac done # CLEANUP echo "Removing old checker log @ $LOG" rm -f "$LOG" &>/dev/null echo "Date Checked: $(date)" >> "$LOG" # CONFIG echo "Reading your config ($CONF_LOCATION) and redacting private key..." CONFDATA=$(sed -e "s/private-key = .*/private-key = 5xxxxxxxxxxxxxxx/" "$CONF_LOCATION") echo " --- CONFIG FILE @ $CONF_LOCATION --- " >> "$LOG" cat <<< "$CONFDATA" >> "$LOG" echo " --- END CONFIG --- " >> "$LOG" # MEMORY echo "Checking memory usage" echo " --- FREE MEMORY / USAGE --- " >> "$LOG" free -m >> "$LOG" echo " --- END MEMORY --- " >> "$LOG" echo "Checking /dev/shm and disk space usage" echo " --- FREE DISK/SHM PLUS USAGE --- " >> "$LOG" df -h >> "$LOG" echo " --- END DISK/SHM --- " >> "$LOG" echo "Checking Operating System version, kernel version, docker images installed, and docker version" echo " ------ VERSION INFORMATION -----" >> "$LOG" uname -a >> "$LOG" cat /etc/lsb-release >> "$LOG" P=$(pwd) cd "$SIAB_LOCATION" echo "SIAB GIT STATUS:" >> "$LOG" git status >> "$LOG" git log | head -n 15 >> "$LOG" echo "DOCKER IMAGES:" >> "$LOG" docker images >> "$LOG" echo "RUNNING CONTAINERS:" >> "$LOG" docker ps -a >> "$LOG" echo "DOCKER VERSION:" >> "$LOG" docker -v >> "$LOG" cd "$P" echo " --- END VERSION INFO --- " >> "$LOG" echo "Checking folder structure of steem-docker" echo " ------ STEEM-DOCKER FOLDER INFO -----" >> "$LOG" dump_dirs echo " --- END FOLDER INFO --- " >> "$LOG" echo " Done. " echo "We've generated a log at $LOG To make it easier to share, we can automatically upload it to termbin.com for you The log generally does not contain any personal information, we automatically censor your signing private key. If you're concerned about the contents of the file, press 'e' and hit enter and you can view/edit the file. Once you've finished censoring out any information you don't want to share, just save and close the file, and we'll ask you if you're ready to upload yet Otherwise, just type 'y' to upload the file, or 'n' to quit without uploading the file. You can access the log file at $LOG after closing. " while true; do echo read -p "Do you want to upload the log to termbin? (y)es/(e)dit/(n)o) > " yn case $yn in [Yy]* ) echo "Uploading log to termbin" cat "$LOG" | nc termbin.com 9999 echo "Please give the above link to the person helping you. You can look at it in your browser if you'd like to make sure there's no personal information" break;; [Ee]* ) echo "Opening $LOG in editor 'nano'" nano "$LOG" echo "Looks like you finished editing, or you're happy with the file." ;; [Nn]* ) exit 1 break;; * ) echo "Please answer yes (y), edit (e), or no (n).";; esac done echo "Finished."