change local to run programs

This changes the local service so that it will run programs located in
@sysconfdir@/local.d instead of the local_start and local_stop functions
from @sysconfdir@/conf.d/local.

The advantage for the user is that these programs are not part
of the openrc package, so the user does not have to worry about them
being overwritten when openrc is upgraded.

X-Gentoo-Bug: 351465
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=351465
This commit is contained in:
William Hubbs 2011-01-06 12:13:33 -06:00
parent eebb2d1b9c
commit 10ce67886d
7 changed files with 41 additions and 25 deletions

View File

@ -4,7 +4,7 @@
include Makefile.inc include Makefile.inc
SUBDIR= conf.d etc init.d man scripts sh src SUBDIR= conf.d etc init.d local.d man scripts sh src
# Build our old net foo or not # Build our old net foo or not
_OLDNET_SH= case "${MKOLDNET}" in \ _OLDNET_SH= case "${MKOLDNET}" in \

View File

@ -1,5 +1,5 @@
DIR= ${CONFDIR} DIR= ${CONFDIR}
CONF= bootmisc fsck hostname local localmount network staticroute urandom CONF= bootmisc fsck hostname localmount network staticroute urandom
TARGETS+= network staticroute TARGETS+= network staticroute
CLEANFILES+= network staticroute CLEANFILES+= network staticroute

View File

@ -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
}

View File

@ -2,7 +2,7 @@
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name> # Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license. # All rights reserved. Released under the 2-clause BSD license.
description="Executes user commands in /etc/conf.d/local" description="Executes user programs in @SYSCONFDIR@/local.d"
depend() depend()
{ {
@ -12,22 +12,40 @@ depend()
start() start()
{ {
ebegin "Starting local" einfo "Starting local"
local file
for file in @SYSCONFDIR@/local.d/*.start ; do
[ -x $file ] && $file
done
if type local_start >/dev/null 2>&1; then 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 with an .start extension"
ewarn "in @SYSCONFDIR@/local.d"
local_start local_start
fi fi
eend $? "Failed to start local" return 0
} }
stop() stop()
{ {
ebegin "Stopping local" einfo "Stopping local"
local file
for file in @SYSCONFDIR@/local.d/*.stop; do
[ -x $file ] && $file
done
if type local_start >/dev/null 2>&1; then 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 with an .stop extension"
ewarn "in @SYSCONFDIR@/local.d"
local_stop local_stop
fi fi
eend $? "Failed to stop local" return 0
} }

6
local.d/Makefile Normal file
View File

@ -0,0 +1,6 @@
DIR= ${LOCALDIR}
CONF= README
MK= ../mk
include ${MK}/os.mk
include ${MK}/scripts.mk

9
local.d/README Normal file
View File

@ -0,0 +1,9 @@
This directory should contain programs or scripts which are to be run
when the local service is started or stopped.
If a file in this directory is executable and it has a .start extension,
it will be run when the local service is started. If a file is
executable and it has a .stop extension, it will be run when the local
service is stopped.
All files are processed in lexical order.

View File

@ -21,6 +21,7 @@ PICFLAG?= -fPIC
SYSCONFDIR?= ${PREFIX}/etc SYSCONFDIR?= ${PREFIX}/etc
INITDIR?= ${SYSCONFDIR}/init.d INITDIR?= ${SYSCONFDIR}/init.d
CONFDIR?= ${SYSCONFDIR}/conf.d CONFDIR?= ${SYSCONFDIR}/conf.d
LOCALDIR?= ${SYSCONFDIR}/local.d
BINDIR?= ${PREFIX}/sbin BINDIR?= ${PREFIX}/sbin
BINMODE?= 0755 BINMODE?= 0755