#!/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 if ! [ -e ~/humbug/humbug.pem ]; then echo "You need humbug.pem at ~/humbug/humbug.pem; ask tabbott for it" exit 1 fi if ! [ -e ~/humbug/servers/puppet/files/id_rsa ]; then echo "You need a server ssh key at ~/humbug/servers/puppet/files/id_rsa" exit 1 fi ssh "$server" -t -i ~/humbug/humbug.pem -lroot <>/etc/apt/sources.list.d/backports.list < /root/.ssh/known_hosts < /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 ~/humbug/humbug.pem ~/humbug/servers/puppet/files/id_rsa humbug@"$server":/home/humbug/.ssh/id_rsa ssh "$server" -t -i ~/humbug/humbug.pem -lhumbug <