LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   POSIX-compatible rc.init scripts for Slack (13.0+) (https://www.linuxquestions.org/questions/slackware-14/posix-compatible-rc-init-scripts-for-slack-13-0-a-778084/)

GrapefruiTgirl 12-25-2009 02:52 PM

POSIX-compatible rc.init scripts for Slack (13.0+)
 
This thread will be a replacement/continuation of the stuff discussed over in this post here: What you'd like to see in future Slackware so I/we don't derail that thread.

Feedback should go in this thread.

This here thread basically deals with using Dash shell as /bin/sh on Slackware, and to make that work, repairing some Slackware init scripts to be POSIX compatible.

I'm attaching an updated archive here of all my rc.init scripts from my Slack64-13.0 machine, which I have edited and/or checked for POSIX compliance.
Currently I am using Dash as my system shell (/bin/sh), and am happy with this.
Most of the attached scripts are stock, or very close to it, with the exception of rc.local and maybe rc.local.shutdown, and the intention is for no change in actual functionality of the scripts-- they all work the exact same, only they can work in (theoretically) *any* shell now, not just Bash.
There's a README file in this archive, which might have something useful in it.

The archive is a tar.gz archive, with a .txt extension so it will upload here. Just rename it without the .txt and it will de-compress.

Oct 19 2010 - archive removed for now as it is pretty out-of-date. I may attach a new one in a matter of days or weeks...

tuxdev 12-28-2009 02:08 PM

Neat! I've applied these to my own system, but haven't gotten around to rebooting yet :p.

Perhaps index the rc.inet1.conf pseudo-arrays by interface name rather than integer

GrapefruiTgirl 12-28-2009 03:03 PM

Cool! Do let me know how it works for you; I have updated a whack more scripts from around my system in various locations, so I'll be uploading a new archive sooner than later.

One thing I will be doing though, is making a script to run from cron which will occasionally monitor any files I have modified, in case a package update or whatever, happens to replace something I've repaired. That way I'll know to investigate.
Until scripts get repaired upstream officially, that may be an ongoing process ;)

Sasha

leeeoooooo 12-28-2009 07:32 PM

Thanks Sasha!

According to "Ash (Almquist Shell) Variants" ...

http://www.in-ulm.de/~mascheck/various/ash/

...Slackware's ash is *based* on dash.

They just took out the Debian-specific stuff (and the letter "d"). ;-)


Further, our ash thinks it already *is* the install shell:

Quote:

ash: ash (Kenneth Almquist's ash shell)
ash:
ash: A lightweight (92K) Bourne compatible shell. Great for machines with
ash: low memory, but does not provide all the extras of shells like bash,
ash: tcsh, and zsh. Runs most shell scripts compatible with the Bourne
ash: shell. Note that under Linux, most scripts seem to use at least some
ash: bash-specific syntax. The Slackware setup scripts are a notable
ash: exception, since ash is the shell used on the install disks. NetBSD
ash: uses ash as its /bin/sh.
ash:
ash:
I agree, ash *should* be our system startup shell, if not our default shell.

As you point out, though, it's part of the AP package set, not the A package set (as bash and tcsh are!).

Thanks gobs for the tip -- and the revised scripts!
You've streamlined my system!

GrapefruiTgirl 12-28-2009 08:05 PM

Quote:

Originally Posted by leeeoooooo (Post 3807319)
Thanks Sasha!

...Slackware's ash is *based* on dash.

Hi leooooo* :)

I'm glad you've found this useful. I was aware that ash and dash are basically the same thing; but I hadn't looked into what the exact differences are. It just happened that I have read more about Dash than Ash since I began looking into all this, so my focus has been on Dash.
Since Ash is already installed, that might be one less step for folks who are interested in this stuff -- just use Ash, rather than Dash. The point is, with the scripts fixed, people can use their preferred shell, whatever it may be :)
Quote:

Further, our ash thinks it already *is* the install shell:

Yes, I seem to recall reading that the Slackware installer uses an Ash shell; someone on that other thread may have pointed that out.

Quote:

I agree, ash *should* be our system startup shell, if not our default shell.
As a startup/system shell it's really good; but as a login shell for general usage, I must say that Bash is much friendlier: The other little shells do not have History, Tab Completion, and a few other goodies that we are all used to.
Quote:

As you point out, though, it's part of the AP package set, not the A package set (as bash and tcsh are!).
Actually I believe it was someone else who pointed that out, not me ;)
Quote:

Thanks gobs for the tip -- and the revised scripts!
You've streamlined my system!

You're welcome -- I'm glad you find this helpful and/or interesting! Just remember, not much comes with a warranty, including this :D

Best regards,
Sasha

leeeoooooo 12-28-2009 08:37 PM

Yah,

I guess I wasn't thinking "friendly" (Linux myopia I guess ;-)

ksh has more useful features and is still more POSIX compliant (they say the POSIX standard was based on the earlier version of this), and some folks swear by it.


Of course, when Ubuntu changed their default shell from bash to dash, they had "#!/bin/sh" scrips crashing all over the place.

I guess I'll still be using bash, but I'll consider writing for ash (for general consumption, anyway). That's it, bash as a login shell, and ash to run scripts. Still should be faster...

