Installation manual

6. 2. Network Profile Management 53
#start fvwm as window/session manager
fvwm
Note: Contrary to popular belief, the existence of the environment variable PS1 does not indicate an interactive
shell. If the current shell is the non-interactive child of an interactive shell, it inherits PS1 from the parent shell.
We hav e to test the shell flags for interactivity.
Source of /usr/local/bin/readenv:
/* readenv.c
*alittle hack to read a file containing statements like
*export VAR=VALUE
*and then print them as
*setenv VAR VALUE
*tostdout.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main (int argc, char **argv)
{
char string[2048], *var, *val;
FILE *file;
if ( argc != 2 ) return EXIT_FAILURE;
if ( (file = fopen(argv[1], "r")) == NULL ) return EXIT_FAILURE;
do
{
fgets(string, sizeof(string), file);
if ( !feof(file) )
{
val = strstr(string, "export");
strsep(&val, " ");
var = strsep(&val, "=");
if ( var && val ) printf("setenv %s %s;", var, val);
}
}
while (!feof(file));
fclose(file);
return EXIT_SUCCESS;
}
Note: If we replace export and setenvwith alias, this program can also be used to read a shell independent alias
definition file.
6. 2. Network Profile Management
Originally,wehad installed a nifty package called laptop-net, which was supposed to autodetect to which net-
work our machine was connected to and then automagically reconfigure the system correspondingly.Unfortu-
nately,this package neverworked as advertised and the package maintainer did not bother to answer emails. We
therefore decided to scrap laptop-net and roll our own replacement.
Similarly as the laptop-net package, we makethe distinction between a network scheme and a network profile.A
scheme describes the network interface and the network connection, whereas a profile describes the system con-
figuration, which is selected for a givenscheme. The advantage of this setup is that we can this way easily map
the same profile to different schemes or different profiles to the same scheme.
The different schemes are defined in the network interface description file /etc/network/interfaces: