source: tags/confman-1.5.4/confmancommon.sh @ 142

Revision 142, 1.8 KB checked in by ccowart, 5 years ago (diff)

A couple more minor bug fixes.

  • Property svn:keywords set to Id
Line 
1#! /bin/bash
2
3##
4# This file is a global include for all confman-based utilities. It
5# provides the common interfaces for loading the shell library, setting
6# up the use of syslog, and reading configurations.
7#
8# Author:   Chris Cowart <ccowart@rescomp.berkeley.edu>
9#           4 December 2006
10#
11# $Id$
12##
13
14# Some global definitions. Defaults that can be overriden by options.
15GCONF="/usr/local/rescomp/etc/confman.conf"
16UCONF="${HOME}/.confmanrc"
17MYNAME=`basename $0`
18
19# First things first. Check to see if the logging fd is open. If it's not,
20# we re-spawn confman inside a pipe.
21if (true >&5) 2>/dev/null ; then
22        exec 4>&2 2>&5 >&3-
23else
24        exec 3>&1
25        exec $0 "$@" 5>&1 1>&3 | logger -t "$MYNAME[$$]: $USER" -s
26        exit ${PIPESTATUS[0]}
27fi
28
29# Get the global config
30if [ -f $GCONF ] ; then 
31        . $GCONF
32else
33        echo "Global config file couldn't be located" >&2
34        exit 1
35fi
36
37# Get the user config
38if [ -f $UCONF ] ; then
39        . $UCONF
40fi
41
42# Set debugging:
43if [ -z $DEBUG ] ; then
44        DEBUG="false"
45fi
46
47if [ -z "$REPO_DB" ] || [ -z "$CONF_EXPORT_FILE" ] \
48    || [ -z "$CONF_EXPORT_URI" ] || [ -z "$CONF_GROUP" ] ; then
49    echo "$GCONF is out-of-date. Please see the ChangeLog" >&2
50    exit 1
51fi
52
53if ! [ -d "$REPO_DB" ] ; then
54    sudo install -d -o root -g $CONF_GROUP -m 770 "$REPO_DB"
55    sudo chmod g+s "$REPO_DB"
56fi
57
58# Now, we source the library
59if [ -f $REPO_LIBRARY ] ; then
60        . $REPO_LIBRARY
61else
62        echo "Couldn't source the confman shell library" >&2
63        exit 1
64fi
65
66# And the documentation library
67if [ -f $REPO_DOCS ] ; then
68        . $REPO_DOCS
69else
70        echo "Couldn't source the confman shell library" >&2
71        exit 1
72fi
73
74# And we read in the layers that make this host
75if [ -f $RECIPE_PATH ] ; then
76        LAYERS=`cat $RECIPE_PATH | grep "^[^#]"`
77else
78        echo "Couldn't read the host's recipe!" >&2
79        exit 1
80fi
81
82# And we'll set a trap:
83trap "conf_cleanexit" SIGINT SIGTERM SIGHUP
84
Note: See TracBrowser for help on using the repository browser.