LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 12-25-2009, 02:52 PM   #1
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Lightbulb 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...

Last edited by GrapefruiTgirl; 10-19-2010 at 05:21 PM.
 
Old 12-28-2009, 02:08 PM   #2
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

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

Perhaps index the rc.inet1.conf pseudo-arrays by interface name rather than integer
 
Old 12-28-2009, 03:03 PM   #3
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Original Poster
Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
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
 
Old 12-28-2009, 07:32 PM   #4
leeeoooooo
Member
 
Registered: Jan 2009
Distribution: Slackware64 14.2 (current)
Posts: 126

Rep: Reputation: 20
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!
 
Old 12-28-2009, 08:05 PM   #5
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Original Poster
Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Quote:
Originally Posted by leeeoooooo View Post
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

Best regards,
Sasha
 
Old 12-28-2009, 08:37 PM   #6
leeeoooooo
Member
 
Registered: Jan 2009
Distribution: Slackware64 14.2 (current)
Posts: 126

Rep: Reputation: 20
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...
 
Old 12-29-2009, 12:33 AM   #7
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
"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.
 
1 members found this post helpful.
Old 12-29-2009, 09:15 PM   #8
leeeoooooo
Member
 
Registered: Jan 2009
Distribution: Slackware64 14.2 (current)
Posts: 126

Rep: Reputation: 20
Quote:
Originally Posted by gnashley View Post
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' ;-).
 
Old 12-31-2009, 01:13 PM   #9
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
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?
 
Old 12-31-2009, 02:03 PM   #10
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Original Poster
Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Quote:
Originally Posted by tuxdev View Post
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
 
Old 01-02-2010, 07:01 PM   #11
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
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).
 
Old 01-02-2010, 09:37 PM   #12
leeeoooooo
Member
 
Registered: Jan 2009
Distribution: Slackware64 14.2 (current)
Posts: 126

Rep: Reputation: 20
Quote:
Originally Posted by tuxdev View Post
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.

Last edited by leeeoooooo; 01-02-2010 at 09:41 PM.
 
Old 01-03-2010, 02:26 PM   #13
leeeoooooo
Member
 
Registered: Jan 2009
Distribution: Slackware64 14.2 (current)
Posts: 126

Rep: Reputation: 20
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*).
 
Old 01-03-2010, 06:15 PM   #14
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
Your login shell is whatever is recorded in /etc/passwd.. It's completely unrelated to whatever shell is used in the boot scripts.
 
Old 01-04-2010, 10:12 AM   #15
Ivshti
Member
 
Registered: Sep 2008
Distribution: Linvo
Posts: 132

Rep: Reputation: 43
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] init scripts, variables in INIT INFO section catkin Linux - General 1 08-18-2009 02:02 PM
Please recommend Slack-based & Slack-compatible distros. brjoon1021 Slackware 19 11-04-2007 03:14 PM
[SOLVED] Optimize slack boot process / init scripts ? H_TeXMeX_H Slackware 73 10-12-2007 04:47 AM
Wireless POSIX compatible library thebryster Linux - Laptop and Netbook 0 12-03-2004 12:44 PM
slack init scripts gui10 Slackware 11 05-15-2002 11:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 07:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration