#!/bin/sh

# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

SYSTEMCTL=systemctl

systemd_status=
systemd_is_active()
{
	if [ -z "$systemd_status" ]; then
		sd_booted && "$SYSTEMCTL" --version >/dev/null 2>&1
		systemd_status=$?
	fi
	return $systemd_status
}

if systemd_is_active; then
	$SYSTEMCTL set-environment _WSREP_NEW_CLUSTER='--wsrep-new-cluster' && \
		$SYSTEMCTL start ${1:-mysqld}
	$SYSTEMCTL set-environment _WSREP_NEW_CLUSTER=''
else
	service mysqld new-cluster
fi

