Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Shell script RUN_DIR

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
frederiek
Posts: 3
Joined: 2020-05-11 13:23

Shell script RUN_DIR

#1 Post by frederiek »

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

cuckooflew
Posts: 677
Joined: 2018-05-10 19:34
Location: Some where out west
Been thanked: 1 time

Re: Shell script RUN_DIR

#2 Post by cuckooflew »

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!

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Shell script RUN_DIR

#3 Post by Head_on_a_Stick »

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.
deadbang

neuraleskimo
Posts: 195
Joined: 2019-03-12 23:26

Re: Shell script RUN_DIR

#4 Post by neuraleskimo »

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***

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Shell script RUN_DIR

#5 Post by Head_on_a_Stick »

^ 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:
deadbang

neuraleskimo
Posts: 195
Joined: 2019-03-12 23:26

Re: Shell script RUN_DIR

#6 Post by neuraleskimo »

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.

neuraleskimo
Posts: 195
Joined: 2019-03-12 23:26

Re: Shell script RUN_DIR

#7 Post by neuraleskimo »

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

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

Re: Shell script RUN_DIR

#8 Post by frederiek »

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

#9 Post by frederiek »

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.

User avatar
None1975
df -h | participant
df -h | participant
Posts: 1387
Joined: 2015-11-29 18:23
Location: Russia, Kaliningrad
Has thanked: 45 times
Been thanked: 64 times

Re: Shell script RUN_DIR

#10 Post by None1975 »

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 12.4 Bookworm / DE: Enlightenment
Debian Wiki | DontBreakDebian, My config files on github

trinidad
Posts: 289
Joined: 2016-08-04 14:58
Been thanked: 13 times

Re: Shell script RUN_DIR

#11 Post by trinidad »

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.

LE_746F6D617A7A69
Posts: 932
Joined: 2020-05-03 14:16
Has thanked: 7 times
Been thanked: 65 times

Re: Shell script RUN_DIR

#12 Post by LE_746F6D617A7A69 »

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

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Shell script RUN_DIR

#13 Post by Head_on_a_Stick »

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.
deadbang

User avatar
Bloom
df -h | grep > 90TiB
df -h | grep > 90TiB
Posts: 503
Joined: 2017-11-11 12:23
Been thanked: 26 times

Re: Shell script RUN_DIR

#14 Post by Bloom »

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.

LE_746F6D617A7A69
Posts: 932
Joined: 2020-05-03 14:16
Has thanked: 7 times
Been thanked: 65 times

Re: Shell script RUN_DIR

#15 Post by LE_746F6D617A7A69 »

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

anticapitalista
Posts: 428
Joined: 2007-12-14 23:16
Has thanked: 11 times
Been thanked: 13 times

Re: Shell script RUN_DIR

#16 Post by anticapitalista »

LE_746F6D617A7A69 wrote:
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
They get them from upstream Debian
antiX with runit - lean and mean.
https://antixlinux.com

LE_746F6D617A7A69
Posts: 932
Joined: 2020-05-03 14:16
Has thanked: 7 times
Been thanked: 65 times

Re: Shell script RUN_DIR

#17 Post by LE_746F6D617A7A69 »

anticapitalista wrote:
LE_746F6D617A7A69 wrote:
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
They get them from upstream Debian
Yes, but they lag behind quite often.
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

Post Reply