Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 60 lines (44 sloc) 2.141 kb
984bf0b Matthew Kocher Can now bootstrap an ec2 instance and run chef
authored
1 #!/bin/bash -e
50725d0 Matthew Kocher updated bootstrap and passing app user to bootstrap - seems to be necess...
authored
2
3 env | grep -q "APP_USER=" || echo "Please set APP_USER environment variable"
4 echo "app user at the beginning: $APP_USER"
984bf0b Matthew Kocher Can now bootstrap an ec2 instance and run chef
authored
5
6 # perl -e 'print crypt("password", "salt"),"\n"'
50725d0 Matthew Kocher updated bootstrap and passing app user to bootstrap - seems to be necess...
authored
7 getent passwd $APP_USER >/dev/null 2>&1 || useradd $APP_USER -p passwordhashgoeshere # sa3tHJ3/KuYvI would set the password to "password"
984bf0b Matthew Kocher Can now bootstrap an ec2 instance and run chef
authored
8
50725d0 Matthew Kocher updated bootstrap and passing app user to bootstrap - seems to be necess...
authored
9 # copy root's authorized keys to APP_USER
10 mkdir -p /home/$APP_USER/.ssh
11 touch /home/$APP_USER/.ssh/authorized_keys
12 chmod 700 /home/$APP_USER/.ssh
13 chmod 600 /home/$APP_USER/.ssh/authorized_keys
14 chown -R $APP_USER /home/$APP_USER/.ssh
2a076cc Matthew Kocher fixing bootstrapping rvm problem, allowing passwordless ssh as app user
authored
15
16 authorized_keys_string=`cat /root/.ssh/authorized_keys`
50725d0 Matthew Kocher updated bootstrap and passing app user to bootstrap - seems to be necess...
authored
17 grep -sq "$authorized_keys_string" /home/$APP_USER/.ssh/authorized_keys || cat /root/.ssh/authorized_keys >> /home/$APP_USER/.ssh/authorized_keys
2a076cc Matthew Kocher fixing bootstrapping rvm problem, allowing passwordless ssh as app user
authored
18
19
984bf0b Matthew Kocher Can now bootstrap an ec2 instance and run chef
authored
20 ## enable ssh password auth
21 perl -p -i -e 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
22 /etc/init.d/sshd reload
23
24 # install epel
25 rpm -q epel-release-5-4.noarch || rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
26
27 # install git
28 yum -y install git
29
30 # rvm prereqs
50725d0 Matthew Kocher updated bootstrap and passing app user to bootstrap - seems to be necess...
authored
31 yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libffi-devel openssl-devel iconv-devel java
984bf0b Matthew Kocher Can now bootstrap an ec2 instance and run chef
authored
32
33 # passwordless sudo
34 sudo_string='ALL ALL = (ALL) NOPASSWD: ALL'
35 grep "$sudo_string" /etc/sudoers || echo "$sudo_string" >> /etc/sudoers
36
50725d0 Matthew Kocher updated bootstrap and passing app user to bootstrap - seems to be necess...
authored
37 cat <<'BOOTSTRAP_AS_USER' > /home/$APP_USER/bootstrap_as_user.sh
984bf0b Matthew Kocher Can now bootstrap an ec2 instance and run chef
authored
38 set -e
39
50725d0 Matthew Kocher updated bootstrap and passing app user to bootstrap - seems to be necess...
authored
40 export APP_USER=$1
6e482f7 Matthew Kocher Merge branch 'master' of https://github.com/mkocher/chef_deploy
authored
41 cd ~
50725d0 Matthew Kocher updated bootstrap and passing app user to bootstrap - seems to be necess...
authored
42
43 mkdir -p /home/$APP_USER/rvm/src
44 curl -Lskf http://github.com/wayneeseguin/rvm/tarball/156d0b42feba4922ad04 | tar xvz -C/home/$APP_USER/rvm/src --strip 1
45 cd "/home/$APP_USER/rvm/src" && ./install
984bf0b Matthew Kocher Can now bootstrap an ec2 instance and run chef
authored
46
47 rvm_include_string='[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"'
48 grep "$rvm_include_string" ~/.bashrc || echo "$rvm_include_string" >> ~/.bashrc
49
50 cat <<'RVMRC_CONTENTS' > ~/.rvmrc
51 rvm_install_on_use_flag=1
52 rvm_trust_rvmrcs_flag=1
53 rvm_gemset_create_on_use_flag=1
54 RVMRC_CONTENTS
55 BOOTSTRAP_AS_USER
56
50725d0 Matthew Kocher updated bootstrap and passing app user to bootstrap - seems to be necess...
authored
57 chmod a+x /home/$APP_USER/bootstrap_as_user.sh
6e482f7 Matthew Kocher Merge branch 'master' of https://github.com/mkocher/chef_deploy
authored
58 su $APP_USER /home/$APP_USER/bootstrap_as_user.sh $APP_USER
59 echo "finished"
50725d0 Matthew Kocher updated bootstrap and passing app user to bootstrap - seems to be necess...
authored
60 rm /home/$APP_USER/bootstrap_as_user.sh
Something went wrong with that request. Please try again.