# Shell code in rc.conf file



## freethread (Mar 11, 2014)

An unusual question regarding rc.conf.

In my rc.conf I set the virtual console properties in this way


```
allscreens_flags="MODE_283"
font8x8="swiss-8x8"
font8x14="swiss-8x14"
font8x16="swiss-8x16"
keymap="it.iso.kbd"
keyrate="fast"
```

For some machines I also have KDE installed and usually I start KDM. In that scenario I comment the above lines and uncomment the line


```
kdm_enable="YES"
```

Sometimes, I want to disable KDM to test Xorg settings and such, that is switching from a 'console only' to a 'GUI only' environment and back. Now, the file rc.conf is executed as a shell script. It's correct to put in it things like the following?


```
console_mode="YES"
...
keymap="it.iso.kbd"
keyrate="fast"
if [ "$console_mode" = "YES" ]; then
    allscreens_flags="MODE_283"
    font8x8="swiss-8x8"
    font8x14="swiss-8x14"
    font8x16="swiss-8x16"
else
    kdm_enable="YES"
fi
```

I think this works, but I wish to have an opinion about the DOs and DON'Ts sh code in rc.conf file.


----------



## J65nko (Mar 11, 2014)

rc.conf is sourced in the various startup scripts with `. /etc/rc.conf` .During booting this is done multiple times, so you should not start programs in this file.
Conditionalizing variable settings like your example should be OK.


----------



## freethread (Mar 11, 2014)

Many thanks @J65nko, I'm not instrested to starting programs, for that sort of things I use crontab or /usr/local/etc/rc.d custom daemons, yes only conditionalizing variable settings.


----------

