Last active
September 29, 2019 01:57
-
-
Save justmiles/2e985f71f5aea743d7f1e61c38fc42d0 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
## Usage | |
# curl -sfLO https://gist.githubusercontent.com/justmiles/2e985f71f5aea743d7f1e61c38fc42d0/raw/64636aca2630ccc50c87db4520a8f226efa071a2/gather_info.sh | |
# chmod +x ./gather_info.sh | |
# sudo ./gather_info.sh | |
WORKDIR="info-$(hostname)-$(date +'%d-%m-%y')" | |
OUTPUT="${WORKDIR}/info.$(date +'%d-%m-%y').txt" | |
SCRIBE="${WORKDIR}/os-scribe.$(date +'%d-%m-%y').csv" | |
chk_root() { | |
if [ $(id -u) -ne 0 ]; then | |
echo "Please run this as root" | |
exit 8 | |
fi | |
} | |
write_header() { | |
echo "---------------------------------------------------" >>$OUTPUT | |
echo "$@" >>$OUTPUT | |
echo "---------------------------------------------------" >>$OUTPUT | |
} | |
has() { | |
which $1 >/dev/null 2>&1 && write_header $1 | |
} | |
install_scribe() { | |
curl -sfLo os-scribe.tar.gz https://github.com/justmiles/os-scribe/releases/download/v0.0.1/os-scribe_0.0.1_linux_x86_64.tar.gz | |
tar -xzvf os-scribe.tar.gz -C /usr/local/bin >/dev/null | |
} | |
dump_info() { | |
mkdir -p $WORKDIR | |
echo "Hostname: $(hostname) -- $(date)" >$OUTPUT | |
has uname && | |
hostname >>$OUTPUT | |
has lsb_release && | |
lsb_release -a >>$OUTPUT 2>&1 | |
has hwinfo && | |
hwinfo --network_ctrl >>$OUTPUT 2>&1 && | |
hwinfo --isapnp >>$OUTPUT 2>&1 | |
has lspci && | |
lspci -v >>$OUTPUT 2>&1 | |
has ifconfig && | |
ifconfig >>$OUTPUT 2>&1 | |
has route && | |
route -n >>$OUTPUT 2>&1 | |
write_header "DNS Configuration" | |
[ -f /etc/resolv.conf ] && cat /etc/resolv.conf >>$OUTPUT || echo "Error /etc/resolv.conf file not found." >>$OUTPUT | |
has service && | |
service --status-all >>$OUTPUT 2>&1 | |
has systemctl && | |
systemctl status --all >>$OUTPUT 2>&1 | |
## PHP Specific things | |
has php && | |
php --version >>$OUTPUT 2>&1 | |
has composer && | |
composer show --installed --tree >>$OUTPUT 2>&1 | |
has os-scribe || (install_scribe && has os-scribe) && | |
os-scribe / >$SCRIBE && | |
echo "os-scribe results written to $SCRIBE" >>$OUTPUT | |
has apt && | |
apt list --installed >>$OUTPUT 2>&1 | |
} | |
chk_root | |
dump_info | |
tar -czvf ${WORKDIR}.tar.gz $WORKDIR >/dev/null | |
rm -rf $WORKDIR | |
echo "This machine's information has been written to ${WORKDIR}.tar.gz. If you were asked to generate this, please respond with the ${WORKDIR}.tar.gz file." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment