source: tags/confman-1.5.6a2/confmancommon.sh @ 185

Revision 185, 2.0 KB checked in by arjun, 4 years ago (diff)

Fixed the locking bug

  • 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`
18if [ -z $MY_PID ] ; then
19    MY_PID="$$"
20fi
21# First things first. Check to see if the logging fd is open. If it's not,
22# we re-spawn confman inside a pipe.
23if (true >&5) 2>/dev/null ; then
24        exec 4>&2 2>&5 >&3-
25else
26        exec 3>&1
27        exec $0 "$@" 5>&1 1>&3 | logger -t "$MYNAME[$$]: $USER" -s
28        exit ${PIPESTATUS[0]}
29fi
30
31# Get the global config
32if [ -f $GCONF ] ; then 
33        . $GCONF
34else
35        echo "Global config file couldn't be located" >&2
36        exit 1
37fi
38
39# Get the user config
40if [ -f $UCONF ] ; then
41        . $UCONF
42fi
43
44# Set debugging:
45if [ -z $DEBUG ] ; then
46        DEBUG="false"
47fi
48
49if [ -z "$REPO_DB" ] || [ -z "$CONF_EXPORT_FILE" ] \
50    || [ -z "$CONF_EXPORT_URI" ] || [ -z "$CONF_GROUP" ] ; then
51    echo "$GCONF is out-of-date. Please see the ChangeLog" >&2
52    exit 1
53fi
54
55# Test if the specified group exists before setting folder groups
56if ! [ -d "$REPO_DB" ] ; then
57        if ! [ conf_checkgroup ]; then
58                sudo install -d -o root -m 770 "$REPO_DB"
59        else
60                sudo install -d -o root -g $CONF_GROUP -m 770 "$REPO_DB"
61        fi
62        sudo chmod g+s "$REPO_DB"
63fi
64
65# Now, we source the library
66if [ -f $REPO_LIBRARY ] ; then
67        . $REPO_LIBRARY
68else
69        echo "Couldn't source the confman shell library" >&2
70        exit 1
71fi
72
73# And the documentation library
74if [ -f $REPO_DOCS ] ; then
75        . $REPO_DOCS
76else
77        echo "Couldn't source the confman shell library" >&2
78        exit 1
79fi
80
81# And we read in the layers that make this host
82if [ -f $RECIPE_PATH ] ; then
83        LAYERS=`cat $RECIPE_PATH | grep "^[^#]"`
84else
85        echo "Couldn't read the host's recipe!" >&2
86        exit 1
87fi
88
89# And we'll set a trap:
90trap "conf_cleanExit" SIGINT SIGTERM SIGHUP
91
Note: See TracBrowser for help on using the repository browser.