Conditional statements in the startup script?

Is it possible to test for the existence of a file in the startup script and execute different commands depending on whether the file exists?

I’ve been looking around the site for an answer and what little I’ve found on the topic seems to suggest that it can’t be done, but I thought I’d ask to see if anyone knows of a way to do it.

it is not possible. Workaround is to write a program a la diskboot.

Or simply write a shell script (ksh, not esh)

We’re basically doing what cburgess suggested.

We create a file: /etc/rc.d/rc.local

Inside rc.local we call another script: /usr/local/bin/configme

So configme is run every time the system boots up.

Inside configme we do something like this (syntax is probably garbled: this is from memory) to test to see if the file exists and is executable:

if [ -x /somedir/config.$HOSTNAME ]
blah, blah…

Since we tie the hostname to the geographic location of each system (which also determines some of its functionality) we pull the hostname out of /etc/net.cfg before doing this test in configme. Then, if there is a file named config.$HOSTNAME it runs it and sets up the configuration specific to the location tied to that hostname.

This is probably more convoluted than it absolutely needs to be, but it does work. :slight_smile: