Commit 9e18f58e authored by Leigh B. Stoller's avatar Leigh B. Stoller

The basis of a reorganized (and common) directory structure for the

client side code. Two new files, to be included by any client side
script, which define all the paths. For /bin/sh scripts:

	. /etc/emulab/paths.sh

and for perl scripts:

	BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }

Each defines a number of variables: ETCDIR, BINDIR, VARDIR, BOOTDIR,
LOGDIR, and LOCKDIR. They also set the path properly for the script.

This gets rid of the different hardwired paths, and reduces it to just
one for everyone.
parent 77661f58
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved.
#
package emulabpaths;
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw( $BINDIR $ETCDIR $VARDIR $BOOTDIR $LOGDIR $LOCKDIR );
#
# This path stuff will go away when the world is consistent. Until then
# we need to be able to upgrade individual scripts to the various setups.
# I know, what a mess.
#
$BINDIR = "";
$ETCDIR = "";
$VARDIR = "";
$BOOTDIR = "";
$LOGDIR = "/var/tmp";
$LOCKDIR = "/var/tmp";
if (-d "/usr/local/etc/emulab") {
$BINDIR = "/usr/local/etc/emulab";
unshift(@INC, "/usr/local/etc/emulab");
if (-d "/etc/emulab") {
$ETCDIR = "/etc/emulab";
}
else {
$ETCDIR = "/usr/local/etc/emulab";
}
$VARDIR = "/var/emulab";
$BOOTDIR = "/var/emulab/boot";
$LOGDIR = "/var/emulab/logs";
$LOCKDIR = "/var/emulab/lock";
}
elsif (-d "/etc/testbed") {
unshift(@INC, "/etc/testbed");
$ETCDIR = "/etc/testbed";
$BINDIR = "/etc/testbed";
$VARDIR = "/etc/testbed";
$BOOTDIR = "/etc/testbed";
}
elsif (-d "/etc/rc.d/testbed") {
unshift(@INC, "/etc/rc.d/testbed");
$ETCDIR = "/etc/rc.d/testbed";
$BINDIR = "/etc/rc.d/testbed";
$VARDIR = "/etc/rc.d/testbed";
$BOOTDIR = "/etc/rc.d/testbed";
}
else {
print "$0: Cannot find proper emulab paths!\n";
exit 1;
}
#
# Untaint path
#
$ENV{'PATH'} = "$BINDIR:/bin:/sbin:/usr/bin:/usr/sbin:".
"/usr/local/bin:/usr/local/sbin:/usr/site/bin:/usr/site/sbin";
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
1;
#!/bin/sh
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved.
#
#
# This path stuff will go away when the world is consistent. Until then
# we need to be able to upgrade individual scripts to the various setups.
# Of course, the old setups need /etc/emulab/paths.{sh,pm} installed
# if any new scripts are installed too. I know, what a mess.
#
LOGDIR=/var/tmp
LOCKDIR=/var/tmp
if [ -d /usr/local/etc/emulab ]; then
BINDIR=/usr/local/etc/emulab
if [ -e /etc/emulab/client.pem ]; then
ETCDIR=/etc/emulab
else
ETCDIR=/usr/local/etc/emulab
fi
VARDIR=/var/emulab
BOOTDIR=/var/emulab/boot
LOGDIR=/var/emulab/logs
LOCKDIR=/var/emulab/lock
elif [ -d /etc/testbed ]; then
ETCDIR=/etc/testbed
BINDIR=/etc/testbed
VARDIR=/etc/testbed
BOOTDIR=/etc/testbed
elif [ -d /etc/rc.d/testbed ]; then
ETCDIR=/etc/rc.d/testbed
BINDIR=/etc/rc.d/testbed
VARDIR=/etc/rc.d/testbed
BOOTDIR=/etc/rc.d/testbed
else
echo "$0: Cannot find proper emulab paths!"
exit 1
fi
export ETCDIR
export BINDIR
export VARDIR
export BOOTDIR
export LOGDIR
export LOCKDIR
PATH=$BINDIR:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:\
/usr/site/bin:/usr/site/sbin
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment