Created
May 2, 2011 15:05
-
-
Save danp/951741 to your computer and use it in GitHub Desktop.
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
trap "exec /bin/bash" EXIT | |
trap "state_update error" ERR | |
set -ex | |
. dhcp_env | |
cat dhcp_env | |
BACKUP_PREFIX=/newroot/engineyard/migration/backups | |
state_update() { | |
state="$1" | |
message="$2" | |
curl --data-urlencode "state=$state" --data-urlencode "message=$message" http://$siaddr/ey/configuration/update | |
} | |
message_update() { | |
message="$1" | |
curl --data-urlencode "message=$message" http://$siaddr/ey/configuration/update | |
} | |
is_legacy() { | |
ls -ald /newroot/var/db/pkg/sys-libs/{ss,com_err}-* > /dev/null 2>&1 | |
} | |
backup() { | |
file="$1" | |
backup_file="$BACKUP_PREFIX/$(echo "$file" | sed -e 's!^/newroot/!!')" | |
if [ -e "$file" ]; then | |
mkdir -p "$(dirname "$backup_file")" | |
md5sum_backup_file="$backup_file.$(md5sum "$file" | awk '{ print $1 }')" | |
echo "backup: backing up $file to $md5sum_backup_file" | |
cp "$file" "$md5sum_backup_file" | |
else | |
echo "backup: not backing up $file, doesn't exist" | |
fi | |
} | |
replace() { | |
file="$1" | |
backup "$file" | |
echo "replace: replacing $file" | |
cat > $file | |
} | |
append() { | |
file="$1" | |
backup "$file" | |
echo "append: appending to $file" | |
cat >> $file | |
} | |
edit() { | |
file="$1" | |
script="$2" | |
backup "$file" | |
echo "edit: editing $file" | |
inside_file="$(echo "$file" | sed -e 's!^/newroot!!')" | |
chroot /newroot /usr/bin/perl -lpi -e "$script" $inside_file | |
} | |
determine_long_query_time() { | |
version=$1 | |
echo $version | awk '{ split($1, pieces, "."); if (pieces[2] > 0 || pieces[3] >= 52) print("2.000000"); else if (pieces[3] ~ /^51/) print("2000000"); else if (pieces[3] ~ /^45/) print("2") }' | |
} | |
state_update "booted" | |
message_update "Mounting NFS shares" | |
mkdir -p /mnt/archives | |
mount.nfs $siaddr:/data/archives /mnt/archives -o nolock | |
mkdir -p /mnt/support | |
mount.nfs $siaddr:/data/support /mnt/support -o nolock | |
message_update "Partitioning disks" | |
# partition root disk | |
sfdisk -uM /dev/sda <<EOF | |
{{slash_boot_sfdisk_line}} | |
,,8e | |
EOF | |
{{#non_root_disks}} | |
dd if=/dev/zero of={{path}} bs=512 count=1 | |
sfdisk -R {{path}} | |
{{/non_root_disks}} | |
message_update "Setting up LVM" | |
# create PVs | |
lvm pvcreate -y -ff /dev/sda2 | |
{{#non_root_disks}} | |
lvm pvcreate -y -ff {{path}} | |
{{/non_root_disks}} | |
lvm vgcreate {{volume_group}} /dev/sda2 {{non_root_disk_list}} | |
# create root disk LVs | |
{{#root_disk_logical_volumes}} | |
lvm lvcreate -L {{logical_volume_size}} -n {{logical_volume_name}} {{volume_group}} /dev/sda2 | |
{{/root_disk_logical_volumes}} | |
# create non-root disk LVs | |
{{#non_root_disk_logical_volumes}} | |
lvm lvcreate -L {{logical_volume_size}} -n {{logical_volume_name}} {{volume_group}} {{non_root_disk_list}} | |
{{/non_root_disk_logical_volumes}} | |
# mkfs and mount | |
message_update "Creating filesystems" | |
{{#filesystems}} | |
{{mkfs_command}} | |
{{mount_command}} | |
{{/filesystems}} | |
state_update "configuring" | |
{{#unpack_stage4?}} | |
message_update "New VM, unpacking stage4" | |
tar -C /newroot/ --numeric-owner -jpxf /mnt/support/slice_stage4/slice-stage4-amd64-2009a.1_pre48.tar.bz2 | |
{{/unpack_stage4?}} | |
{{#filesystem_archives_to_unpack}} | |
message_update "Unpacking filesystem archive {{filename}} to {{source_item}}" | |
mkdir -p /newroot/{{source_item}} | |
tar -C /newroot/{{source_item}} --numeric-owner -zpxf /mnt/archives/{{filename}} | |
{{/filesystem_archives_to_unpack}} | |
mount -o bind /proc /newroot/proc | |
mount -o bind /sys /newroot/sys | |
{{#database_archives}} | |
message_update "Copying database archive {{filename}} to {{database_data_dir}}" | |
mkdir -p /newroot/{{database_data_dir}} | |
cp /mnt/archives/{{filename}} /newroot/{{database_data_dir}} | |
{{/database_archives}} | |
message_update "Copying kernel, modules and kernel source" | |
cp -a /mnt/support/kernel/boot/* /newroot/boot | |
cp -a /mnt/support/initrd/initrd-final.img /newroot/boot | |
cp -a /mnt/support/kernel/lib/modules/* /newroot/lib/modules | |
mkdir -p /newroot/usr/src/kernels | |
cp -a /mnt/support/kernel-devel/* /newroot/usr/src/kernels | |
message_update "Setting up grub" | |
cp -a /mnt/support/grub /newroot/boot | |
replace /newroot/boot/grub/grub.conf <<EOF | |
default 0 | |
timeout 10 | |
title system | |
root (hd0,0) | |
kernel /vmlinuz-2.6.18-164.11.1.el5 root=/dev/ram0 root_lv=/dev/local/root divider=10 | |
initrd /initrd-final.img | |
EOF | |
(cd /newroot/boot/grub && ln -s grub.conf menu.lst) | |
grub --batch <<GRUB | |
root (hd0,0) | |
setup (hd0) | |
GRUB | |
message_update "Doing various config things" | |
rm -rf /newroot/var/lib/puppet/ssl | |
rm -f /newroot/etc/udev/rules.d/*-persistent-net[.-]* | |
mkdir -p /newroot/engineyard/var | |
{{^unpack_stage4?}} | |
touch /newroot/engineyard/var/migrating | |
{{/unpack_stage4?}} | |
replace /newroot/etc/fstab <<EOF | |
shm /dev/shm tmpfs nodev,nosuid,noexec 0 0 | |
{{#filesystems}} | |
{{fstab_line}} | |
{{/filesystems}} | |
EOF | |
mkdir -p /newroot/initrd | |
sed -i -e 's/xvc0/tty1/' /newroot/etc/inittab | |
cp /mnt/support/puppet/puppet_run.sh /newroot/engineyard/bin/puppet_run.sh | |
append /newroot/etc/inittab <<EOF | |
pu:345:respawn:/engineyard/bin/puppet_run.sh --migration | |
EOF | |
echo "alias eth0 e1000" >> /newroot/etc/modprobe.d/e1000 | |
chroot /newroot /sbin/update-modules -f | |
chroot /newroot {{{change_root_password_command}}} | |
replace /newroot/etc/conf.d/net <<EOF | |
modules=("iproute2") | |
config_eth0=( | |
"{{vlan_ip}}/{{vlan_prefix_length}}" | |
) | |
routes_eth0=( | |
"default via {{default_gateway}} dev eth0" | |
) | |
EOF | |
replace /newroot/etc/conf.d/hostname <<EOF | |
HOSTNAME="{{hostname}}" | |
EOF | |
replace /newroot/etc/resolv.conf <<EOF | |
options rotate | |
domain {{domainname}} | |
{{#dns_caches}} | |
nameserver {{ip}} | |
{{/dns_caches}} | |
EOF | |
{{#from_existing}} | |
edit /newroot/etc/hosts ' | |
s/^\s*127.0.0.1\s.*/127.0.0.1 {{fqdn}} {{hostname}} localhost/; | |
if (/^\s*10\..*\s{{from_existing_cluster}}-/) { $_ = "# $_" } | |
' | |
edit /newroot/etc/sysctl.conf ' | |
if (/^\s*xen\./) { $_ = "# $_" } | |
' | |
{{/from_existing}} | |
{{#new}} | |
replace /newroot/etc/hosts <<EOF | |
127.0.0.1 {{fqdn}} {{hostname}} localhost | |
EOF | |
{{/new}} | |
edit /newroot/etc/conf.d/clock ' | |
s/^(#?\s*)?CLOCK_SYSTOHC=.*/CLOCK_SYSTOHC="yes"/ | |
' | |
replace /newroot/etc/conf.d/local.start <<EOF | |
if [ -f /firstboot ]; then | |
rm -f /firstboot | |
source /firstboot.sh | |
rm -f /firstboot.sh | |
state_update "destination_booted" | |
state_update "destination_configuring" | |
set -e | |
set -E | |
set -o pipefail | |
trap "state_update error" ERR | |
EOF | |
touch /newroot/firstboot | |
replace /newroot/firstboot.sh <<EOF | |
state_update() { | |
state="\$1" | |
message="\$2" | |
curl -k --form-string "state=\$state" --form-string "message=\$message" https://{{external_app_address}}/ey/configuration/update/{{name}} | |
} | |
message_update() { | |
message="\$1" | |
curl -k --form-string "message=\$message" https://{{external_app_address}}/ey/configuration/update/{{name}} | |
} | |
hold_until_complete() { | |
name="\$1" | |
message_update "Holding until \$name completes" | |
while ! curl -k -f -s https://{{external_app_address}}/ey/configuration/completeness_check/\$name; do sleep 30; done | |
} | |
{{#database_mysql_server}} | |
start_mysql() { | |
/sbin/start-stop-daemon --quiet --start --background --pidfile {{database_mysql_pid}} --exec /usr/sbin/mysqld -- --defaults-file=/etc/mysql/my.cnf --basedir=/usr --datadir={{database_mysql_datadir}} --pid-file={{database_mysql_pid}} --socket=/var/run/mysqld/mysqld.sock | |
while ! echo 'select now()' | mysql; do sleep 10; done | |
} | |
create_mysql_dotfiles() { | |
cat > /root/.my.cnf <<EOC | |
[mysql] | |
user=root | |
password={{database_root_password}} | |
[mysqldump] | |
user=root | |
password={{database_root_password}} | |
[mysqladmin] | |
user=root | |
password={{database_root_password}} | |
EOC | |
chmod 600 /root/.my.cnf | |
cat > /root/.mytop <<EOC | |
pass={{database_root_password}} | |
db=mysql | |
delay=2 | |
idle=0 | |
sort=1 | |
EOC | |
chmod 600 /root/.mytop | |
} | |
secure_mysql() { | |
echo "grant replication slave, replication client on *.* to replication@'{{database_replica_ip}}' identified by '{{database_root_password}}';" | mysql | |
echo "grant super, replication client on *.* to nagios@'{{nagios_host}}' identified by '{{database_nagios_password}}';" | mysql | |
echo "update mysql.user set Password=PASSWORD('{{database_root_password}}') where user='root';" | mysql mysql | |
echo "delete from mysql.user where user='';" | mysql mysql | |
echo "delete from mysql.db where user='';" | mysql mysql | |
echo "delete from mysql.user where user='root' and host!='localhost';" | mysql mysql | |
echo "drop database test;" | mysql | |
echo "flush privileges;" | mysql | |
create_mysql_dotfiles | |
} | |
establish_mysql_replication() { | |
master_status=\$(echo "SHOW MASTER STATUS" | mysql -h {{database_master_virtual_machine_vlan_ip}} --user replication --password={{database_root_password}} | tail -n1) | |
master_log=\$(echo \$master_status | awk '{ print \$1 }') | |
master_pos=\$(echo \$master_status | awk '{ print \$2 }') | |
message_update "Setting up replication from {{database_master_virtual_machine_name}}, log: \$master_log, pos: \$master_pos" | |
echo "CHANGE MASTER TO MASTER_HOST='{{database_master_virtual_machine_vlan_ip}}', MASTER_USER='replication', MASTER_PASSWORD='{{database_root_password}}', MASTER_LOG_FILE='\$master_log', MASTER_LOG_POS=\$master_pos" | mysql | |
echo "START SLAVE" | mysql | |
} | |
{{/database_mysql_server}} | |
EOF | |
message_update "Unpacking new portage tarball and fixing portage" | |
rm -rf /newroot/engineyard/portage | |
mkdir -p /newroot/engineyard/portage | |
if is_legacy; then | |
tar -xf /mnt/support/portage/portage-legacy.tar -C /newroot/engineyard/portage | |
chroot /newroot /bin/ln -nsf /engineyard/portage/profiles/default-linux/amd64/2007.0 /etc/make.profile | |
chroot /newroot /bin/bash -c ' | |
for link in $(find /etc/portage -type l); do | |
target=$(readlink $link) | |
new_target=$(echo $target | sed -e "s!^/.*/engineyard/profile!/engineyard/portage/engineyard/profile!"); | |
(cd $(dirname $link) && ln -nsf $new_target $link) | |
done | |
' | |
edit /newroot/etc/portage/package.use/local ' | |
if (/lvm2/) { $_ = "# $_" } | |
' | |
else | |
tar -xf /mnt/support/portage/portage-2009a.tar -C /newroot/engineyard/portage | |
chroot /newroot /bin/ln -nsf /engineyard/portage/engineyard/profiles/slice/amd64 /etc/make.profile | |
fi | |
mkdir -p /newroot/engineyard/portage/distfiles | |
mkdir -p /newroot/engineyard/portage/packages | |
edit /newroot/etc/make.conf ' | |
if (/^\s*EMERGE_DEFAULT_OPTS=/) { $_ = "" } | |
if (/^\s*http_proxy=/) { $_ = "" } | |
if (/^\s*PORTDIR=/) { $_ = "" } | |
if (/^\s*PORTDIR_OVERLAY=/) { $_ = "" } | |
if (/^\s*DISTDIR=/) { $_ = "" } | |
if (/^\s*PKGDIR=/) { $_ = "" } | |
if (/^\s*SYNC=/) { $_ = "" } | |
if (/^\s*PORTAGE_BINHOST=/) { $_ = "" } | |
' | |
if is_legacy; then | |
append /newroot/etc/make.conf <<EOF | |
SYNC="rsync://{{portage_sync_host}}/portage/legacy" | |
EOF | |
else | |
append /newroot/etc/make.conf <<EOF | |
SYNC="rsync://{{portage_sync_host}}/portage/2009a" | |
PORTAGE_BINHOST="http://{{portage_bin_host}}/2009a/amd64/" | |
EOF | |
fi | |
append /newroot/etc/make.conf <<EOF | |
PORTDIR="/engineyard/portage" | |
PORTDIR_OVERLAY="/engineyard/portage/engineyard" | |
DISTDIR="/engineyard/portage/distfiles" | |
PKGDIR="/engineyard/portage/packages" | |
http_proxy="http://{{portage_sync_host}}:5254" | |
EOF | |
chroot /newroot /bin/ln -nsf /engineyard/portage /usr/portage | |
mount -o bind /mnt/support/portage/distfiles /newroot/engineyard/portage/distfiles | |
message_update "Installing packages" | |
packages="lvm2 xfsprogs portage pax-utils =net-fs/nfs-utils-1.1.0-r1" | |
if ! chroot /newroot /usr/bin/emerge -n $packages; then | |
message_update "First emerge failed, trying again" | |
chroot /newroot /usr/bin/emerge -n $packages | |
fi | |
chroot /newroot /usr/bin/emerge -n -O iptables | |
umount /newroot/engineyard/portage/distfiles | |
message_update "Installing VMware tools" | |
replace /newroot/sbin/mkinitrd <<EOF | |
#!/bin/bash | |
EOF | |
chmod 755 /newroot/sbin/mkinitrd | |
mkdir /newroot/tmp/vmware-tools | |
mount -o bind /mnt/support/vmware-tools /newroot/tmp/vmware-tools | |
for x in 0 1 2 3 4 5 6; do mkdir -p /newroot/etc/rc$x.d; done | |
chroot /newroot /tmp/vmware-tools/vmware-tools-distrib/vmware-install.pl --default | |
chroot /newroot /sbin/rc-update add vmware-tools boot | |
umount /newroot/tmp/vmware-tools | |
rm -rf /newroot/tmp/vmware-tools | |
killall -q vmware-guestd | |
sleep 5 | |
{{^unpack_stage4?}} | |
message_update "Setting up iptables" | |
replace /newroot/var/lib/iptables/rules-save <<EOF | |
*filter | |
:INPUT ACCEPT [0:0] | |
:FORWARD ACCEPT [0:0] | |
:OUTPUT ACCEPT [0:0] | |
[0:0] -A OUTPUT -m state --state RELATED,ESTABLISHED -m comment --comment "allow traffic related to other allowed traffic" -j ACCEPT | |
[0:0] -A OUTPUT -p udp -m udp --dport 53 -m comment --comment "allow DNS traffic" -j ACCEPT | |
[0:0] -A OUTPUT -p tcp -m tcp --dport 53 -m comment --comment "allow DNS traffic" -j ACCEPT | |
[0:0] -A OUTPUT -p udp -m udp --dport 111 -m comment --comment "allow NFS-related traffic" -j ACCEPT | |
[0:0] -A OUTPUT -p tcp -m tcp --dport 111 -m comment --comment "allow NFS-related traffic" -j ACCEPT | |
[0:0] -A OUTPUT -p udp -m udp --dport 123 -m comment --comment "allow ntp-related traffic" -j ACCEPT | |
[0:0] -A OUTPUT -p tcp -m tcp --dport 123 -m comment --comment "allow ntp-related traffic" -j ACCEPT | |
[0:0] -A OUTPUT -d {{vlan_subnet}} -m comment --comment "allow traffic within our DMZ" -j ACCEPT | |
[0:0] -A OUTPUT -d {{external_app_address}}/32 -p tcp -m tcp --dport 443 -m comment --comment "allow traffic to the migration application" -j ACCEPT | |
[0:0] -A OUTPUT -m owner --uid-owner portage -m comment --comment "allow emerge to fetch things" -j ACCEPT | |
[0:0] -A OUTPUT -d {{portage_address}}/32 -m comment --comment "allow portage things" -j ACCEPT | |
[0:0] -A OUTPUT -d {{portage_bin_host_ip}}/32 -m comment --comment "allow emerge to query/fetch binary package info" -j ACCEPT | |
[0:0] -A OUTPUT -p tcp -m tcp --dport 8140 -m comment --comment "allow traffic to the puppetmaster" -j ACCEPT | |
{{#previous_environment_api_slices}} | |
[0:0] -A OUTPUT -p tcp -m tcp -d {{ssh_ip}}/32 --dport {{ssh_port}} -m comment --comment "allow ssh to the previous environment slice {{name}}" -j ACCEPT | |
{{/previous_environment_api_slices}} | |
[0:0] -A OUTPUT -o lo -m comment --comment "allow loopback traffic" -j ACCEPT | |
[0:0] -A OUTPUT -j LOG --log-prefix "rejected outbound: " --log-level 6 | |
[0:0] -A OUTPUT -j REJECT | |
COMMIT | |
EOF | |
{{/unpack_stage4?}} | |
{{#database_server?}} | |
{{#new}} | |
chroot /newroot /bin/bash -c 'rm -rf /root /home/eydba_maint /etc/mysql/*.cnf' | |
mkdir -p /newroot/root | |
chmod 700 /newroot/root | |
rm -f /newroot/var/spool/cron/crontabs/root | |
{{/new}} | |
{{#database_mysql_server}} | |
mysql_version=$(chroot /newroot /usr/sbin/mysqld -V | awk '{ print($3) }') | |
long_query_time=$(determine_long_query_time $mysql_version) | |
message_update "Creating starter MySQL configuration with version $mysql_version installed" | |
replace /newroot/etc/mysql/my.cnf <<EOF | |
[client] | |
port = 3306 | |
[mysql] | |
character-sets-dir=/usr/share/mysql/charsets | |
default-character-set=utf8 | |
[mysqladmin] | |
character-sets-dir=/usr/share/mysql/charsets | |
default-character-set=utf8 | |
[mysqlcheck] | |
character-sets-dir=/usr/share/mysql/charsets | |
default-character-set=utf8 | |
[mysqldump] | |
character-sets-dir=/usr/share/mysql/charsets | |
default-character-set=utf8 | |
[mysqlimport] | |
character-sets-dir=/usr/share/mysql/charsets | |
default-character-set=utf8 | |
[mysqlshow] | |
character-sets-dir=/usr/share/mysql/charsets | |
default-character-set=utf8 | |
[myisamchk] | |
character-sets-dir=/usr/share/mysql/charsets | |
[myisampack] | |
character-sets-dir=/usr/share/mysql/charsets | |
[mysqld_safe] | |
err-log = {{database_mysql_err_log}} | |
[mysqld] | |
open-files-limit = 4096 | |
max_connections = 300 | |
innodb_file_per_table = 1 | |
sync-binlog = 0 | |
log-slow-queries = {{database_mysql_slow_query_log}} | |
long_query_time = $long_query_time | |
ft_min_word_len = 3 | |
max_heap_table_size = 64M | |
tmp_table_size = 64M | |
server-id = {{database_mysql_server_id}} | |
{{#database_master}} | |
log-bin = {{database_mysql_master_log_bin}} | |
log-bin-index = {{database_mysql_master_log_bin_index}} | |
log-slave-updates=1 | |
relay-log = {{database_mysql_master_relay_log_bin}} | |
relay-log-index = {{database_mysql_master_relay_log_bin_index}} | |
#read-only | |
{{#databases}} | |
#replicate-do-db = {{name}} | |
{{/databases}} | |
{{/database_master}} | |
{{#database_replica}} | |
read-only | |
relay-log = {{database_mysql_replica_log}} | |
relay-log-index = {{database_mysql_replica_log_index}} | |
{{/database_replica}} | |
character-set-server = utf8 | |
default-character-set = utf8 | |
user = mysql | |
port = 3306 | |
pid-file = {{database_mysql_pid}} | |
log-error = {{database_mysql_err_log}} | |
basedir = /usr | |
datadir = {{database_mysql_datadir}} | |
key_buffer = 32M | |
max_allowed_packet = 32M | |
table_cache = 1024 | |
thread_cache = 512 | |
sort_buffer_size = 2M | |
net_buffer_length = 64K | |
read_buffer_size = 1M | |
read_rnd_buffer_size = 1M | |
myisam_sort_buffer_size = 2M | |
language = /usr/share/mysql/english | |
tmpdir = {{database_mysql_tmpdir}} | |
innodb_buffer_pool_size = 750M | |
innodb_additional_mem_pool_size = 16M | |
innodb_data_file_path = ibdata1:20M:autoextend | |
innodb_log_file_size = 96M | |
innodb_log_buffer_size = 8M | |
innodb_log_files_in_group = 2 | |
innodb_flush_log_at_trx_commit = 2 | |
innodb_flush_method = O_DIRECT | |
innodb_lock_wait_timeout = 50 | |
query_cache_size = 0M | |
query_cache_type = 0 | |
[mysqldump] | |
quick | |
max_allowed_packet = 32M | |
[mysql] | |
[isamchk] | |
key_buffer = 20M | |
sort_buffer_size = 20M | |
read_buffer = 2M | |
write_buffer = 2M | |
[myisamchk] | |
key_buffer = 20M | |
sort_buffer_size = 20M | |
read_buffer = 2M | |
write_buffer = 2M | |
ft_min_word_len = 3 | |
[mysqlhotcopy] | |
interactive-timeout | |
EOF | |
mkdir -p /newroot/{{database_mysql_base_directory}}/{,log,run,tmp} | |
chroot /newroot /bin/chown -R mysql:mysql {{database_mysql_base_directory}} | |
chroot /newroot /bin/chmod 700 {{database_mysql_base_directory}} | |
edit /newroot/etc/conf.d/mysql ' | |
s!"mycnf=[^"]+"!"mycnf=/etc/mysql/my.cnf"! | |
' | |
cat >>/newroot/etc/conf.d/local.start <<EOF | |
set -x | |
exec 1>/tmp/local.start.out 2>&1 | |
export HOME=/root | |
{{#database_skip_setup?}} | |
message_update "Skipping MySQL configuration and load" | |
create_mysql_dotfiles | |
{{/database_skip_setup?}} | |
{{^database_skip_setup?}} | |
message_update "Creating starter MySQL database" | |
mysql_install_db | |
message_update "Starting MySQL" | |
start_mysql | |
message_update "Securing MySQL" | |
secure_mysql | |
{{#database_archives}} | |
message_update "Loading MySQL data from {{filename}}" | |
(echo "set sql_log_bin=0;"; gunzip -c {{database_data_dir}}/{{filename}}) | mysql -B | |
{{/database_archives}} | |
echo "flush privileges;" | mysql | |
rc-update add mysql default | |
(cd /var/lib/init.d/softscripts && ln -nsf /etc/init.d/mysql mysql) | |
(cd /var/lib/init.d/started && ln -nsf /etc/init.d/mysql mysql) | |
echo "0" > /var/lib/init.d/exitcodes/mysql | |
cat >/var/run/svc-started-mysqld <<EOS | |
0={{database_mysql_pid}} | |
EOS | |
cat >/var/lib/init.d/daemons/mysql <<EOS | |
RC_DAEMONS[0]='/usr/sbin/mysqld' | |
RC_PIDFILES[0]='{{database_mysql_pid}}' | |
RC_NAMES[0]='' | |
EOS | |
{{#database_replica}} | |
hold_until_complete {{database_master_virtual_machine_name}} | |
establish_mysql_replication | |
{{/database_replica}} | |
{{/database_skip_setup?}} | |
EOF | |
{{/database_mysql_server}} | |
{{/database_server?}} | |
{{#nfs_server}} | |
message_update "Setting up NFS server" | |
chroot /newroot /sbin/rc-update add nfs default | |
replace /newroot/etc/exports <<EOF | |
{{#exported_filesystems}} | |
{{mount}} {{vlan_subnet}}(rw,sync,mp,no_root_squash) | |
{{/exported_filesystems}} | |
EOF | |
{{/nfs_server}} | |
{{#nfs_client}} | |
message_update "Setting up NFS client" | |
{{#exported_filesystems}} | |
mkdir -p {{configuration_mount}} | |
cat >> /newroot/etc/fstab <<EOF | |
{{nfs_fstab_line}} | |
EOF | |
{{/exported_filesystems}} | |
{{/nfs_client}} | |
for badservice in fence_update gfs vixie-cron nginx monit mysql net.eth1 cman ntpd postgresql-8.2 postgresql-8.3 postgresql-8.4; do | |
chroot /newroot /sbin/rc-update del $badservice | |
done | |
for goodservice in net.eth0 nfsmount dmeventd iptables; do | |
chroot /newroot /sbin/rc-update add $goodservice default | |
done | |
cat >> /newroot/etc/conf.d/local.start <<EOF | |
state_update "destination_configured" | |
message_update "Running eix-sync" | |
eix-sync | |
state_update "complete" | |
fi | |
EOF | |
mkdir -p /newroot/root/.ssh | |
chmod 700 /newroot/root/.ssh | |
cp /mnt/support/ssh/authorized_keys /newroot/root/.ssh | |
{{#from_existing}} | |
replace /newroot/root/.ssh/config <<EOF | |
ServerAliveInterval 45 | |
ServerAliveCountMax 3 | |
{{#previous_environment_api_slices}} | |
Host {{name}} | |
HostName {{ssh_ip}} | |
Port {{ssh_port}} | |
HostKeyAlias {{name}} | |
User root | |
StrictHostKeyChecking no | |
{{/previous_environment_api_slices}} | |
EOF | |
{{/from_existing}} | |
mkdir -p /newroot/engineyard/var/log | |
cp /config_{stdout,stderr} /newroot/engineyard/var/log | |
message_update "Unmounting filesystems" | |
umount /newroot/proc /newroot/sys | |
{{#filesystems_reversed}} | |
{{umount_command}} | |
{{/filesystems_reversed}} | |
state_update "configured" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment