mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 23:43:43 +00:00
This should be part of the Puppet config eventually, but I'm not sure how to do it. (imported from commit 23063e1e492f6e1cad0afbcf4adffbb6e25aedf7)
106 lines
3.8 KiB
Bash
Executable File
106 lines
3.8 KiB
Bash
Executable File
#!/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 <<EOF
|
|
resize2fs /dev/xvda1
|
|
|
|
# First, install a sufficiently new version of puppet on the target
|
|
cat >>/etc/apt/sources.list.d/backports.list <<EOF2
|
|
deb http://backports.debian.org/debian-backports squeeze-backports main
|
|
deb-src http://backports.debian.org/debian-backports squeeze-backports main
|
|
EOF2
|
|
apt-get update
|
|
apt-get -y upgrade
|
|
|
|
# need to get puppet from squeeze-backports before we can do anything with puppet
|
|
apt-get install -y -t squeeze-backports puppet git
|
|
EOF
|
|
|
|
# Give new server git access
|
|
# TODO: Don't give servers push access to our git!
|
|
scp -i "$amazon_key_file" "$server_private_key_file" root@"$server":/root/.ssh/id_rsa
|
|
|
|
ssh "$server" -t -i "$amazon_key_file" -lroot <<EOF
|
|
chmod 600 /root/.ssh/id_rsa
|
|
# Setup initial known_hosts including git server
|
|
cat > /root/.ssh/known_hosts <<EOF2
|
|
|1|YmrT42zuHUt3kvg+MzhtF1IXakM=|Ps1MaxDiy5uTeFTjB2k8oQQyxg8= ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+jhFu8Y9kSe+HyWtCmH2GqTi38lwqZzhAkyaUaASwvcvCRJWGC6AMPGVCKyNxJMcWcIcmP+mB8i5z5AhsgqwEmV5F9TrbPYjbroALCoZEon/bnCBNd3Jh/8eKZI/VLCzWQpL2FTZ5p1RYnCJ4PKSjd8PbKbGd5eAyRlbuETeyavwC+komLlekKkV+wiAv4aGuGRZeGrVJIqSRydVplQrFVaoF/1ifFS/XcNx18jFH0nw8oPOahaTzB/EUTTS/q1Cq0XgrA7x6bsr5kg4Vtw0BcP7JLob6pl/1D9FjLYsDPZCPGIfJV2uF4WcRJWg/U6OtSKOrwTmVw02TcwaavARr
|
|
|1|ccgacGoQ9gPCsFVrAopK3oGvYfU=|YcNvWUziiANLr22lvHD05N2veas= ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+jhFu8Y9kSe+HyWtCmH2GqTi38lwqZzhAkyaUaASwvcvCRJWGC6AMPGVCKyNxJMcWcIcmP+mB8i5z5AhsgqwEmV5F9TrbPYjbroALCoZEon/bnCBNd3Jh/8eKZI/VLCzWQpL2FTZ5p1RYnCJ4PKSjd8PbKbGd5eAyRlbuETeyavwC+komLlekKkV+wiAv4aGuGRZeGrVJIqSRydVplQrFVaoF/1ifFS/XcNx18jFH0nw8oPOahaTzB/EUTTS/q1Cq0XgrA7x6bsr5kg4Vtw0BcP7JLob6pl/1D9FjLYsDPZCPGIfJV2uF4WcRJWg/U6OtSKOrwTmVw02TcwaavARr
|
|
EOF2
|
|
# clone humbug repository
|
|
cd /root
|
|
rm -rf /root/humbug
|
|
git clone humbug@git.humbughq.com:/srv/git/humbug.git
|
|
cd /root/humbug
|
|
git checkout master
|
|
EOF
|
|
|
|
# Stupid hack because humbug-self-signed.key isn't in git
|
|
scp -i "$amazon_key_file" "$humbug_cert_file" root@"$server":/root/humbug/certs/humbug-self-signed.key
|
|
|
|
# TODO: Copy the real certs into place for prod servers
|
|
|
|
ssh "$server" -t -i "$amazon_key_file" -lroot <<EOF
|
|
cp -a /root/humbug/servers/puppet/modules/humbug/files/puppet.conf /etc/puppet/
|
|
puppet apply -e 'class {"humbug": machinetype => "$type"}'
|
|
# 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 <<EOF
|
|
chmod 600 /home/humbug/.ssh/id_rsa
|
|
EOF
|
|
|
|
set +x
|
|
cat <<EOF
|
|
|
|
Done.
|
|
|
|
FIXME: Manually run servers/install-nodejs if necessary
|
|
|
|
EOF
|