Deciphering rc.inet1 on Slackware 12.1 Part 1
After attempting to configure AirLink 101 802.11g PCI network card with an ACX111 chip under Slackware 12.1, I came to the rationalization that I needed a better understanding of Linux network initialization scripts I was able to successfully compile and install the driver and firmware but the computer would hang displayed Triggering udev events. I believe this to be because a DHCP server can not be found. While trying to troubleshoot this I found that I did not understand the network initialization process and needed a review of shell scripting. So Before I continue further, I have decided to write this post to better my understanding of the entire process of bringing up network interfaces in Linux.
The script used to bring up network interfaces at boot is /etc/rc.d/rc.inet1 and it is executed by /etc/rc.d/rc.M with this code:
#Initialize the networking hardware if [-x /etc/rc.d/rc.inet1 ]; then . /etc/rc.d/rc.inet1 fi
This if statements checks if rc.inet1 can be found and is executable by using the -x operator. If rc.inet1 exists and is executable rc.M executes it using the source operator.
Overview of /etc/rc.d/rc.inet1
- includes the configuration information from rc.inet1.conf
- Sets up logging
- Fills an array of interfaces from entries in rc.inet1.conf
- Creates a the following functions
- lo_up() to bring up loopback interface, do nothing if loopback is already up
- lo_down() take down the loopback interface
- if_up() to bring up a network interface, do nothing if already up or does not exist
- if_down() to take down a network interface
- gateway_up() brings up the gateway if there is not yet a default route
- gateway_down() take down an existing default gateway
- start() start the network
- stop() stop the network
- The main script
The Main Script
The execution of rc.inet1 begins with a case statement which provides various cases for starting stopping and restarting the network.
Since the script is executed by rc.M without parameters the default case is executed. The default case first calls the lo_up function to bring up the loopback device. It then iterates through the devices found in rc.inet1 using a for statement. It then uses a for loop to iterate through the devices from rc.inet1.conf which are stored in the IFNAME array. The for loop calls the if_up function passing it the name of each device. Finally gateway_up is called to bring up the gateway.
Bash Operators used in rc.inet1
| . | Read & execute commands from source file no matter if it is executable http://ss64.com/bash/period.html |
| -f | true if the regular file exist |
| -a | AND |
| -x | true if the argument is an existing executable file |
| ! | not |
| “” and ” | double quotes will display the contents of a variable, single quotes display what is enclosed literally |
Other good things to know about Bash
| $! | PID of last process that has been started in the background (e.g. firefox &) |
| exit | (0-255) 0 is success http://tldp.org/LDP/abs/html/exit-status.html |
| $? | return value of last command |
| $# | Number of command line arguments |
| $0 | Name of the shell script being executed. |
| $@ | variable, which expands to all command-line parameters separated by spaces |
Things that are still not clear
what's the deal with the parenthesis: i=$(($i+1))
what's the deal with the brackets: IFNAME[$i]=${IFNAME[$i]:=eth${i}}

October 18th, 2010 at 12:05 pm
You mention such a great things here and it is always pleassure to read. Hope to hear more and learn from you.
October 18th, 2010 at 4:39 pm
Greetings! Is it alright if I go a bit off topic? I’m trying to read your website on my Blackberry but it doesn’t display properly, do you have any suggestions? Thanks in advance! Blake
October 19th, 2010 at 4:28 pm
Thanks for good stuff
October 20th, 2010 at 4:37 pm
If the problem is with the bash operator table it was because a <p> tag found its way into the table. I also fixed some other things, so it might display correctly now.
November 11th, 2010 at 6:02 pm
Your post is really wonderful..thanks for posting…your post is very informative
November 12th, 2010 at 12:50 am
Brilliant. Thanks for the list.
November 12th, 2010 at 9:58 pm
Cool…
November 13th, 2010 at 10:28 pm
Very pleasing to read post! Will be eagerly waiting for the second good part.
November 14th, 2010 at 7:46 am
Pretty nice post. I just stumbled upon your blog and wanted to say that I have really enjoyed browsing your blog posts. In any case I’ll be subscribing to your feed and I hope you write again soon!
November 14th, 2010 at 3:14 pm
found your site on del.icio.us today and really liked it.. i bookmarked it and will be back to check it out some more later
November 15th, 2010 at 4:06 pm
Great read, I just passed this onto a colleague who was doing a little analysis on that. And he in fact bought me lunch because I found it for him…. smile.. So let me rephrase that: Thanks for lunch! But yeah Thank you for taking the time to discuss this, I feel strongly about it and enjoy learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me. Big thumb up for this blog!
November 15th, 2010 at 9:54 pm
great content thanks for info
November 17th, 2010 at 5:45 pm
Beneficial info and excellent design you got here! I want to thank you for sharing your ideas and putting the time into the stuff you publish! Great work!
November 17th, 2010 at 6:54 pm
This write up is nice. I’ll post in my blog and translate it in French.