[CentOS] Systemd and systemd-sysv-generator

Wed Dec 30 15:47:22 UTC 2015
James Hogarth <james.hogarth at gmail.com>

On 30 December 2015 at 15:25, Mike - st257 <silvertip257 at gmail.com> wrote:

> On Wed, Dec 30, 2015 at 10:06 AM, James Hogarth <james.hogarth at gmail.com>
> wrote:
>
> >
> > > > Best way to see this is using systemctl (status|cat|show)
> <servicename>
> > > ...
> > > >
> > > > I expect if you do this for your failing service you'll get a better
> > > > understanding of what's going on.
> > >
> > >
> > > ~]# systemctl status lsi_mrdsnmp.service
> > > ● lsi_mrdsnmp.service
> > >    Loaded: not-found (Reason: No such file or directory)
> > >    Active: inactive (dead)
> > >
> > > ~]# systemctl cat lsi_mrdsnmp.service
> > > Unit lsi_mrdsnmp.service is not loaded: No such file or directory
> > >
> > > ~]# systemctl show lsi_mrdsnmp.service | egrep 'Name|Load'
> > > Names=lsi_mrdsnmp.service
> > > LoadState=not-found
> > > LoadError=org.freedesktop.DBus.Error.FileNotFound "No such file or
> > > directory"
> > >
> > >
> > >
> > Can you pastebin the init script by any chance? I wonder if it's
> actually a
> > properly written init script or if it's bad enough  that the generator
> > fails to parse it ...
>
>
> Yes - here is a pastebin with that script.
>
> And there was an error on line 130 ... or line 133 of the pastebin -- which
> I already fixed. ;-)
> (I verified the typo against the contents of the RPM from LSI to be
> certain.)
> if ( "$rhel_ver" == "1" && "oel_ver" == "0" ) ; then
> should have been
> if ( "$rhel_ver" == "1" && "$oel_ver" == "0" ) ; then
>
>
> http://pastebin.com/BGLjGiuT
>
>
>
That doesn't even make sense ... if it's both rhel and oel version 7 then
systemctl start <Service>  ... :/

Some lovely samples from it:
 #A function to stop a program.
statuscheck() {

Let's import the standard distro function library! then ...
mykillproc()
{


Okay we might have a pid we think ... better kill it ...

               kill -TERM $pid
               usleep 200000
               if ps h $pid >/dev/null  >/dev/null 2>&1 ; then
                sleep 1
                if ps h $pid >/dev/null  >/dev/null 2>&1 ; then
                        sleep 3
               ...

Hmm we have a snmpd dependency...
if [ -x /etc/init.d/snmpd ] ; then
            /etc/init.d/snmpd start

./twitch && ./vomit

That's so badly written it wouldn't surprise me if it just barfed and gave
up ...

According to
https://github.com/systemd/systemd/blob/master/src/sysv-generator/sysv-generator.c
though the journal (or syslog) should contain a Failed to create unit file
<foo> if it couldn't translate it though ...

I'd seriously just give up on that and do the 3-5 line systemd unit that is
soo much cleaner ... you could even have a proper snmpd.service dependency
in place then!