Subject: pkg/23555: Suggested rc-script for mysqld
To: None <gnats-bugs@gnats.netbsd.org>
From: None <xavier.humbert@xavhome.fr.eu.org>
List: netbsd-bugs
Date: 11/24/2003 14:01:12
>Number: 23555
>Category: pkg
>Synopsis: Suggested improvement to the rc.d script for databases/mysql-server
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: pkg-manager
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Mon Nov 24 13:02:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Xavier HUMBERT
>Release: NetBSD 1.6ZF
>Organization:
>Environment:
System: NetBSD arnor.xavhome.fr.eu.org 1.6ZF NetBSD 1.6ZF (XAVIER) #1: Sat Nov 22 23:31:15 CET 2003 root@arnor.xavhome.fr.eu.org:/usr/netbsd-build/obj.i386/sys/arch/i386/compile/XAVIER i386
Architecture: i386
Machine: i386
>Description:
I'd like to submit an improvement to the rc-scrip that starts mysqld. I added status, stop and restart.
>How-To-Repeat:
>Fix:
--------------- begin patch --------------------------
--- /usr/pkg/etc/rc.d/mysqld 2003-11-24 02:40:22.000000000 +0100
+++ /etc/rc.d/mysqld 2003-11-24 13:57:56.000000000 +0100
@@ -1,25 +1,37 @@
+
#!/bin/sh
#
-# $NetBSD: mysqld.sh,v 1.2 2003/10/05 17:55:34 martti Exp $
+# $NetBSD: mysql,v 1.0 2002/02/10 01:44:37 xavier Exp $
#
# PROVIDE: mysqld
# REQUIRE: DAEMON LOGIN mountall
# KEYWORD: shutdown
-# Note: this needs NetBSD 1.6 or newer
-#
-
. /etc/rc.subr
name="mysqld"
rcvar=$name
command="/usr/pkg/bin/safe_mysqld"
-procname="/usr/pkg/libexec/${name}"
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."
@@ -27,5 +39,23 @@
${command} ${mysqld_flags} &
}
+mysqld_restart()
+{
+ check_pidfile $pidfile $name
+ mysqld_stop
+ echo "Waiting for shutdown to complete"
+ wait_for_pids $_pid
+ mysqld_start
+}
+
+mysqld_stop()
+{
+ echo "Shutting down mysqld"
+ check_pidfile $pidfile $name
+ if [ -n "$_pid" ]; then
+ kill -SIGTERM $_pid
+ fi
+}
+
load_rc_config $name
run_rc_command "$1"
----------------------- end patch -----------------------------
Best regards,
Xavier
--
Xavier HUMBERT
INJEP - Ministere Jeunesse Education Recherche
FRANCE
>Release-Note:
>Audit-Trail:
>Unformatted: