From 6342995a8951fba570ccc0689094a36513958bea Mon Sep 17 00:00:00 2001 From: Michal Schmidt Date: Thu, 14 Jun 2012 16:54:50 +0200 Subject: service: add support for legacy custom actions This adds support for legacy initscript actions such as service iptables save Packages wishing to provide legacy actions should install programs (probably scripts, but could be binaries) named /usr/libexec/initscripts/legacy-actions// It should be emphasized that this feature is meant to be used only in packages where compatibility of custom actions with previous releases is desired. Adding of entirely new actions is discouraged. Useful tools should be shipped by upstreams as programs in /usr/bin, not in distro-specific hacks. [ Modifications from original : change from /usr/lib to /usr/libexec - notting ] https://bugzilla.redhat.com/show_bug.cgi?id=796663 --- service | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'service') diff --git a/service b/service index 6aabd6fc..86b6f29f 100755 --- a/service +++ b/service @@ -5,8 +5,10 @@ VERSION="$(basename $0) ver. 0.91" USAGE="Usage: $(basename $0) < option > | --status-all | \ [ service_name [ command | --full-restart ] ]" -SERVICE= SERVICEDIR="/etc/init.d" +ACTIONDIR="/usr/libexec/initscripts/legacy-actions" +SERVICE= +ACTION= OPTIONS= if [ $# -eq 0 ]; then @@ -58,6 +60,8 @@ while [ $# -gt 0 ]; do fi elif [ -z "${SERVICE}" ]; then SERVICE="${1}" + elif [ -z "${ACTION}" ]; then + ACTION="${1}" else OPTIONS="${OPTIONS} ${1}" fi @@ -67,8 +71,10 @@ while [ $# -gt 0 ]; do done if [ -f "${SERVICEDIR}/${SERVICE}" ]; then - env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES=${SYSTEMCTL_IGNORE_DEPENDENCIES} SYSTEMCTL_SKIP_REDIRECT=${SYSTEMCTL_SKIP_REDIRECT} "${SERVICEDIR}/${SERVICE}" ${OPTIONS} + env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES=${SYSTEMCTL_IGNORE_DEPENDENCIES} SYSTEMCTL_SKIP_REDIRECT=${SYSTEMCTL_SKIP_REDIRECT} "${SERVICEDIR}/${SERVICE}" ${ACTION} ${OPTIONS} +elif [ -x "${ACTIONDIR}/${SERVICE}/${ACTION}" ]; then + env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES=${SYSTEMCTL_IGNORE_DEPENDENCIES} SYSTEMCTL_SKIP_REDIRECT=${SYSTEMCTL_SKIP_REDIRECT} "${ACTIONDIR}/${SERVICE}/${ACTION}" ${OPTIONS} else - echo $"Redirecting to /bin/systemctl ${OPTIONS} ${SERVICE}.service" >&2 - exec /bin/systemctl ${OPTIONS} ${SERVICE}.service + echo $"Redirecting to /bin/systemctl ${ACTION} ${OPTIONS} ${SERVICE}.service" >&2 + exec /bin/systemctl ${ACTION} ${OPTIONS} ${SERVICE}.service fi -- cgit v1.2.1