Created
August 29, 2013 21:08
-
-
Save dstanek/6383436 to your computer and use it in GitHub Desktop.
A really simple script that I use to bootstrap devstack on a brand new Rackspace cloud server.
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 | |
host=$1 | |
pub_key=$2 | |
function help { | |
echo 'usage: ./bootstrap-devstack.sh host public_key' | |
echo ' example: ./bootstrap-devstack.sh 1.1.1.1 ~/.ssh/id_dsa.pub' | |
exit 1 | |
} | |
# XXX: add some validation here | |
REPO='https://github.com/openstack-dev/devstack.git' | |
GIST='https://gist.github.com/everett-toews/4004430/raw/57481ac76bebd41ad4d825fda365f752027026eb/localrc' | |
echo " | |
function install_software { | |
apt-get update | |
apt-get upgrade -y | |
apt-get install -y git libxslt1.1 libxslt1-dev | |
} | |
function create_user_account { | |
adduser --disabled-password --gecos $USER $USER | |
echo '$USER ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers | |
} | |
function disable_password_login { | |
perl -p -i -e 's/UsePAM yes/UsePAM no/' /etc/ssh/sshd_config | |
echo 'PasswordAuthentication no' >> /etc/ssh/sshd_config | |
service ssh reload | |
} | |
function setup_pubkey { | |
su - $USER -c 'mkdir -m 0700 /home/$USER/.ssh && \ | |
echo \"`cat $pub_key`\" >> /home/$USER/.ssh/authorized_keys && \ | |
chmod 0644 /home/$USER/.ssh/authorized_keys' | |
} | |
function install_devstack { | |
su - $USER -c 'git clone $REPO -b stable/folsom devstack && \ | |
cd devstack && \ | |
curl $GIST > localrc && \ | |
./stack.sh' | |
} | |
install_software | |
create_user_account | |
setup_pubkey | |
#disable_password_login | |
install_devstack | |
" | ssh \ | |
-o 'StrictHostKeyChecking no' \ | |
-o "UserKnownHostsFile /dev/null" \ | |
root@${host} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment