Created
July 8, 2013 17:42
-
-
Save fairchild/5950859 to your computer and use it in GitHub Desktop.
script that can be passed as userdata when booting an instance. It fetches a gist of bash functions and runs the ones called in the main function.
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 | |
# Setup a new ubuntu 12.04 or 12.10 server appropriate for deploying nodejs and/or ruby applications. | |
set -x | |
set -e | |
# mkdir -p /tmp/user_data | |
date >> /tmp/provisioning_began | |
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1 | |
echo BEGIN | |
date '+%Y-%m-%d %H:%M:%S' | |
# Setup a new ubuntu 12.04 server | |
export USERNAME=${1:-deploy} | |
export APPNAME=${2:-mygreatapp} | |
export AUTHORIZED_KEYS=${3:-'ssh-rsa whateveryerkeyis'} | |
export RUBY_VERSION=${4:-'1.9.2'} | |
export NODE_VERSION="0.8.16" | |
# export APT_PROXY=${5:-"http://10.4.45.95:3142"} | |
# export LOG_SERVER=${6:-"10.4.45.95"} | |
export UBUNTU_RELEASE=quantal | |
export DEBIAN_FRONTEND=noninteractive | |
sudo apt-get -y update | |
sudo apt-get -y dist-upgrade | |
sudo apt-get install -y git curl | |
git clone https://gist.github.com/4367544.git /tmp/user_data | |
. /tmp/user_data/user_data_functions.sh | |
function main () { | |
mkdir -p /tmp/user_data | |
cd /tmp/user_data | |
# setup_apt_cache | |
dist_upgrade | |
setup_deploy_user | |
install_common_tools | |
build_tools | |
install_redis | |
setup_postgres | |
# setup_www | |
install_ruby | |
install_java | |
install_nodejs | |
haproxy_setup | |
# setup_elastic_search | |
known_hosts | |
add_github_to_known_hosts | |
install_mosh | |
# setup_newrelic_server_monitoring | |
# setup_monitoring | |
# setup_logging | |
# setup_rvm | |
# setup_logging | |
} | |
main | |
date >> /tmp/user_data/provisioned | |
echo "User data run completed" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment