[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#741930: reportbug: add current init system information



Hi Michael et al,

On Mon, Nov 3, 2014 at 1:19 PM, Michael Biebl <biebl@debian.org> wrote:
>> provided above one requires to check a dir existence and the checking
>> a command and then execute it to parse its output. it seems a bit
>> fragile, and maybe only upstart check really the running processes
>
> The systemd system runtime directory is only created when systemd is the
> active PID 1. Could you elaborate why you think this approach is
> fragile? If those two tests (for systemd and upstart) would be brittle,
> we'd have a problem, since they are used all over the place.

well, mkdir can create it too :) but ok, those checks are so embedded
that i can ignore if the reportbug check if fooled to thing theres
another systems (there will be bigger problems indeed) so I will just
mimik their logic in the code; I changed the sample scripts, attached,
and it would be nice if you all could give it another round (thanks to
everyone who already did!) in particular to those having an upstart
init system.

Cheers,
-- 
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi
import os
import subprocess

init = 'unable to detect'

if os.path.isdir('/run/systemd/system'):
    init = 'systemd (via /run/systemd/system)'
if not subprocess.call('. /lib/lsb/init-functions ; init_is_upstart', shell=True):
    init = 'upstart (via init_is_upstart()'
elif os.path.isfile('/sbin/init') and not os.path.islink('/sbin/init'):
    init = 'sysvinit (via /sbin/init)'

print 'Init: %s' % init

Reply to: