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/lib/initscripts/legacy-actions/<service>/<action>
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.
https://bugzilla.redhat.com/show_bug.cgi?id=796663
---
Makefile | 1 +
initscripts.spec | 1 +
service | 14 ++++++++++----
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 3d1ae95..c1a8921 100644
--- a/Makefile
+++ b/Makefile
@@ -143,6 +143,7 @@ install:
ln -s rc.d/$$i $(ROOT)/etc/$$i; \
done
+ mkdir -p -m 755 $(ROOT)/usr/lib/initscripts/legacy-actions
syntax-check:
diff --git a/initscripts.spec b/initscripts.spec
index 55e2833..84fac05 100644
--- a/initscripts.spec
+++ b/initscripts.spec
@@ -299,6 +299,7 @@ rm -rf $RPM_BUILD_ROOT
%ghost %verify(not md5 size mtime) %config(noreplace,missingok) /etc/crypttab
%dir /etc/tmpfiles.d
/etc/tmpfiles.d/initscripts.conf
+%dir %{_prefix}/lib/initscripts/legacy-actions
%files legacy
%defattr(-,root,root)
diff --git a/service b/service
index 2e2d4ea..4585f71 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/lib/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
- [ -c /dev/stderr ] && echo $"Redirecting to /bin/systemctl ${OPTIONS}
${SERVICE}.service" >/dev/stderr
- exec /bin/systemctl ${OPTIONS} ${SERVICE}.service
+ [ -c /dev/stderr ] && echo $"Redirecting to /bin/systemctl ${ACTION}
${OPTIONS} ${SERVICE}.service" >/dev/stderr
+ exec /bin/systemctl ${ACTION} ${OPTIONS} ${SERVICE}.service
fi
--
1.7.10.2