Created
May 2, 2012 02:09
-
-
Save taylor/2573056 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
set -e -x | |
echo "Setting up base system" | |
REMOTE_SCRIPT="https://raw.github.com/gist/2573056/74237aada624251de7ddfe5e8b98a6e39f736e43/base_setup.sh" | |
wget -nv -O - "$REMOTE_SCRIPT" | bash | |
echo "Setting up Chef" | |
#REMOTE_SCRIPT="http://codecafe.com/chef/ec2_client_setup.sh" | |
REMOTE_SCRIPT="http://git.io/chefclientsetup.1" | |
wget -nv -O - "$REMOTE_SCRIPT" | bash | |
set +x | |
true |
This file contains hidden or 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 | |
set -e -x | |
echo "Setting up base system" | |
REMOTE_SCRIPT="https://raw.github.com/gist/2573056/74237aada624251de7ddfe5e8b98a6e39f736e43/base_setup.sh" | |
wget -nv -O - "$REMOTE_SCRIPT" | bash | |
set +x | |
true |
This file contains hidden or 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 | |
if [ ! "$UID" = 0 ] ; then | |
echo "this should be run as root" | |
exit 1 | |
fi | |
SCREENRC_URL="https://raw.github.com/gist/2573056/5cf0ff5ebe6f72fe3f5d93b3099e6a44564ec1bf/screenrc" | |
TMUXCONF_URL="https://raw.github.com/gist/2573056/550d6412f6eff39c674e2dcc8b7e478fe9a12d81/tmuxrc" | |
set -e -x | |
mkdir -p /root/.ssh | |
touch /root/.ssh/authorized_keys | |
chmod 700 /root/.ssh | |
chmod 600 /root/.ssh/authorized_keys | |
if ! grep [email protected] /root/.ssh/authorized_keys ; then | |
wget -nv -O - http://codecafe.com/chris/ssh.pub | tee -a /etc/skel/.ssh/authorized_keys | tee -a /root/.ssh/authorized_keys | |
fi | |
if ! grep [email protected] /root/.ssh/authorized_keys ; then | |
wget -nv -O - http://codecafe.com/taylor/ssh.pub | tee -a /etc/skel/.ssh/authorized_keys | tee -a /root/.ssh/authorized_keys | |
fi | |
if ! grep wwalker /root/.ssh/authorized_keys ; then | |
wget -nv -O - http://codecafe.com/wayne/ssh.pub | tee -a /etc/skel/.ssh/authorized_keys | tee -a /root/.ssh/authorized_keys | |
fi | |
if ! grep backuppc@blackhole /root/.ssh/authorized_keys ; then | |
wget -nv -O - http://codecafe.com/wayne/ssh-backup.pub | tee -a /etc/skel/.ssh/authorized_keys | tee -a /root/.ssh/authorized_keys | |
fi | |
sed -i.orig 's/^PermitRootLogin/#PermitRootLogin/' /etc/ssh/sshd_config | |
echo "PermitRootLogin yes" | tee -a /etc/ssh/sshd_config | |
service ssh restart | |
service sshd restart | |
RPM_SYS=0 | |
APT_SYS=0 | |
which rpm > /dev/null 2>&1 | |
#which apt-get > /dev/null 2>&1 | |
if [ "$?" = "0" ] ; then | |
RPM_SYS=1 | |
pmapp=yum | |
else | |
APT_SYS=1 | |
pmapp=apt-get | |
fi | |
# START SETUP BASE SYSTEM | |
$pmapp -y install screen | |
# TODO: need to install tmux every where | |
## Screen config | |
if [ ! -f /root/.screenrc ] ; then | |
curl $SCREENRC_URL | tee /etc/skel/.screenrc | tee /root/.screenrc | |
fi | |
if [ ! -f /root/.tmux.conf ] ; then | |
curl $TMUXCONF_URL | tee /etc/skel/.tmux.conf | tee /root/.tmux.conf | |
fi | |
echo export HISTSIZE=9000 | tee -a /etc/skel/.bash_profile | tee -a /root/.bash_profile | |
# ncurses term for ansi-term in emacs | |
$pmapp -y install ncurses-term | |
if ! [ -a /usr/share/terminfo/e/eterm-color ]; then | |
ln -s /usr/share/terminfo/e/eterm /usr/share/terminfo/e/eterm-color | |
fi | |
## SUDO defaults | |
sed -ire '/NOPASSWD/ s/^# //' /etc/sudoers # %sudo doesn't need a password now! | |
# add our public keys to all new users, and to the default user | |
mkdir -p /etc/skel/.ssh | |
#curl http://codecafe.com/chris/ssh.pub | tee -a /etc/skel/.ssh/authorized_keys | |
#curl http://codecafe.com/taylor/ssh.pub | tee -a /etc/skel/.ssh/authorized_keys | |
# curl http://codecafe.com/wayne/ssh.pub | tee -a /etc/skel/.ssh/authorized_keys | |
#curl http://codecafe.com/wayne/ssh-backup.pub | tee -a /etc/skel/.ssh/authorized_keys | |
cat <<"EOS"| tee -a /tmp/setup_user_account | |
mkdir -p ~/.ssh | |
touch ~/.ssh/authorized_keys | |
cat /etc/skel/.ssh/authorized_keys >> ~/.ssh/authorized_keys | |
chmod 700 ~/.ssh | |
chmod 600 ~/.ssh/authorized_keys | |
cp /etc/skel/.screenrc ~/ | |
echo export HISTSIZE=9000 | tee -a ~/.bash_profile | |
EOS | |
chmod +x /tmp/setup_user_account | |
if [ -d /home/ubuntu ] ; then | |
U=ubuntu | |
elif [ -d /home/ec2-user ] ; then | |
U=ec2-user | |
else | |
U="" | |
fi | |
if [ -n "$U" ] ; then | |
su - $U -c "sh /tmp/setup_user_account" | |
fi | |
# END SETUP BASE SYSTEM | |
set +x | |
true |
This file contains hidden or 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 | |
if [ ! "$UID" = 0 ] ; then | |
echo "this should be run as root" | |
exit 1 | |
fi | |
set -e -x | |
wget -nv -O - http://www.opscode.com/chef/install.sh | bash | |
set +x | |
true |
This file contains hidden or 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
source /etc/screenrc | |
defscrollback 9000 | |
termcapinfo xterm 'hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007' | |
defhstatus "screen ^A (^Aa) | $USER@^AH" | |
hardstatus off | |
caption always "%{Yk} %H%{k}|%{W}%-w%{+u}%n %t%{-u}%+w" | |
caption string "%{yk}%H %{Kk}%{g}%-w%{kR}%n %t%{Kk}%{g}%+w" | |
startup_message off | |
vbell off |
This file contains hidden or 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
set -g default-terminal "screen-256color" | |
## OLD | |
set -g prefix DC,C-b | |
set -g prefix DC | |
bind-key b send-keys C-b | |
## NEW | |
#set -g prefix DC | |
#set -g prefix2 C-b | |
#bind-key DC send-prefix | |
#bind-key b send-prefix -2 | |
set-window-option -g window-status-current-bg red | |
setw -g aggressive-resize on | |
set -g base-index 1 | |
set -s escape-time 0 | |
# Use: Prefix + Control-l to change to last window | |
bind-key C-b last-window | |
#bind-key C-l last-window | |
# prefix ! will split the current pane into it's own window. To join use | |
# prefix J then give the window number at the prompt | |
bind-key J command-prompt -p "create pane from:" "join-pane -s ':%%'" | |
bind-key -r k select-pane -U | |
bind-key -r j select-pane -D | |
bind-key -r h select-pane -L | |
bind-key -r l select-pane -R | |
setw -g mode-keys vi | |
#setw -g mode-mouse on | |
set -g history-limit 5000 | |
unbind % # Remove default binding since we’re replacing | |
#unbind " # we use | for split | |
bind | split-window -h | |
bind \ split-window -h | |
bind - split-window -v | |
#bind " list-windows | |
# http://jasonwryan.com/post/6279048610/tmux-copy | |
unbind [ | |
bind Escape copy-mode | |
unbind p | |
bind p paste-buffer | |
bind-key -t vi-copy 'v' begin-selection | |
bind-key -t vi-copy 'y' copy-selection | |
### | |
setw -g monitor-activity on | |
set -g visual-activity on | |
unbind-key z | |
bind-key z new-window -d -n tmux-zoom 'clear && echo TMUX ZOOM && read' \; swap-pane -s tmux-zoom.0 \; select-window -t tmux-zoom | |
unbind-key u | |
bind-key u last-window \; swap-pane -s tmux-zoom.0 \; kill-window -t tmux-zoom | |
#urxvt tab like window switching (-n: no prior escape seq) | |
bind -n S-down new-window | |
bind -n S-left prev | |
bind -n S-right next | |
bind -n C-left swap-window -t -1 | |
bind -n C-right swap-window -t +1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment