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/)

Slax-Dude 01-05-2010 06:06 PM

Quote:

Originally Posted by Ivshti (Post 3813673)
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 :)

I would like to try those. Can you share the packages?

sahko 10-19-2010 03:58 AM

GrapefruiTgirl: did you send the scripts to Pat by any chance?

GrapefruiTgirl 10-19-2010 05:05 AM

sahko, funny you should ask at this moment. :)

For the last few days I have been griping to myself about how I'm going to have to go through all the latest Slack init-scripts again soon, see what's new and patch up my custom ones.

No, I never did send them, or the idea of them, to Pat. I never felt that there was enough of an impact caused by them for them to be something that Pat would consider. -- though the POSIX-compliance-ness of them should be of interest to him perhaps?

I wonder.. tuxdev also came up with a package of scripts too - I wonder if he forwarded the idea to Pat?

Anyhow, if there's interest from the community, and after I go over the scripts again and fix up the latest sysvinit-scripts package in my --current64, perhaps I will send the thing along to Pat and see if there's any interest. I should however set them up for #!/bin/ash rather than #!/bin/dash for obvious reasons (never say "for obvious reasons", right? ;) )

gnashley 10-19-2010 12:50 PM

Sasha, I combined your scripts with some of tuxdev's and modified some others. By using them with dash, I was able to get a boot-time of about 7 seconds on a 2.0GHz Pentium 4 machine -normal boot time was around 25-30 seconds on the same machine.
I tried to create a complete set of scripts which get called directly from the existing init routines and not worry about the init 'fragments' which are included with individual packages -letting them use the normal 'bash as sh' code.
I used a 'dedicated' shebang (#!/bin/dash) instead of substituting dash for bash as the main /bin/sh shell. It turns out that using a shebang which points to a link also slows things down. In other words, just using #!/bin/bash instead of #!/bin/sh with the standard scripts would speed things up some...

GrapefruiTgirl 10-19-2010 05:35 PM

gnashley,

thanks for the feedback and interesting statistics about speed. You've achieved a significant boot-time increase for sure. Mine doesn't boot nearly that fast at the moment, more like about a minute or so till login at init 3.

I'm currently revisiting this whole scenario beginning with the latest sysvinit-scripts-32 package that came into -current the other day.

I also tried for the heck of it, since I mentioned it earlier, using /bin/ash as the boot shell. Don't try it. It doesn't work-- I thought Dash was strict but Ash is worse -- or maybe it's just plain incapable of doing anything the least bit complicated. My machine wouldn't boot with a #!/bin/ash in rc.M, had to reboot into /bin/bash to fix it.

Finally: I'm curious if anyone has had any issues with lines which source other scripts with arguments, and how you worked around them. Like for example:
Code:

if [ -x /etc/rc.d/rc.syslog -a -x /usr/sbin/syslogd -a -d /var/log ]; then
    . /etc/rc.d/rc.syslog start
fi

In Ash for sure, the argument doesn't get passed to the sourced script. The workaround I used for Ash is:
Code:

if [ -x /etc/rc.d/rc.syslog -a -x /usr/sbin/syslogd -a -d /var/log ]; then
  func_syslog () {
    . /etc/rc.d/rc.syslog
  }
  func_syslog start
fi

gnashley: I'd be interested to have a look through the script collection you're currently using on the machine you describe above in post #19-- have you got them all in a tarball that you can email me, or would you provide or send a link where I could download them?

Thanks!

lumak 10-19-2010 11:43 PM

How much processing time would you loose to have symlinks take control of the "start" and "stop"... however that would be messy and ugly.

BTW... if you are already editing the scripts.. you can do:

CMD=start
. /etc/rc.d/rc.syslog
unset $CMD

Then instead of using $1, you could just use $CMD.. or use them both that will assign $1 to $CMD but only if $1 is set.

Bruce Hill 10-20-2010 03:44 AM

Quote:

Originally Posted by gnashley (Post 4132715)
Sasha, I combined your scripts with some of tuxdev's and modified some others. By using them with dash, I was able to get a boot-time of about 7 seconds on a 2.0GHz Pentium 4 machine -normal boot time was around 25-30 seconds on the same machine.
I tried to create a complete set of scripts which get called directly from the existing init routines and not worry about the init 'fragments' which are included with individual packages -letting them use the normal 'bash as sh' code.
I used a 'dedicated' shebang (#!/bin/dash) instead of substituting dash for bash as the main /bin/sh shell. It turns out that using a shebang which points to a link also slows things down. In other words, just using #!/bin/bash instead of #!/bin/sh with the standard scripts would speed things up some...

Perhaps I've missed something here...

Changing every script in /etc/rc.d/ which was executable from #!/bin/sh to #!/bin/bash
did not speed up my boot time by a nanosecond. It takes ~ 34 seconds to boot from the
LiLO splash screen to Linux login in runlevel 3.

I do remember years ago changing several things, backgrounding scripts, to get Slackware
to boot faster. In fact, there was a thread about fastest boot times. But heck, I don't reboot
that often. Once a month usually to use Windoze for Adobe InDesign is about it.

rmjohnso 10-20-2010 08:50 AM

Quote:

Originally Posted by Bruce Hill (Post 4133277)
Perhaps I've missed something here...

Changing every script in /etc/rc.d/ which was executable from #!/bin/sh to #!/bin/bash
did not speed up my boot time by a nanosecond. It takes ~ 34 seconds to boot from the
LiLO splash screen to Linux login in runlevel 3.

I do remember years ago changing several things, backgrounding scripts, to get Slackware
to boot faster. In fact, there was a thread about fastest boot times. But heck, I don't reboot
that often. Once a month usually to use Windoze for Adobe InDesign is about it.

Bruce, are you using bash or dash? The speed increases require you to use dash.

Bruce Hill 10-20-2010 09:07 AM

But gnashley wrote: "In other words, just using #!/bin/bash instead of #!/bin/sh with the standard scripts would speed things up some..."

Tsomi 10-20-2010 11:50 AM

Quote:

Originally Posted by GrapefruiTgirl (Post 4132918)
I also tried for the heck of it, since I mentioned it earlier, using /bin/ash as the boot shell. Don't try it. It doesn't work-- I thought Dash was strict but Ash is worse -- or maybe it's just plain incapable of doing anything the least bit complicated. My machine wouldn't boot with a #!/bin/ash in rc.M, had to reboot into /bin/bash to fix it.

Finally: I'm curious if anyone has had any issues with lines which source other scripts with arguments, and how you worked around them. Like for example:
Code:

if [ -x /etc/rc.d/rc.syslog -a -x /usr/sbin/syslogd -a -d /var/log ]; then
    . /etc/rc.d/rc.syslog start
fi

In Ash for sure, the argument doesn't get passed to the sourced script. The workaround I used for Ash is:
Code:

if [ -x /etc/rc.d/rc.syslog -a -x /usr/sbin/syslogd -a -d /var/log ]; then
  func_syslog () {
    . /etc/rc.d/rc.syslog
  }
  func_syslog start
fi

gnashley: I'd be interested to have a look through the script collection you're currently using on the machine you describe above in post #19-- have you got them all in a tarball that you can email me, or would you provide or send a link where I could download them?

Thanks!

Actually, it seems that POSIX doesn't allow you to source a script with an argument.

Well, that's what a little script called checkbashism.pl told me:
http://sourceforge.net/projects/checkbaskisms/

I used it to switch my init scripts to ash, too, a long time ago. Very useful.
This link is interesting, too: https://wiki.ubuntu.com/DashAsBinSh

So, calling /bin/ash instead of sourcing seems to be OK (sometimes, the scripts don't even need to be sourced).

Here are my initscripts :
http://www.slackware-fr.org/users/ts...cripts.tar.bz2

However, USE WITH CAUTION:
- They're not updated for what I don't use: i.e luks, cryptsetup, maybe some services...
- bash is still used at some places (especially rc.inet1)
- I have disabled some stuff like atd/crond
- I use the '-F' flag for mount, which is unsafe if you have separated partitions like /usr and /usr/local, /var and /var/www.

I could have made a cleaner version without my personal changes (which may be dangerous for others), but unfortunately, I don't have much time...

So it may help people who want to have ash-compatible scripts but it might be "dangerous" to use them "as it".

It's also quite painful to use when running -current since a lot of rc scripts lack a .new/config() thingy in doinst.sh and thus whenever Pat upgrades them your changes are lost. So, make backups.

An other improvement could be to use awk instead of cut|rev|cut|sed.

The funny thing is that, by using a small shell like ash or dash, you have a really good booting time while keeping the simple BSD-like init scripts (compared to the over-complicated upstart, initng and all that stuff). But I don't think Pat is going to accept these small changes.

Hoping it might help you the same way your scripts helped me.

gnashley 10-20-2010 12:33 PM

@Bruce Hill -I mentioned that links are slower than directly calling the desired program as a matter of theory -you need to run lots more iterations than in the init scripts in order to observe any difference.

@lumak I tried and discarded a scheme similar to waht you mention.

@Tsomi -you are right that POSIX doesn't support sourcing with appended parameters. My attempts have dealt with this in several ways. Thank you for posting a link to your files -always nice to have more comparisons(until you go crazy looking at diffs, that is...) Thanks also for mentioning checkbashisms (BTW, check the spelling in your link). I used that script (maybe slightly enhanced??) to check everything as a starting point. However, it does not take into account differences between ash and dash.

@Sasha -I am working on complying with your request for archives of my files. Hope to have it all ready by tomorrow. It's been about a year since you, Tim and I were fooling around with this and my work, back then, was still WIP. So, I had to dig back in, archive as new version what were my last efforts, and try to re-acquaint myself with what we were each doing. I spent a couple of hours today starting to write a README which tries to summarize the approach and content that you, Tim and I had going. And it tries to at least mention all possibly problematic areas of the code and the concepts I was using. Unfortunately, we have all (Tsomi too...) have included extraneous changes which are specific to our style tastes or system/hardware needs. if you only want to update your own scripts, just make a diff between script versions in Slackware-current and Slackware-12.1 (maybe it was 12.0 or 12.2) either way, the changes in the stndard scripts are very few compared to the changes in any one of our modified versions, so it'll be easier to use a diff between official versions as a guide than vice-versa.

I was building my scripts and packages for my own distro and could have done things any way I pleased. But still I tried to come up with a package-based solution which would make it possible to convert/upgrade/downgrade an existing system safely (and revertibly).

In my README, I discount the possibility of any of these ever getting into official Slackware. I doubt that PatV is very interested in POSIX-compliance *for itself*. And rocking the Slackware boat is generally frowned on... Perhaps unfortunately, my efforts to make something which installs/upgrade/downgrades cleanly led to some structural changes which were otherwise un-needed.

I'll do my best to get done with the README by tomorrow so I can upload the materials and link to them in this thread. It should be no surprise that my packages are built using src2pkg scripts, but any useful code there could easily be 'ported' to standard SlackBuild scripts. My doinst.sh scripts do much of the heavy lifting vis-a-vis clean installation.

Finally, as I went back through what I had done, I remembered a couple of details which contributed to my lower boot-times, which I have now left out of the builds. Namely, I had backgrounded all the calls to *update-* in rc.M (gtk-modules, pango and mime stuff, etc) Some of this may have already been implemented in Slackware scripts. The other thing I did, which I am sure is not in Slackware is to have commented out a 3-secnf sleep (waiting for USB modules to intialize) -definietely a no-no for a stock system. Still, the combined effect of those two categories of change amounted to 5-7 seconds, so a system using my changes (without those), would still be shaving close to 50% of the bootup time. Also, my test system had very few services being started so YMMV.

My scripts built on some of the most extensive changes which tuxdev and Sasha had already done. Aside from the extensive structural changes I made, I also spent quite a while on getting some of the most time-consuming sub-scripts working faster using ash or dash.

H_TeXMeX_H 10-20-2010 01:41 PM

I would much appreciate it if someone made a package or slackbuild out of this, because I've tried this before, but I didn't install dash in the right place, and the computer wouldn't boot properly. After fixing, I wasn't in the mood to try it again.

brianL 10-20-2010 01:49 PM

There's a SlackBuild for dash.
http://slackbuilds.org/repository/13.1/system/dash/

H_TeXMeX_H 10-20-2010 02:13 PM

I guess I could try that.

GrapefruiTgirl 10-20-2010 02:54 PM

@ gilbert,

you wrote so much in post #26 :) thank you for the detailed reply.

Of course take whatever time you need/want to put together any archive of files you wish to share. I mainly want to look through what you're using, to see if there are any nifty tricks I can throw into my own scripts, and get an idea if there's perhaps any bootup-processes that I definitely should NOT background -- I haven't gone background crazy in my implementation..

You're right -- with the variety of approaches we all have likely taken in this, and the possibly negligible gains vs effort ratio for the general population, it isn't likely that Pat would be interested in this stuff, for better or worse, and also not likely we all could (or would want to) keep a single consistent set of working scripts. And that's OK. :) It's always been more a "Slacker project" idea that anyone can take upon themselves of they're interested in playing around, and each user can decide how far they want to push it. Also, it doesn't really make sense to have just the init scripts be all nice & modern & POSIXy and all that, when there still many other non-conformant and/or just "age-old-tradition" scripts all around in other locations. I don't dare (grep) the whole system and see just how many scripts there are that need a tune-up. :/

Anyhow, thanks for the feedback & thanks everyone for their input & thoughts on this. Gilbert, I'll enjoy looking through your stuff when you get it ready - no rush (P.S. new distro? wh--where!? What?! :D)


All times are GMT -5. The time now is 11:28 PM.