Shell script RUN_DIR

Need help with C, C++, perl, python, etc?

Shell script RUN_DIR

Postby frederiek » 2020-05-11 13:41

Hi,

What is the purpose of the RUN_DIR variable in a shell script?

The first line of the script is
#!/bin/sh -e

Regards,

Frederiek
frederiek
 
Posts: 3
Joined: 2020-05-11 13:23

Re: Shell script RUN_DIR

Postby cuckooflew » 2020-05-11 13:47

Please Read What we expect you have already Done
Search Engines know a lot, and
"If God had wanted computers to work all the time, He wouldn't have invented RESET buttons"
and
Just say NO to help vampires!
cuckooflew
 
Posts: 683
Joined: 2018-05-10 19:34
Location: Some where out west

Re: Shell script RUN_DIR

Postby Head_on_a_Stick » 2020-05-11 15:45

Do I get a prize for guessing that this is in /etc/init.d/networking? :mrgreen:

But seriously, the more information that is included in the question the better the replies will be. See also http://catb.org/~esr/faqs/smart-questions.html

In the case of the networking init script $RUN_DIR defines the directory in /run that is used by the script to keep track of the state of the service. This hack is needed because sysvinit is an antiquated pile of crap that doesn't offer true process supervision.
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 12480
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Shell script RUN_DIR

Postby neuraleskimo » 2020-05-11 16:08

Head_on_a_Stick wrote:Do I get a prize for guessing that this is in /etc/init.d/networking? :mrgreen:

Good eyes and memory! ***bowing in respect***
Black Lives Matter
User avatar
neuraleskimo
 
Posts: 193
Joined: 2019-03-12 23:26
Location: Bloomington, Indiana, USA

Re: Shell script RUN_DIR

Postby Head_on_a_Stick » 2020-05-11 16:22

^ You are too kind sir. And anyway:
Code: Select all
empty@E485 ~ % grep RUN_DIR -R /etc/init.d
/etc/init.d/networking:RUN_DIR="/run/network"
/etc/init.d/networking:IFSTATE="$RUN_DIR/ifstate"
/etc/init.d/networking:STATEDIR="$RUN_DIR/state"
/etc/init.d/networking:    if [ ! -d "$RUN_DIR" ] ; then
/etc/init.d/networking: if ! mkdir -p "$RUN_DIR" ; then
/etc/init.d/networking:     log_failure_msg "can't create $RUN_DIR"
/etc/init.d/networking: if ! chown root:netdev "$RUN_DIR" ; then
/etc/init.d/networking:     log_warning_msg "can't chown $RUN_DIR"
empty@E485 ~ %

I cheated :mrgreen:
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 12480
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Shell script RUN_DIR

Postby neuraleskimo » 2020-05-11 16:25

Head_on_a_Stick wrote:^ You are too kind sir. And anyway:
Code: Select all
empty@E485 ~ % grep RUN_DIR -R /etc/init.d
/etc/init.d/networking:RUN_DIR="/run/network"
/etc/init.d/networking:IFSTATE="$RUN_DIR/ifstate"
/etc/init.d/networking:STATEDIR="$RUN_DIR/state"
/etc/init.d/networking:    if [ ! -d "$RUN_DIR" ] ; then
/etc/init.d/networking: if ! mkdir -p "$RUN_DIR" ; then
/etc/init.d/networking:     log_failure_msg "can't create $RUN_DIR"
/etc/init.d/networking: if ! chown root:netdev "$RUN_DIR" ; then
/etc/init.d/networking:     log_warning_msg "can't chown $RUN_DIR"
empty@E485 ~ %

I cheated :mrgreen:

LOL. I am told a magician should never give away his/her secrets.
Black Lives Matter
User avatar
neuraleskimo
 
Posts: 193
Joined: 2019-03-12 23:26
Location: Bloomington, Indiana, USA

Re: Shell script RUN_DIR

Postby neuraleskimo » 2020-05-11 17:11

frederiek wrote:The first line of the script is
Code: Select all
#!/bin/sh -e

I see this is your first post. Welcome!

HOAS is helping on the RUN_DIR issue, so I will contribute in another way....

Posting the first line of the script isn't very informative because all scripts start roughly like that. That line is called the shebang or hashbang. Googling for either term will get you to a good explanation. A variation on that line is often:
Code: Select all
#!/usr/bin/env bash
or
#!/usr/bin/env python3
Black Lives Matter
User avatar
neuraleskimo
 
Posts: 193
Joined: 2019-03-12 23:26
Location: Bloomington, Indiana, USA

Re: Shell script RUN_DIR

Postby frederiek » 2020-05-14 13:25

Head_on_a_Stick wrote:Do I get a prize for guessing that this is in /etc/init.d/networking? :mrgreen:


You probably do deserve a prize for this. Whether you'll get it, that's another question. :wink:

Head_on_a_Stick wrote: But seriously, the more information that is included in the question the better the replies will be. See also http://catb.org/~esr/faqs/smart-questions.html


I know. I just thought that I had included all possible information summarized to the bare minimum of essential useful information. :mrgreen:
Fact is, I thought that $RUN_DIR was some kind of system level environment variable, with a specific purpose. And hence it would require no context. But, tying things together, especially after reading "variables part I" on http://www.shellscript.sh, it now occurred to me that for declaring a local script variable you just have to assign something to a name. And so RUN_DIR is a local variable. So, yes, you do deserve a prize, which will be my deepest respect.

Head_on_a_Stick wrote: In the case of the networking init script $RUN_DIR defines the directory in /run that is used by the script to keep track of the state of the service. This hack is needed because sysvinit is an antiquated pile of crap that doesn't offer true process supervision.


Thanks for the explanation, and your kindness.
frederiek
 
Posts: 3
Joined: 2020-05-11 13:23

Re: Shell script RUN_DIR

Postby frederiek » 2020-05-14 13:40

neuraleskimo wrote:
frederiek wrote:The first line of the script is
Code: Select all
#!/bin/sh -e

I see this is your first post. Welcome!


Thanks.

neuraleskimo wrote:Posting the first line of the script isn't very informative because all scripts start roughly like that. That line is called the shebang or hashbang. Googling for either term will get you to a good explanation. A variation on that line is often:
Code: Select all
#!/usr/bin/env bash
or
#!/usr/bin/env python3


I knew that. I really did. I posted this script line, because... and, now I need to think deep. It was because I wanted to mention what kind of scripting language I was talking about. So this would be shell script. Maybe this RUN_DIR variable had a specific meaning within this scripting language. Maybe it was some kind of special parameter specific to this scripting language. Anyway, it's all resolved know. And I see things clear now. At least about how to define local script variables.

So, thanks for the advice, and for baring with me.
frederiek
 
Posts: 3
Joined: 2020-05-11 13:23

Re: Shell script RUN_DIR

Postby None1975 » 2020-05-15 14:35

frederiek wrote:Hi,

What is the purpose of the RUN_DIR variable in a shell script?

The first line of the script is
#!/bin/sh -e

Regards,

Frederiek



Hello. Check this:

https://www.shellscript.sh/variables1.html
OS: Debian 10.3 Buster / WM: xmonad
Debian Wiki | DontBreakDebian, My config files on github
User avatar
None1975
 
Posts: 1019
Joined: 2015-11-29 18:23
Location: Lithuania, Vilnius

Re: Shell script RUN_DIR

Postby trinidad » 2020-05-17 13:18

sysvinit is an antiquated pile of crap that doesn't offer true process supervision


:D

TC
You can't believe your eyes if your imagination is out of focus.
trinidad
 
Posts: 134
Joined: 2016-08-04 14:58

Re: Shell script RUN_DIR

Postby LE_746F6D617A7A69 » 2020-05-17 19:13

Head_on_a_Stick wrote:In the case of the networking init script $RUN_DIR defines the directory in /run that is used by the script to keep track of the state of the service. This hack is needed because sysvinit is an antiquated pile of crap that doesn't offer true process supervision.

I agree that sysvinit had many problems (but it was used on biggest servers for at least 3 decades - and it was stable) - systemd is even much worse crap - it has hundreds of bugs, mainly resulting from unresolved logic races.

Of course, it works mostly correct in typical cases, but if You're unlucky, systemd can totally mess up Your services or even crash Your server.

For example: about 2 weeks ago, I was automatically logged off, because I've disconnected the USB stick (!) - I had an important program running at the time - and it has been terminated because of the logoff action - I've lost 10 hours to recover the results computed by that program. To be clear: I'm using stable Buster release, no ppa's, flatpacks, etc - I know what I'm doing.

Systemd is just more "modern" pile of crap.

Regards.

PS
I'm still trying to discover what have actually happened, but since systemd sources are ~2000 times bigger than sysvinit, it's hard to find the bug ...
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed
LE_746F6D617A7A69
 
Posts: 340
Joined: 2020-05-03 14:16

Re: Shell script RUN_DIR

Postby Head_on_a_Stick » 2020-05-17 19:51

LE_746F6D617A7A69 wrote:systemd is even much worse crap

I do not disagree. OpenRC ftw!

LE_746F6D617A7A69 wrote:I'm still trying to discover what have actually happened, but since systemd sources are ~2000 times bigger than sysvinit, it's hard to find the bug ...

C.A.R. Hoare wrote:There are two ways of constructing a software design: one way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies.
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 12480
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Shell script RUN_DIR

Postby Bloom » 2020-05-17 20:07

LE_746F6D617A7A69 wrote:Systemd is just more "modern" pile of crap.

Then run Devuan. That's a fork of Debian that uses sysvinit instead of systemd.
User avatar
Bloom
 
Posts: 290
Joined: 2017-11-11 12:23

Re: Shell script RUN_DIR

Postby LE_746F6D617A7A69 » 2020-05-17 20:58

Bloom wrote:Then run Devuan. That's a fork of Debian that uses sysvinit instead of systemd.


I know that. But Devuan has limited resources - in terms of security patches...

Regards
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed
LE_746F6D617A7A69
 
Posts: 340
Joined: 2020-05-03 14:16

Next

Return to Programming

Who is online

Users browsing this forum: No registered users and 7 guests

fashionable