#!/bin/bash -xe server=$1 type=$2 hostname=$3 if [ -z "$hostname" ]; then echo "USAGE: $0 server type hostname" exit 1 fi if ! $(echo "$hostname" | grep -q humbughq.com$); then echo "USAGE: $0 server type hostname" echo "Hostname must end with humbughq.com" exit 1 fi humbug_root=${HUMBUG_ROOT:-$HOME/humbug} amazon_key_file=$humbug_root/humbug.pem if ! [ -e "$amazon_key_file" ]; then echo "You need humbug.pem at $amazon_key_file; ask tabbott for it" exit 1 fi server_private_key_file=$humbug_root/servers/puppet/modules/humbug/files/id_rsa if ! [ -e "$server_private_key_file" ]; then echo "You need a server ssh key at $server_private_key_file" exit 1 fi humbug_cert_file=$humbug_root/certs/humbug-self-signed.key if ! [ -e "$humbug_cert_file" ]; then echo "You need humbug-self-signed.key at $humbug_cert_file" exit 1 fi ssh "$server" -t -i "$amazon_key_file" -lroot <>/etc/apt/sources.list.d/backports.list < /root/.ssh/known_hosts < "$type"}' cp -a /root/humbug /home/humbug/humbug chown -R humbug:humbug /home/humbug/humbug # These server restarting bits should be moveable into puppet-land, ideally apt-get -y upgrade if [ -e "/etc/init.d/nginx" ]; then service nginx restart fi if [ -e "/etc/init.d/apache2" ]; then service apache2 restart fi echo "$hostname" > /etc/hostname sed -i 's/localhost$/localhost $hostname/' /etc/hosts /etc/init.d/hostname.sh start EOF # TODO: Don't give servers push access to our git! scp -i "$amazon_key_file" "$server_private_key_file" humbug@"$server":/home/humbug/.ssh/id_rsa ssh "$server" -t -i "$amazon_key_file" -lhumbug <