Re: [systemd-devel] Detect if a script runs during bootup

2015-11-23 Thread Frank Steiner
Colin Guthrie wrote

> Zbigniew Jędrzejewski-Szmek wrote on 11/11/15 15:55:
>> On Wed, Nov 11, 2015 at 04:39:23PM +0100, Frank Steiner wrote:
>>> Isn't there an easy way to figure out if this script is running
>>> inside the boot process? Some variable set or not yet set?
>> You can use systemctl is-system-running (see the man page).
> 
> I guess another option would just be to write out a flag file into /run
> tree when you do the first call. First call the file won't exist, all
> subsequent calls it will.
> 
> That might fit better with a scripted solution than calling out to an
> exec, but YMMV.

I finally did that and it works well, thanks :-)

-- 
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. BioinformatikMail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17   Phone: +49 89 2180-4049
80333 Muenchen, Germany   Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Detect if a script runs during bootup

2015-11-12 Thread Frank Steiner
Reindl Harald wrote

>> This is not possible as it is an opensuse system script that I cannot
>> replace.
> 
> says who?
> 
> thats why /etc/systemd/system/ exists - override sysvinit scripts and 
> even systemd-units from packages - just name it identical and it will win

Right, but it's the /etc/init.d/nfsserver script that I'm not going
to replace as it does a lot of stuff for setting up the nfs server
the way the SuSE folks want it...

Zbigniew Jędrzejewski-Szmek wrote

> You can use systemctl is-system-running (see the man page).

The systemd in SLE 12 does not yet know about this option, but I'll
ask for an update. 

Thanks so far!

cu,
Frank



-- 
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. BioinformatikMail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17   Phone: +49 89 2180-4049
80333 Muenchen, Germany   Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Detect if a script runs during bootup

2015-11-12 Thread Colin Guthrie
Zbigniew Jędrzejewski-Szmek wrote on 11/11/15 15:55:
> On Wed, Nov 11, 2015 at 04:39:23PM +0100, Frank Steiner wrote:
>> Isn't there an easy way to figure out if this script is running
>> inside the boot process? Some variable set or not yet set?
> You can use systemctl is-system-running (see the man page).

I guess another option would just be to write out a flag file into /run
tree when you do the first call. First call the file won't exist, all
subsequent calls it will.

That might fit better with a scripted solution than calling out to an
exec, but YMMV.

Col



-- 

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/

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Detect if a script runs during bootup

2015-11-12 Thread Frederic Crozat
Le jeudi 12 novembre 2015 à 11:31 +0100, Frank Steiner a écrit :
> Reindl Harald wrote
> 
> > > This is not possible as it is an opensuse system script that I
> > > cannot
> > > replace.
> > 
> > says who?
> > 
> > thats why /etc/systemd/system/ exists - override sysvinit scripts
> > and 
> > even systemd-units from packages - just name it identical and it
> > will win
> 
> Right, but it's the /etc/init.d/nfsserver script that I'm not going
> to replace as it does a lot of stuff for setting up the nfs server
> the way the SuSE folks want it...

For the record, nfsserver initscript is being replaced by a set of
systemd service files in upcoming SLE12 SP1 ;)


-- 
Frederic Crozat
Enterprise Desktop Release Manager
SUSE



___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Detect if a script runs during bootup

2015-11-11 Thread Frank Steiner
Hi,

is there an easy way to figure out if a LSB script in /etc/init.d/
is called during bootup by systemd? I need to distinguish the first
execution during boot from subsequent calls (cron, manually etc.).

It seems that /sbin/runlevel returns "unknown" during bootup, but
I'm not sure if this reliable or not.

cu,
Frank
-- 
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. BioinformatikMail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17   Phone: +49 89 2180-4049
80333 Muenchen, Germany   Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Detect if a script runs during bootup

2015-11-11 Thread Tomasz Torcz
On Wed, Nov 11, 2015 at 12:03:10PM +0100, Frank Steiner wrote:
> Hi,
> 
> is there an easy way to figure out if a LSB script in /etc/init.d/
> is called during bootup by systemd? I need to distinguish the first
> execution during boot from subsequent calls (cron, manually etc.).
> 
> It seems that /sbin/runlevel returns "unknown" during bootup, but
> I'm not sure if this reliable or not.

  I would suggest splitting the "on boot only" part into separate
