Switch from upstart to os-refresh-config for MySQL server-id's

This is both more reliable, and more cross-platform. With the
mysql element, this upstart job is never run, as a sysvinit rather
than upstart job triggers mysql.

Change-Id: I208310048d7617ec7726eceee9e4e269f1473510
This commit is contained in:
Kiall Mac Innes 2014-05-09 14:45:12 +01:00
parent 0eec6b2744
commit 32323f8472
7 changed files with 32 additions and 45 deletions

View File

@ -4,10 +4,4 @@
set -eux
if [ "$(dib-init-system)" = "upstart" ] ; then
install $(dirname $0)/mysql-set-server-id.upstart /etc/init/mysql-set-server-id.conf
else
echo WARNING: server-id will not be set on systems that boot this image!
fi
install-packages sysstat mytop python-mysqldb mariadb-rdo-galera-server mariadb-galera galera

View File

@ -4,10 +4,4 @@
set -eux
if [ "$(dib-init-system)" = "upstart" ] ; then
install $(dirname $0)/mysql-set-server-id.upstart /etc/init/mysql-set-server-id.conf
else
echo WARNING: server-id will not be set on systems that boot this image!
fi
install-packages sysstat mytop python-mysqldb mariadb-galera-server mariadb-client galera

View File

@ -1,27 +0,0 @@
# vim: syntax=upstart
description "Set mysql server_id based on instance-id"
start on starting mysql
task
env INSTANCE_ID="/var/lib/cloud/data/instance-id"
env CONF_TARGET="/etc/mysql/conf.d/server_id.cnf"
pre-start script
if ! [ -e $INSTANCE_ID ] ; then
stop
exit 0
fi
end script
script
instance=$(cat $INSTANCE_ID)
server_id=$(python -c "print 0x${instance##i-}")
cat > $CONF_TARGET.new <<EOF
# Generated by mysql-set-server-id upstart job $(date)
# From $INSTANCE_ID ${instance}
[mysqld]
server_id = $server_id
EOF
mv -f $CONF_TARGET.new $CONF_TARGET
end script

View File

@ -0,0 +1,32 @@
#!/bin/bash
set -eux
# Set mysql server_id based on instance-id
INSTANCE_ID_FILE="/var/lib/cloud/data/instance-id"
CONF_TARGET="/etc/mysql/conf.d/server_id.cnf"
if [ ! -f $INSTANCE_ID_FILE ] ; then
exit 0
fi
if [ -f $CONF_TARGET ] ; then
echo "MySQL Server ID has already been configured"
exit 0
fi
INSTANCE_ID=$(cat $INSTANCE_ID_FILE)
if [ $INSTANCE_ID = 'nocloud' ]; then
echo "nocloud, not configuring server-id"
exit 0
fi
SERVER_ID=$(python -c "print 0x${INSTANCE_ID##i-}")
cat > $CONF_TARGET <<EOF
# Generated by os-refresh-config on $(date)
# From $INSTANCE_ID_FILE ${INSTANCE_ID}
[mysqld]
server_id = $SERVER_ID
EOF

View File

@ -5,12 +5,6 @@
set -e
set -o xtrace
if [ "$(dib-init-system)" = "upstart" ] ; then
install $(dirname $0)/mysql-set-server-id.upstart /etc/init/mysql-set-server-id.conf
else
echo WARNING: server-id will not be set on systems that boot this image!
fi
install-packages libaio1 pv rsync lsof
percona_pkgdir=Percona-XtraDB-Cluster