aboutsummaryrefslogtreecommitdiffstats
path: root/rc.d
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2010-08-24 15:04:08 -0400
committerBill Nottingham <notting@redhat.com>2010-08-24 15:10:02 -0400
commit3b755b613c07bdda82b558b8f4afb0442c79e05b (patch)
tree485c2bb67b0408fd4105e057428dbe068e337c57 /rc.d
parente40133a36b02122f0d1ae443c3118debdd6c1eac (diff)
downloadinitscripts-3b755b613c07bdda82b558b8f4afb0442c79e05b.tar
initscripts-3b755b613c07bdda82b558b8f4afb0442c79e05b.tar.gz
initscripts-3b755b613c07bdda82b558b8f4afb0442c79e05b.tar.bz2
initscripts-3b755b613c07bdda82b558b8f4afb0442c79e05b.tar.xz
initscripts-3b755b613c07bdda82b558b8f4afb0442c79e05b.zip
If systemd is running, redirect start/stop/condrestart/etc. to systemctl. (#612728)
Diffstat (limited to 'rc.d')
-rw-r--r--rc.d/init.d/functions52
1 files changed, 50 insertions, 2 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions
index 3ce93ecf..b2f8c95c 100644
--- a/rc.d/init.d/functions
+++ b/rc.d/init.d/functions
@@ -13,11 +13,40 @@ umask 022
PATH="/sbin:/usr/sbin:/bin:/usr/bin"
export PATH
+if [ $PPID -ne 1 -a -z "$SYSTEMCTL_SKIP_REDIRECT" ] && /bin/mountpoint -q /cgroup/systemd ; then
+ case "$0" in
+ /etc/init.d/*|/etc/rc.d/init.d/*)
+ _use_systemctl=1
+ ;;
+ esac
+fi
+
+systemctl_redirect () {
+ local s
+ local prog=${1##*/}
+ local command=$2
+
+ case "$command" in
+ start)
+ s=$"Starting $prog (via systemctl): "
+ ;;
+ stop)
+ s=$"Stopping $prog (via systemctl): "
+ ;;
+ reload|try-reload)
+ s=$"Reloading $prog configuration (via systemctl): "
+ ;;
+ restart|try-restart|condrestart)
+ s=$"Restarting $prog (via systemctl): "
+ ;;
+ esac
+
+ action "$s" /bin/systemctl $command "$prog.service"
+}
+
# Get a sane screen width
[ -z "${COLUMNS:-}" ] && COLUMNS=80
-# /sbin/consoletype checks the type of stdin. Since we are mostly
-# interested in output, we use redirection to check stdout/stderr instead.
[ -z "${CONSOLETYPE:-}" ] && CONSOLETYPE="$(/sbin/consoletype < /dev/stderr)"
if [ -z "${NOLOCALE:-}" ] && [ -z "${LANGSH_SOURCED:-}" ] && [ -f /etc/sysconfig/i18n ] ; then
@@ -411,6 +440,11 @@ status() {
fi
base=${1##*/}
+ if [ "$_use_systemctl" = "1" ]; then
+ systemctl status ${0##*/}.service
+ return $?
+ fi
+
# First try "pidof"
__pids_var_run "$1" "$pid_file"
RC=$?
@@ -768,3 +802,17 @@ init_crypto() {
# A sed expression to filter out the files that is_ignored_file recognizes
__sed_discard_ignored_files='/\(~\|\.bak\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d'
+
+if [ "$_use_systemctl" = "1" ]; then
+ if [ "x$1" = xstart -o \
+ "x$1" = xstop -o \
+ "x$1" = xrestart -o \
+ "x$1" = xreload -o \
+ "x$1" = xtry-restart -o \
+ "x$1" = xforce-reload -o \
+ "x$1" = xcondrestart ] ; then
+
+ systemctl_redirect $0 $1
+ exit $?
+ fi
+fi