Determine if systemD is running

    path
        path to the container parent

        .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt '*' lxc.running_systemd ubuntu

def running_systemd(name, cache=True, path=None):
    '''
    Determine if systemD is running

    path
        path to the container parent

        .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt '*' lxc.running_systemd ubuntu

    '''
    k = 'lxc.systemd.test.{0}{1}'.format(name, path)
    ret = __context__.get(k, None)
    if ret is None or not cache:
        rstr = __salt__['test.random_hash']()
        # no tmp here, apparmor won't let us execute !
        script = '/sbin/{0}_testsystemd.sh'.format(rstr)
        # ubuntu already had since trusty some bits of systemd but was
        # still using upstart ...
        # we need to be a bit more careful that just testing that systemd
        # is present
        _script = textwrap.dedent(
            '''\
            #!/usr/bin/env bash
            set -x
            if ! command -v systemctl 1>/dev/null 2>/dev/null;then exit 2;fi
            for i in \\
                /run/systemd/journal/dev-log\\
                /run/systemd/journal/flushed\\
                /run/systemd/journal/kernel-seqnum\\
                /run/systemd/journal/socket\\
                /run/systemd/journal/stdout\\
                /var/run/systemd/journal/dev-log\\
                /var/run/systemd/journal/flushed\\
                /var/run/systemd/journal/kernel-seqnum\\
                /var/run/systemd/journal/socket\\
                /var/run/systemd/journal/stdout\\
            ;do\\
                if test -e ${i};then exit 0;fi
            done
            if test -d /var/systemd/system;then exit 0;fi
            exit 2
            ''')
        result = run_all(
            name, 'tee {0}'.format(script), path=path,
            stdin=_script, python_shell=True)
        if result['retcode'] == 0:
            result = run_all(name,
                             'sh -c "chmod +x {0};{0}"'''.format(script),
                             path=path,
                             python_shell=True)
        else:
            raise CommandExecutionError(
                'lxc {0} failed to copy initd tester'.format(name))
        run_all(name,
                'sh -c \'if [ -f "{0}" ];then rm -f "{0}";fi\''
                ''.format(script),
                path=path,
                ignore_retcode=True,
                python_shell=True)
        if result['retcode'] != 0:
            error = ('Unable to determine if the container \'{0}\''
                     ' was running systemd, assmuming it is not.'
                     ''.format(name))
            if result['stderr']:
                error += ': {0}'.format(result['stderr'])
        # only cache result if we got a known exit code
        if result['retcode'] in (0, 2):
            __context__[k] = ret = not result['retcode']
    return ret