File: cm.sh

package info (click to toggle)
config-manager 0.3-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,180 kB
  • ctags: 802
  • sloc: sh: 8,865; cpp: 2,630; python: 2,191; makefile: 127
file content (42 lines) | stat: -rw-r--r-- 1,097 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash

# config-manager is transitioning from being a C++ binary
# to being a Python script.  Unfortunately this means that
# not all features of the C++ binary are supported by the
# Python version.

# Here we attempt to detect if the features being requested
# only require the Python version otherwise we default to
# using the binary

# the last argument is supposed to be the config
if [ -r $BASH_ARGV ]; then
    CMFILE=$BASH_ARGV
fi

if [ "X$CMFILE" == "X" ]; then
    # It ain't a file, so we'll punt and invoke the Python one
    exec /usr/bin/cm.py "$@"
fi

# okay, we have a config file (supposedly)
# let's strip out any comments first
TMPCMFILE=`/bin/tempfile`
if [ $? -ne 0 ]; then
    printf "$0: failed to create temporary file\n"
    exit 1
fi
grep -v "^#" $CMFILE >> $TMPCMFILE

# now, with our temporary file, if we only 
# find 'http' we should be able to use the 
# python version, otherwise it'll be the C++ one
COUNT=`grep -c -v http $TMPCMFILE`

/bin/rm -f $TMPCMFILE

if [ "X$COUNT" == "X0" ]; then
    exec /usr/bin/cm.py "$@"
else
    exec /usr/bin/cm.bin "$@"
fi