gnashley 12-29-2009 12:33 AM

"Slackware's ash is *based* on dash" -that's not correct. Slackware's ash is based on an ancient BSD version of ash and uses a whole slew of patches(21). The original sources won't even come close to compiling and the patches make the sources look completely different -and make it compilable.

dash is based on ash -not the other way around. I would not expect Slackware's ash to perform exactly like dash -it may be more lenient about some non-POSIX stuff, while being less capable with other posix-correct code. In other words, trying to use dash to replace ash in the installer would probably also require changes to those scripts.

I'm going to be using Sasha's scripts on my system, but I don't want to use dash as /bin/sh, so I'll edit the scripts to use '#!/bin/dash' as the shebang. That way /bin/sh can remain as a link to /bin/bash.

leeeoooooo 12-29-2009 09:15 PM

Quote:

Originally Posted by gnashley (Post 3807472)
dash is based on ash -not the other way around.

My sources say Debian took the Linux port of ash and customized it for their purposes (and added the "d") and then Slackware took dash and removed the customizations (and the "d") for their own ash (for Slackware 8).
...whatever


Today I thought of an alternate to by bash/ash plan (above)...

...Z shell!

It's got the best bells and whistles of bash, tcsh, ksh, etc. and more of its own, but it will also emulate a fully-POSIX-compatible sh if called with #!/bin/sh. It goes *both* ways!

Oh, well...didn't mean to get into a fight over shells, to each her own...as for "friendly," I doubt most average folks would consider *any* shell 'friendly' ;-).

tuxdev 12-31-2009 01:13 PM

Using zsh as /bin/sh kind of misses the point.. It's got exactly the same issues as using bash as /bin/sh. ash and dash are more-or-less strictly POSIX, bash and zsh.. not so much. ash and dash are also light and speedy compared to bash and zsh.

Anyhow, I had to fix a few errors here and there.. and had to correct stuff in /etc/X11/xdm so that it'd properly source /etc/profile in there.

I'm planning on putting this stuff up on GitHub. That fine with you, Sasha?

GrapefruiTgirl 12-31-2009 02:03 PM

Quote:

Originally Posted by tuxdev (Post 3810204)
Using zsh as /bin/sh kind of misses the point.. It's got exactly the same issues as using bash as /bin/sh. ash and dash are more-or-less strictly POSIX, bash and zsh.. not so much. ash and dash are also light and speedy compared to bash and zsh.

Anyhow, I had to fix a few errors here and there.. and had to correct stuff in /etc/X11/xdm so that it'd properly source /etc/profile in there.

I'm planning on putting this stuff up on GitHub. That fine with you, Sasha?

Of course, that's fine with me; and if the fix-ups you have had to do, would apply to systems in general, and not just yours, then email me the files you fixed, and I'll diff them against my own, and put the fixed versions into the next archive I upload.

At first I was toying with using Dash as a login shell too, which is very likely why stuff related to sourcing /etc/profile may be a bit weird. I've since gone back to Bash as the login shell, so my profile related stuff may already be back as you have put it.

Sasha

tuxdev 01-02-2010 07:01 PM

http://github.com/tuxdev/slackware-scripts

I've pushed the first set of scripts I've personally gone through and corrected to my own style (using test over [, && and || over -a and -o, indentation, etc).

leeeoooooo 01-02-2010 09:37 PM

Quote:

Originally Posted by tuxdev (Post 3810204)
Using zsh as /bin/sh kind of misses the point.. It's got exactly the same issues as using bash as /bin/sh. ash and dash are more-or-less strictly POSIX, bash and zsh.. not so much. ash and dash are also light and speedy compared to bash and zsh.

Yeah, I've been thinking about that...

I'm under the impression that, when operating under sh compatibility mode, zsh does its best to follow POSIX, though I haven't been to confirm how closely.

My idea was to use zsh to check for the POSIX compliance of my #!/bin/sh scripts and still have access to all the bells and whistles in my day-to-day work, but of course I would have to actually call on ash to enjoy the performance benefits.


I look forward to seeing the improvements to Sasha's init scripts.

leeeoooooo 01-03-2010 02:26 PM

Oh, nevermind...

According to the bash manual:

Quote:

When invoked as `sh', Bash enters POSIX mode after reading the
startup files.
No need to go to something as big as zsh (except of the fun of it) just to emulate POSIX compliance.

ash is used for the Slackware installer. It would be nice if it would run during bootup (for speed) and then change the shell to bash for the customary niceties (*hint* *hint*).

tuxdev 01-03-2010 06:15 PM

Your login shell is whatever is recorded in /etc/passwd.. It's completely unrelated to whatever shell is used in the boot scripts.

Ivshti 01-04-2010 10:12 AM

I appreciate what you have done, great job.

However, I think initng will be much better idea for moving into the future. I've prepared packages for Slackware (I think I mentioned it somewhere in the forum, PM me if interested), and my machine boots for 30 seconds to desktop with them. Awesome stuff.
I don't think Pat will like it thought. He doesn't look very open-minded.
Your scripts are much more likely to get into Slackware :)


All times are GMT -5. The time now is 12:48 PM.