Subject: pkg/19055: rc.d startup script for mysql-server
To: None <gnats-bugs@gnats.netbsd.org>
From: Julio Merino <jmmv@menta.net>
List: netbsd-bugs
Date: 11/14/2002 23:20:11
>Number:         19055
>Category:       pkg
>Synopsis:       rc.d startup script for mysql-server
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Nov 14 14:16:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Julio Merino
>Release:        NetBSD 1.6K
>Organization:
HispaBSD
>Environment:
	
	
System: NetBSD darkstar.local 1.6K NetBSD 1.6K (DARKSTAR) #130: Thu Nov 7 23:22:44 CET 2002 jmmv@darkstar.local:/var/build/kernel/DARKSTAR i386
Architecture: i386
Machine: i386
>Description:
	The mysqld-server package installs a daemon but does not provide
	a correct startup script to run it. Instead, it prints a message
	telling the user to check a file (mysql.server, iirc), which is
	very redhat-ish; this will simply confuse the user.

	The package should install a netbsd rc.d style mysqld script,
	ready to be used.
>How-To-Repeat:
	
>Fix:
	The following script has been taken from a messge to tech-pkg,
	by Xavier Humbert, with some minor modifications by me:
	    http://mail-index.netbsd.org/tech-pkg/2002/02/10/0000.html
	I think it contains some redundant stuff (maybe I'm wrong!).
	Import it as files/mysqld.sh:

#!/bin/sh
#
# $NetBSD$
#

# PROVIDE: mysqld
# REQUIRE: DAEMON LOGIN mountall
# KEYWORD: shutdown

. /etc/rc.subr

name="mysqld"
rcvar=$name
command="@PREFIX@/bin/safe_mysqld"
pidfile="/var/mysql/`hostname`.pid"
start_cmd="mysqld_start"
restart_cmd="mysqld_restart"
stop_cmd="mysqld_stop"
status_cmd="mysqld_status"
required_files="/var/mysql/mysql/host.frm"

mysqld_status()
{
	check_pidfile $pidfile $name
	if [ -n "$_pid" ]; then
		echo "${name} is running as pid $_pid."
	else
		echo "${name} is not running."
		return 1
	fi
}

mysqld_start()
{
	echo "Starting mysqld."
	ulimit -n 4096
	${command} ${mysqld_flags} &
}

mysqld_restart()
{
	check_pidfile $pidfile $name
	mysqld_stop
	echo "Waiting for mysqld shutdown to complete"
	wait_for_pids $_pid
	mysqld_start
}

mysqld_stop()
{
	echo "Stopping mysqld."
	check_pidfile $pidfile $name
	if [ -n "$_pid" ]; then
		kill -SIGTERM $_pid
	fi
}

load_rc_config $name
run_rc_command "$1"


	And now, apply this simple patch:

Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/databases/mysql-server/Makefile,v
retrieving revision 1.29
diff -u -u -r1.29 Makefile
--- Makefile	2002/09/20 10:39:07	1.29
+++ Makefile	2002/11/14 22:09:16
@@ -2,6 +2,7 @@
 #
 
 PKGNAME=		${DISTNAME:S/-/-server-/}
+PKGREVISION=		1
 SVR4_PKGNAME=		mysqs
 COMMENT=		MySQL, a free SQL database (server)
 
@@ -24,6 +25,8 @@
 
 DEINSTALL_FILE=		${WRKDIR}/DEINSTALL
 
+RCD_SCRIPTS=		mysqld
+
 post-configure:
 	cd ${WRKSRC} && ${CP} -f config.h include/my_config.h
 
@@ -44,4 +47,5 @@
 	PKG_PREFIX=${PREFIX} ${SH} ${INSTALL_FILE} ${PKGNAME} POST-INSTALL
 
 .include "../../security/tcp_wrappers/buildlink2.mk"
+.include "../../mk/bsd.pkg.install.mk"
 .include "../../mk/bsd.pkg.mk"


	Thanks
>Release-Note:
>Audit-Trail:
>Unformatted: