#!/bin/bash

# Disable startup MySQL on boot in Ubuntu
# Service mysqld doesn't start on boot in Fedora and CentOS
# Delete config property 'bind-address' for remote mode (0.0.0.0)

if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
    set -x
fi
set -eu
set -o pipefail

if [ "$DISTRO_NAME" = "ubuntu" ]; then
    if [ -e "/etc/init/mysql.conf" ]; then
        sed -i "s/start on runlevel \[.*\]/start on never runlevel [2345]/g" /etc/init/mysql.conf
        sed -i '/bind-address/d' /etc/mysql/my.cnf
    else
        update-rc.d -f mysql remove
    fi
fi

# Script for starting mysql

install -D -g root -o root -m 0755 $(dirname $0)/start-mysql.sh /opt/start-mysql.sh
