From d274594b226c5a62dd637aa28159299d75bdeaca Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Thu, 6 Jan 2011 12:13:33 -0600 Subject: [PATCH] change local to use scripts This changes the local service so that it will run scripts located in @sysconfdir@/localstart.d when it is started and @sysconfdir@/localstop.d when it is stopped. The advantage of this is that the scripts are not part of the openrc package and will not be lost when openrc is updated. X-Gentoo-Bug: 351465 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=351465 --- Makefile | 2 +- conf.d/local | 18 ------------------ init.d/local.in | 18 +++++++++++++++++- localstart.d/00example | 3 +++ localstart.d/Makefile | 6 ++++++ localstop.d/00example | 3 +++ localstop.d/Makefile | 6 ++++++ mk/sys.mk | 2 ++ 8 files changed, 38 insertions(+), 20 deletions(-) delete mode 100644 conf.d/local create mode 100644 localstart.d/00example create mode 100644 localstart.d/Makefile create mode 100644 localstop.d/00example create mode 100644 localstop.d/Makefile diff --git a/Makefile b/Makefile index 8f9cc95..c2127f8 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ include Makefile.inc -SUBDIR= conf.d etc init.d man scripts sh src +SUBDIR= conf.d etc init.d localstart.d localstop.d man scripts sh src # Build our old net foo or not _OLDNET_SH= case "${MKOLDNET}" in \ diff --git a/conf.d/local b/conf.d/local deleted file mode 100644 index 97dbbcc..0000000 --- a/conf.d/local +++ /dev/null @@ -1,18 +0,0 @@ -# Here is where you can put anything you need to start -# that there is not an init script for. - -local_start() { - # This is a good place to load any misc programs - # on startup (use &>/dev/null to hide output) - - # We should always return 0 - return 0 -} - -local_stop() { - # This is a good place to unload any misc. - # programs you started above. - - # We should always return 0 - return 0 -} diff --git a/init.d/local.in b/init.d/local.in index 63d5e92..fa4fae1 100644 --- a/init.d/local.in +++ b/init.d/local.in @@ -2,7 +2,7 @@ # Copyright (c) 2007-2008 Roy Marples # All rights reserved. Released under the 2-clause BSD license. -description="Executes user commands in /etc/conf.d/local" +description="Executes user scripts in /etc/localstart.d and /etc/localstop.d" depend() { @@ -14,7 +14,15 @@ start() { ebegin "Starting local" + local sh + for sh in @SYSCONFDIR@/localstart.d/*.sh ; do + [ -r "$sh" ] && . "$sh" + done + if type local_start >/dev/null 2>&1; then + ewarn "@SYSCONFDIR@/conf.d/local should be removed." + ewarn "please move the code from the local_start function" + ewarn "to scripts ending in .sh in @SYSCONFDIR@/localstart.d" local_start fi @@ -25,7 +33,15 @@ stop() { ebegin "Stopping local" + local sh + for sh in @SYSCONFDIR@/localstop.d/*.sh ; do + [ -r "$sh" ] && . "$sh" + done + if type local_start >/dev/null 2>&1; then + ewarn "@SYSCONFDIR@/conf.d/local should be removed." + ewarn "please move the code from the local_stop function" + ewarn "to scripts ending in .sh in @SYSCONFDIR@/localstop.d" local_stop fi diff --git a/localstart.d/00example b/localstart.d/00example new file mode 100644 index 0000000..276c539 --- /dev/null +++ b/localstart.d/00example @@ -0,0 +1,3 @@ +# any file located in this directory which has a .sh extention will be +# run when the local service is started. +# Files are processed in lexical order. diff --git a/localstart.d/Makefile b/localstart.d/Makefile new file mode 100644 index 0000000..1f7a1ff --- /dev/null +++ b/localstart.d/Makefile @@ -0,0 +1,6 @@ +DIR= ${LOCALSTARTDIR} +CONF= 00example + +MK= ../mk +include ${MK}/os.mk +include ${MK}/scripts.mk diff --git a/localstop.d/00example b/localstop.d/00example new file mode 100644 index 0000000..400648d --- /dev/null +++ b/localstop.d/00example @@ -0,0 +1,3 @@ +# any file located in this directory which has a .sh extention will be +# run when the local service is stopped. +# Files are processed in lexical order. diff --git a/localstop.d/Makefile b/localstop.d/Makefile new file mode 100644 index 0000000..4a04ac0 --- /dev/null +++ b/localstop.d/Makefile @@ -0,0 +1,6 @@ +DIR= ${LOCALSTOPDIR} +CONF= 00example + +MK= ../mk +include ${MK}/os.mk +include ${MK}/scripts.mk diff --git a/mk/sys.mk b/mk/sys.mk index e22731b..d9cb171 100644 --- a/mk/sys.mk +++ b/mk/sys.mk @@ -21,6 +21,8 @@ PICFLAG?= -fPIC SYSCONFDIR?= ${PREFIX}/etc INITDIR?= ${SYSCONFDIR}/init.d CONFDIR?= ${SYSCONFDIR}/conf.d +LOCALSTARTDIR?= ${SYSCONFDIR}/localstart.d +LOCALSTOPDIR?= ${SYSCONFDIR}/localstop.d BINDIR?= ${PREFIX}/sbin BINMODE?= 0755 -- 1.7.3.4