28 lines
609 B
Plaintext
28 lines
609 B
Plaintext
|
# 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
|