LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-13-2002, 11:41 AM   #1
marsonist
Member
 
Registered: Sep 2002
Location: Stuttgart, Germany
Distribution: SuSE 9.1 Pro
Posts: 171

Rep: Reputation: 30
need help in trying to make a script


I'm running SuSE linux 8.1 (totally awsome btw) and have the typical problem of a GUI configuration utilities rewrite my custom settings.

In my case my network interfaces try to load prior to pcmcia, and my realtek 8139 pcmcia card doesn't load. to solve the problem I have to change the names of the files in my /etc/init.d/rc5.d to re-order the boot processes.

what kind of script could i write that would, upon execution, automaticaly rename those files for me?
 
Old 10-13-2002, 11:50 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
why would you want a script? the file names will not change once you change them once.
 
Old 10-13-2002, 03:23 PM   #3
marsonist
Member
 
Registered: Sep 2002
Location: Stuttgart, Germany
Distribution: SuSE 9.1 Pro
Posts: 171

Original Poster
Rep: Reputation: 30
Yast, however handy it normally is, likes to go back and rewrite the boot files after certain types of configuration. Every few days I find myself having to manually rename three files. I was hoping that I could just write a script that root could run and rename them for me.
 
Old 10-13-2002, 03:28 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well if that really happens, just add the same lines to whatever script file you want. /etc/rc.local for example.
 
Old 10-14-2002, 06:25 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
As an alternative you could also lock them against change by using "chattr +i </pathtoand/filename>". Doubt it Yast will detect they've the immutable bit set.

I do like scripts cuz theyre flexible, so if you want a script post what needs to change from what to what and we'll see.
 
Old 10-14-2002, 11:25 AM   #6
marsonist
Member
 
Registered: Sep 2002
Location: Stuttgart, Germany
Distribution: SuSE 9.1 Pro
Posts: 171

Original Poster
Rep: Reputation: 30
I'd prefer a script so If I wanted to add or change actions it wouldn't be too difficult.

I need to change /etc/init.d/rc5.d/s08pcmcia
to " "s05pcmcia

/etc/init.d/rc5.d/s07hotplug
to " "s08hotplug

/etc/init.d/rc5.d/s05network
to " "s07network


As i don't have my computer in front of me, I'm giving those names and paths off of the top of my head, but they should be pretty close. Any suggestions on what a good script might look like? I've played with linux for a while, but am completely new to scripts.

Thanks
 
Old 10-14-2002, 01:36 PM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
slinker.sh

Maybe this'll do. Its not too subtle tho.

#!/bin/sh
# Have runlevel, or replace by a fixed number
runlevel="$(/sbin/runlevel | awk '{print $2}')"
# Dir we gotta change stuff in
b=/etc/rc.d; bd=""$b"/rc"$runlevel".d"
# Not too subtle :-]
checkSlink() { rm -f ""$bd"/S??"$1""; ln -sf "$b"/init.d/"$1" "$bd"/S"$2""$1"; }
checkSlink pcmcia 05
checkSlink hotplug 08
checkSlink network 07
exit "$?"

One tip for "foreign" scripts is to echo all commands, then you'll see if variables are ok for instance, elif you believe the commands are ok, you could run it as "sh -x <script>" to see all variables expanded as well.
 
Old 10-15-2002, 05:10 AM   #8
marsonist
Member
 
Registered: Sep 2002
Location: Stuttgart, Germany
Distribution: SuSE 9.1 Pro
Posts: 171

Original Poster
Rep: Reputation: 30
Thank you ever so much. It works great. I had to edit one of the paths, and it looked like there were an extra set of quotes laying around, but otherwise worked wonderfully. It ended up looking something like this for me:

#!/bin/sh
# Have runlevel, or replace by a fixed number
runlevel="$(/sbin/runlevel | awk '{print $2}')"
# Dir we gotta change stuff in
b=/etc/init.d; bd=""$b"/rc"$runlevel".d"
# Not too subtle :-]
checkSlink() { rm -f "$bd"/S??"$1"; ln -sf "$b"/"$1" "$bd"/S"$2""$1"; }
checkSlink pcmcia 05
checkSlink hotplug 08
checkSlink network 07
exit "$?"

now, two more questions.

1) where would be a good place to learn such scripts?

2) any idea how I could make my computer execute this on shut down?
 
Old 10-15-2002, 09:23 AM   #9
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Good it worked and thnx for the feedback, I appreciate that.
I do like excessive quoting, but even that can be affected by Mental Floss :-]
1) Lookup "Advanced Bash-Scripting Guide" (abs.tar.gz) at for instance tldp.org
2) Link into rc0.d and rc6.d and then you've covered reboot and shutdown.
 
  


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
can i make a script or program make a phone call? nephish Linux - Software 2 08-15-2005 09:02 PM
make a script! okeyla Programming 7 02-07-2005 06:04 AM
Need to make a start up script chr0no Mandriva 4 08-05-2004 10:46 AM
How to make a GUI for a Script oldstinkyfish Programming 5 07-25-2004 03:18 AM
Anyone know how to make a script that will ... kato678 Programming 4 07-19-2002 05:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:43 AM.

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