0

in my /etc/init.d/blabla script, which is the correct way to determine if the system is booting or the user root is runnig the script ?

I am thinking about * parent pid * euid * terminal... pts ?

Massimo
  • 260
  • 3
  • 13

1 Answers1

0

On traditional init (not systemd), your script would have $0 as something like Sxxblabla when run by init, where xx are two digits.

When run by a user, there are usually a lot of environment variables set, like USER, HOME, and so on that are not set when running from init.

Note that in general, you want the effect of running the command in the shell and running the command at startup to be as identical as possible. Otherwise it may test fine from the command line but file when you boot.

RalfFriedl
  • 3,008
  • 4
  • 12
  • 17