[systemd-devel] PATCH: handle SYSTEMCTL_OPTIONS in systemctl

Colin Guthrie gmane at colin.guthr.ie
Wed Jan 16 08:58:49 PST 2013


'Twas brillig, and Frederic Crozat at 16/01/13 16:34 did gyre and gimble:
> Hi,
> 
> on openSUSE, we found the need to sometime force "--ignore-dependencies"
> when systemctl is called (usually from other services / initscripts /
> tools started by initscripts and which can cause deadlock).
> 
> To handle this in a transparent manner, I'd like to introduce
> SYSTEMCTL_OPTIONS environment variable, which, if set, would cause
> systemctl to append its contents as if it was specified on command line.

Most common use case for this is using the --no-block and
--ignore-dependancies options. I found a need for this to prevent
deadlocks when certainly early packages (e.g. mandriva_everytime (if you
can remember back that far to your mdv days) which would do various h/w
fu (much of it outdated these days tho') and even start some services.
As this was done early in boot the starting of those services could
block in systemd - hence the need to use --no-block)

IIRC this is handled in the redhat "initscripts" (used also on Mageia -
dunno about suse...)


e.g. see this from /etc/init.d/functions (possibly a bit out of date and
IIRC slightly patched by me for Mageia too (the NO_BLOCK option)):

systemctl_redirect () {
        local s
        local prog=${1##*/}
        local command=$2
        local options=""

        case "$command" in
        start)
                s=`gprintf "Starting %s (via systemctl): " $prog`
                ;;
        stop)
                s=`gprintf "Stopping %s (via systemctl): " $prog`
                ;;
        reload|try-reload)
                s=`gprintf "Reloading %s configuration (via systemctl):
" $prog`
                ;;
        restart|try-restart|condrestart)
                s=`gprintf "Restarting %s (via systemctl): " $prog`
                ;;
        esac

        if [ -n "$SYSTEMCTL_IGNORE_DEPENDENCIES" ] ; then
                options="$options --ignore-dependencies"
        fi
        if [ -n "$SYSTEMCTL_NO_BLOCK" ] ; then
                options="$options --no-block"
        fi

        action "$s" /bin/systemctl $options $command "$prog.service"
}




-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/



More information about the systemd-devel mailing list