unit, with RemainAfterExit=true.  The main part should require boot-only
part.
  First of all, create a proper unit and drop LSB script.
 

-- 
Tomasz TorczThere exists no separation between gods and men:
xmpp: zdzich...@chrome.pl   one blends softly casual into the other.

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Detect if a script runs during bootup

2015-11-11 Thread Zbigniew Jędrzejewski-Szmek
On Wed, Nov 11, 2015 at 12:17:59PM +0100, Tomasz Torcz wrote:
> On Wed, Nov 11, 2015 at 12:03:10PM +0100, Frank Steiner wrote:
> > Hi,
> > 
> > is there an easy way to figure out if a LSB script in /etc/init.d/
> > is called during bootup by systemd? I need to distinguish the first
> > execution during boot from subsequent calls (cron, manually etc.).
> > 
> > It seems that /sbin/runlevel returns "unknown" during bootup, but
> > I'm not sure if this reliable or not.
> 
>   I would suggest splitting the "on boot only" part into separate
> unit, with RemainAfterExit=true.  The main part should require boot-only
> part.
>   First of all, create a proper unit and drop LSB script.
+1.

There's no distinction between "boot" and "subsequnct calls":
what if boot takes a bit longer and cron calls the script during
boot?

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Detect if a script runs during bootup

2015-11-11 Thread Frank Steiner
Tomasz Torcz wrote

> I would suggest splitting the "on boot only" part into separate
> unit, with RemainAfterExit=true.  The main part should require boot-only
> part.
> First of all, create a proper unit and drop LSB script.

This is not possible as it is an opensuse system script that I cannot
replace.

Zbigniew Jędrzejewski-Szmek wrote

> There's no distinction between "boot" and "subsequnct calls":
> what if boot takes a bit longer and cron calls the script during
> boot?

That wouldn't matter. The LSB script is called several times with
different parameters. It always sources another script. In this
script I need to perform an action only at the first time this
script is sourced during the boot process. Thus having a flag 
letting me know that I'm inside the boot sequence would be enough 
to have an unique situation for performing this special action.

If I was able to work with systemd unit files, I could perfectly
do what I want, but I'm stuck with this LSB file.

Isn't there an easy way to figure out if this script is running
inside the boot process? Some variable set or not yet set?

cu,
Frank


-- 
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. BioinformatikMail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17   Phone: +49 89 2180-4049
80333 Muenchen, Germany   Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Detect if a script runs during bootup

2015-11-11 Thread Zbigniew Jędrzejewski-Szmek
On Wed, Nov 11, 2015 at 04:39:23PM +0100, Frank Steiner wrote:
> Isn't there an easy way to figure out if this script is running
> inside the boot process? Some variable set or not yet set?
You can use systemctl is-system-running (see the man page).

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Detect if a script runs during bootup

2015-11-11 Thread Jóhann B . Guðmundsson



On 11/11/2015 03:39 PM, Frank Steiner wrote:

If I was able to work with systemd unit files, I could perfectly
do what I want, but I'm stuck with this LSB file.

Why are you stuck with that lsb file and what exactly does it do?
( Paste the content of it )

JBG
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Detect if a script runs during bootup

2015-11-11 Thread Reindl Harald



Am 11.11.2015 um 16:39 schrieb Frank Steiner:

Tomasz Torcz wrote


I would suggest splitting the "on boot only" part into separate
unit, with RemainAfterExit=true.  The main part should require boot-only
part.
First of all, create a proper unit and drop LSB script.


This is not possible as it is an opensuse system script that I cannot
replace.


says who?

thats why /etc/systemd/system/ exists - override sysvinit scripts and 
even systemd-units from packages - just name it identical and it will win


[root@srv-rhsoft:~]$ ls /etc/rc.d/init.d/vmware

-rwxr-xr-x 1 root root 14K 2015-11-01 21:01 /etc/rc.d/init.d/vmware
[root@srv-rhsoft:~]$ systemctl status vmware
● vmware.service - VMware Workstation Service
   Loaded: loaded (/etc/systemd/system/vmware.service; enabled; vendor 
preset: disabled)

   Active: active (exited) since Mi 2015-11-11 10:32:47 CET; 6h ago
 Main PID: 985 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/vmware.service



signature.asc
Description: OpenPGP digital signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel