Itās leftover from an old scriptā¦
Iāll clean that up some more.
It was part of a script that Iād it wound have had to run an chown, it would have taken a long time because of terabytes of files.
Itās leftover from an old scriptā¦
Iāll clean that up some more.
It was part of a script that Iād it wound have had to run an chown, it would have taken a long time because of terabytes of files.
Also, I wasnāt sure what the install command would do if the directories were already there.
So my logic is, if the directories arenāt there, install will create them, and if they are, make sure they are owned by the user.
should just overwrite the file with the given UID and GID.
wait! Are you installing
a directory or a binary program (I could be steering you down the wrong path)?
Just a directory. Itās where the log file and pid file will go once the program runs.
Then if were only talking about a directory, Iād do something like this:
slskd_startprecmd() {
# 'mkdir -p' will not overwrite a directory if it exists
mkdir -p /var/run/${name}
mkdir -p /var/log/${name}
chown ${slskd_user}:${slskd_group} /var/run/${name};
chown ${slskd_user}:${slskd_group} /var/log/${name};
}
This is sightly verbose, but it also allows for easy removal/additional when future versions change.
EDIT:
1.The install
program is for copying a binary file (a program) from one location to another (so my direction above was leading you down the wrong path).
2. Removed the recursive flag from chown
(the -R) because multiple files are not involved.
I missed this logic explanation from you.
Your logic can be simplified to two (2) statements.
The base syntax is:
if [predicate] [consequent] [alternative]
The base logic is:
If the āpredicate
ā is TRUE then do the āconsequent
ā, else do the āalternative
ā.
The modification I propose, in the code directly above, is to eliminate the āpredicate
ā (or more accurately combine it with a revised statement) and take the millisecond performance drop (if there is one) in trade to ensure the proper permissions exist no matter what the conditions are. My logic is: āI always want to make sure proper permissions exist, but I should also make sure the directory exists as well.ā
Sorry, I didnāt mean to make that sound āpreachyā; just trying to cover my bases in that explanation (you could be a genius programmer, for all I know, and think my explanation is good coming from a potato).
For the record, Iām ambivalent towards the āmark as solutionā feature.
There are some drawbacks to it:
Iām fine with that.
@John Iām also good with your advise. Itās easier to read and such.
Thatās fine; itās your thread. But Victor deserves the gold-star IMO.
Oh, look at that; I added āin my opinionā to text I just wrote. Or was that redundancy lost and possibly gotten away with not pointing out my idiocy.
Simple is best. I remember running into the āinstallā command the first time. Whatā¦
The way you propose is clean and easy to follow.
The logic is the interesting part about programming.
For example: I know itās not related, so to speak, but itās a fun story nonetheless. I had an interaction with a new architect writing some python code to produce building layouts with a CAD package. They asked me what I thought: āIt produces 23 parking garage layouts in seconds.ā My reply was āyou can save time by reading a bookā. When they asked what I meant I said: āwhen you have 23 different layouts you need āknowledgeā to know which layout is the ācorrectā one, so if you just read a book (i.e. gain āknowledgeā) and produce the ācorrectā layoutāonceāyouād save yourself, the structural, electrical and mechanical engineerās time.ā. ā¦If you were wondering, they never spoke to me again.
Typical these daysā¦
Sounds like an angry person. Maybe they need to do some soul searching? Or maybe someā¦ soul seeking?
Iām sorry.
Iāll accept the apology. lol
It could be my laconic nature but I feel as though I āinspire angerā in a lot of people. Speaking of which, I was going to write a post on how to āignore meā. I forgot. I should put that on my list of things todo.
I guess a ālesson learnedā from this is that it was really due to the application itself, and not FreeBSD rc scripting. (Even though rc scripting was āpartā of the issue.)
Yes and no. I agree but I think the job of the rc.d scripting mechanism is to be as flexible as possible and I think it proved that in this case. Iām not sure about the flexibility of the systemfile
method of systemd
though. In the past systemd
has been constraining and volatile so I suspect the systemfile
method could possibly become more/less constrained over time so, there is no telling what future hoops the app developer may have to jump though and what that may mean for āportabilityā. Hopefully that is on the dotnet library porting shouldersāin this appās case. The C# language is an extremely volatile language though; please note: dotNet at itās core is rock solid but developer trends are what cause disturbances.