freebsd-ports/databases/mysql-proxy/files/mysql-proxy.in
Doug Barton 83eb2c3700 In the rc.d scripts, change assignments to rcvar to use the
literal name_enable wherever possible, and ${name}_enable
when it's not, to prepare for the demise of set_rcvar().

In cases where I had to hand-edit unusual instances also
modify formatting slightly to be more uniform (and in
some cases, correct). This includes adding some $FreeBSD$
tags, and most importantly moving rcvar= to right after
name= so it's clear that one is derived from the other.
2012-01-14 08:57:23 +00:00

53 lines
1.7 KiB
Bash

#!/bin/sh
# $FreeBSD$
#
# PROVIDE: mysql-proxy
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf to enable mysql-proxy:
# mysql_proxy_enable (bool): Set to "NO" by default.
# Set it to "YES" to enable MySQL Proxy.
# mysql_proxy_address (str): Set to ":4040" by default.
# Set listening address:port of the proxy-server.
# mysql_proxy_backend_addresses (str): Set to "127.0.0.1:3306" by default.
# Set address:port of the remote backend-servers
# mysql_proxy_pid_file (path): Default to "/var/run/mysql-proxy.pid"
# Set PID file in case we are started as daemon
# mysql_proxy_args (str): Default to ""
# Custom additional arguments to be passed to mysql-proxy:
# --proxy-read-only-backend-addresses=<host:port> - address:port of the remote slave-server
# --proxy-skip-profiling - disables profiling of queries (default: enabled)
# --proxy-fix-bug-25371 - fix bug #25371 (mysqld > 5.1.12) for older libmysql versions
# --proxy-lua-script=<file> - filename of the lua script
# --no-proxy - don't start proxy-server
. /etc/rc.subr
name="mysql_proxy"
rcvar=mysql_proxy_enable
load_rc_config $name
: ${mysql_proxy_enable="NO"}
: ${mysql_proxy_address=":4040"}
: ${mysql_proxy_backend_addresses="127.0.0.1:3306"}
start_precmd="${name}_prestart"
mysql_proxy_prestart()
{
local addr
for addr in ${mysql_proxy_backend_addresses}; do
command_args="${command_args} --proxy-backend-addresses=${addr}"
done
}
pidfile="${mysql_proxy_pid_file:-"/var/run/mysql-proxy.pid"}"
command=%%PREFIX%%/libexec/mysql-proxy
command_args="--proxy-address=${mysql_proxy_address} ${mysql_proxy_args} --daemon --pid-file=${pidfile}"
procname=%%PREFIX%%/libexec/mysql-proxy
run_rc_command "$1"