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... |
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 |
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 |
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:
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! |
Quote:
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:
Quote:
Quote:
Quote:
Best regards, Sasha |
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... |
"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. |
Quote:
...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' ;-). |
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? |
Quote:
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 |
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). |
Quote:
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. |
Oh, nevermind...
According to the bash manual: Quote:
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*). |
Your login shell is whatever is recorded in /etc/passwd.. It's completely unrelated to whatever shell is used in the boot scripts.
|
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. |