-
-
Save tsykoduk/1358975 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
#!/usr/bin/env bash | |
## Bash Script to setup a number of boxen | |
## Pass this script a series of machine names, and watch it go to work | |
## Email is who gets the report, access_type is the command used to access the remote boxes - usally ssh. | |
# if you are using telnet, you are doing it wrong | |
#Lovingly stolen from @tsykoduk, and then hacked to crap | |
EMAIL="[email protected]" | |
GEMS="list your gems here" | |
while [ $# -gt 0 ]; do | |
#let's build a report for this machine | |
cd ~ | |
mv report.txt old_report.txt | |
touch report.txt | |
echo -e "X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-\n">>report.txt | |
echo -e "Machine Information for $1\tStart Run\t$(date -u)\n">>report.txt | |
echo -e "Emailed to: $EMAIL">>report.txt | |
echo -e "X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-\n\n">>report.txt | |
echo -e "X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-\n">>report.txt | |
echo -e "Hostname, Kernel: \n$($ACCESS_TYPE $1 'uname -nrmo')">>report.txt | |
echo -e "\nMemory: \n$($ACCESS_TYPE $1 'grep "MemTotal" /proc/meminfo')">>report.txt | |
echo -e "\nCPU: \n$($ACCESS_TYPE $1 'grep -m 4 -e "model name" -e "MHz" -e "cache size" -e "bogomips" /proc/cpuinfo')">>report.txt | |
echo -e "\nNumber of Cores: \n$($ACCESS_TYPE $1 'grep "processor" /proc/cpuinfo | wc -l')">>report.txt | |
echo -e "X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-\n">>report.txt | |
echo -e "X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-\n">>report.txt | |
echo -e "\nDisks: \n$($ACCESS_TYPE $1 'df -h')">>report.txt | |
echo -e "X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-\n\n">>report.txt | |
echo -e "X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-\n">>report.txt | |
echo -e "T">>report.txt | |
echo -e "IoStat:\n$($ACCESS_TYPE $1 'iostat -dkxt 1 4')">>report.txt | |
echo -e "VMStat:\n$($ACCESS_TYPE $1 'vmstat 1 4')">>report.txt | |
echo -e "X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-\n\n">>report.txt | |
#Configuring Enviroment | |
echo -e "$($ACCESS_TYPE $1 'bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )')" | |
echo -e "$($ACCESS_TYPE $1 './rvm-install-head')" | |
echo -e "$($ACCESS_TYPE $1 'rvm install ree')" | |
echo -e "$($ACCESS_TYPE $1 'rvm use ree --default')" | |
echo -e "$($ACCESS_TYPE $1 'gem install $GEMS')" | |
echo -e "$($ACCESS_TYPE $1 'do_more_crap_here')" | |
echo -e "X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-\n">>report.txt | |
echo -e "Ruby: \n$($ACCESS_TYPE $1 'ruby -v')">>report.txt | |
echo -e "Gems Version \n$($ACCESS_TYPE $1 'gem --version')">>report.txt | |
echo -e "Installed Gems\n$($ACCESS_TYPE $1 'gem list --local')">>report.txt | |
echo -e "Nginx: \n$($ACCESS_TYPE $1 'nginx -v')">>report.txt | |
echo -e "X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-\n\n">>report.txt | |
shift | |
mail -s "$1 Report" $EMAIL < report.txt | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment