+ # skip comments and empty lines
+ /^[;#]|^ *$/ { next }
+
+ /^[ \t]*\[.*\][ \t]*$/ {
+ match($0, /\[.*\]/);
+ section = substr($0, RSTART + 1, RSTART + RLENGTH - 3);
+ next;
+ }
+
+ section == "mysqld" {
+ if ($1 == "datadir") {
+ printf("MYSQL_DATA_DIR=%s;", $2);
+ } else if ($1 == "user") {
+ printf("MYSQL_USER=%s;", $2);
+ } else if ($1 == "pid-file") {
+ printf("MYSQL_PIDFILE=%s;", $2);
+ } else if ($1 == "socket") {
+ printf("MYSQL_SOCKET=%s;", $2);
+ } else if ($1 == "port") {
+ printf("MYSQL_PORT=%s;", $2);
+ } else if ($1 == "bind-address") {
+ printf("MYSQL_BIND_ADDRESS=%s;", $2);
+ } else if ($1 == "skip-networking") {
+ printf("MYSQL_SKIP_NETWORKING=1;");
+ } else if ($1 == "log-error") {
+ printf("MYSQL_LOG_ERROR=%s;", $2);
+ }
+ }
+ ' $config_file`
+
+ # error log not defined in config file. add one
+ if [ -z "$MYSQL_LOG_ERROR" ]; then
+ MYSQL_LOG_ERROR=$MYSQL_ERRLOG
+ else
+ # unset, so mysqld would use value from config itself
+ unset MYSQL_LOG_ERROR
+ fi