curl -s https://gist.githubusercontent.com/silviuvulcan/e9981adcfa4fcd7e664e/raw/ | bash -s "distro"
- CentOS 6
curl -s https://gist.githubusercontent.com/silviuvulcan/e9981adcfa4fcd7e664e/raw/ | bash -s "el6"
#!/bin/bash | |
LV="$1" | |
distros=( el6 el7 ) | |
LOG="$HOME/deploy.log" | |
if type tput >/dev/null 2>&1; then | |
RED=$(tput setaf 1) | |
GREEN=$(tput setaf 2) | |
YELLOW=$(tput setaf 3) | |
BLUE=$(tput setaf 4) | |
MAGENTA=$(tput setaf 5) | |
CYAN=$(tput setaf 6) | |
WHITE=$(tput setaf 7) | |
BRIGHT=$(tput bold) | |
COLRESET=$(tput sgr0) | |
COLOR=1 | |
else | |
RED="" | |
GREEN="" | |
YELLOW="" | |
BLUE="" | |
MAGENTA="" | |
CYAN="" | |
WHITE="" | |
BRIGHT="" | |
COLRESET="" | |
COLOR=0 | |
fi | |
function try_run { | |
MSG="$1... " | |
printf "$MSG" | |
echo >> "$LOG" | |
echo -n "$(date '+%Y %b %d %H:%M:%S') " >> "$LOG" | |
echo "${@:2}" >> "$LOG" | |
if [ $COLOR -eq 1 ]; then | |
let COL=$(tput cols)-${#MSG}+${#YELLOW}+${#COLRESET} | |
else | |
let COL=80-${#MSG} | |
fi | |
"${@:2}" >> "$LOG" 2>&1 | |
if [ $? -eq 0 ]; then | |
printf "%${COL}s" "[$YELLOW OK $COLRESET] " | |
else | |
printf "%${COL}s" "[$RED Failed $COLRESET] " | |
fi | |
# ensure new line even on badly calculated lines | |
echo | |
} | |
if [ $# -ne 1 ]; then | |
echo "Please select your distro. See below for possible choices." | |
echo | |
echo -ne "Known distros: " | |
echo "${distros[@]}" | |
echo | |
exit 1 | |
fi | |
if [[ ! " ${distros[@]} " =~ " $LV " ]]; then | |
echo "Unknow distro choice $LV" | |
echo | |
echo -ne "Known distros: " | |
echo "${distros[@]}" | |
echo | |
exit 2 | |
fi | |
echo "Starting at `date` for $LV" > $LOG | |
echo | |
if [ "$LV" = "el6" ]; then | |
echo -e "${BLUE}Setting-up CentOS 6 specific items${COLRESET}" | |
echo -e "${BLUE}----------------------------------${COLRESET}" | |
echo | |
try_run "Setting network interfaces to start on boot" sed -i s/ONBOOT=no/ONBOOT=yes/g /etc/sysconfig/network-scripts/ifcfg-eth* | |
try_run "Running yum update" yum -y update | |
try_run "Yum installing favourite packages" yum -y install git mc vim vim-common wget curl epel-release.noarch screen unzip | |
try_run "Installing epel packages" yum -y install bash-completion.noarch | |
try_run "Backing-up /etc/issue" cp -v /etc/issue /etc/issue.orig | |
try_run "Downloading update-issue.sh" wget https://gist.githubusercontent.com/silviuvulcan/3445bb2d1bd14f9a0ba8/raw/update-issue.sh -O /usr/local/sbin/update-issue.sh | |
try_run "Downloading ifup-local" wget https://gist.githubusercontent.com/silviuvulcan/3445bb2d1bd14f9a0ba8/raw/ -O /sbin/ifup-local | |
try_run "Setting up execute permissions.sh" chmod -v +x /usr/local/sbin/update-issue.sh /sbin/ifup-local | |
try_run "Disabling SELinux on future boot" sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config | |
try_run "Setting current enforce level to permissive" /usr/sbin/setenforce 0 | |
fi | |
if [ "$LV" = "el7" ]; then | |
echo -e "${BLUE}Setting-up CentOS 7 specific items${COLRESET}" | |
echo -e "${BLUE}----------------------------------${COLRESET}" | |
echo | |
try_run "Running yum update" yum -y update | |
try_run "Yum installing favourite packages" yum -y install git mc vim vim-common wget curl bash-completion screen unzip | |
try_run "Backing-up /etc/issue" cp -v /etc/issue /etc/issue.orig | |
try_run "Downloading update-issue.sh" wget https://gist.githubusercontent.com/silviuvulcan/3445bb2d1bd14f9a0ba8/raw/update-issue.sh -O /usr/local/sbin/update-issue.sh | |
try_run "Downloading ifup-local" wget https://gist.githubusercontent.com/silviuvulcan/3445bb2d1bd14f9a0ba8/raw/ -O /sbin/ifup-local | |
try_run "Setting up execute permissions.sh" chmod -v +x /usr/local/sbin/update-issue.sh /sbin/ifup-local | |
try_run "Disabling SELinux on future boot" sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config | |
try_run "Setting current enforce level to permissive" /usr/sbin/setenforce 0 | |
fi | |
echo | |
echo | |
echo -e "${BLUE}Installig homeshick and other non-distro specific items${COLRESET}" | |
echo -e "${BLUE}-------------------------------------------------------${COLRESET}" | |
echo | |
try_run "Installing homeshick" git clone https://github.com/andsens/homeshick.git $HOME/.homesick/repos/homeshick | |
source "$HOME/.homesick/repos/homeshick/homeshick.sh" | |
try_run "homeshick is installing Vundle" homeshick -b clone gmarik/Vundle | |
try_run "homeshick is installing silviuvulcan/dotfiles" homeshick -b clone silviuvulcan/dotfiles | |
try_run "homeshick is symlinking" homeshick -f link | |
try_run "Installing vim bundle" vim -E -u NONE -S ~/.vimrc.vundle +PluginInstall +qall | |
try_run "Preparing .ssh/ " mkdir -v -p ~/.ssh | |
try_run "Setting .ssh/ permissions" chmod -v 700 ~/.ssh | |
try_run "Creating empty authorized_keys" touch ~/.ssh/authorized_keys | |
try_run "Setting authorized_keys permissions" chmod -v 600 ~/.ssh/authorized_keys | |
echo | |
echo | |
echo -e "${BLUE}Done. Check $LOG for details $COLRESET" | |
echo -e "${BLUE}------------------------$(for i in `seq 1 ${#LOG}`; do echo -n -;done)$COLRESET" | |
echo |