| Line | |
|---|
| 1 | #!/bin/sh |
|---|
| 2 | #--------------------------------------------------------------- |
|---|
| 3 | # Project : pxemngr |
|---|
| 4 | # File : pxemngr |
|---|
| 5 | # Copyright : 2009 Splitted-Desktop Systems |
|---|
| 6 | # Author : Frederic Lepied |
|---|
| 7 | # Created On : Fri Feb 6 09:12:51 2009 |
|---|
| 8 | # Purpose : execute pxemngr sub-commands according to the |
|---|
| 9 | # configuration file. |
|---|
| 10 | #--------------------------------------------------------------- |
|---|
| 11 | |
|---|
| 12 | CONF=${PXEMNGR_CONF=/etc/pxemngr.conf} |
|---|
| 13 | |
|---|
| 14 | . $CONF |
|---|
| 15 | |
|---|
| 16 | if [ -z "$BASEDIR" ]; then |
|---|
| 17 | echo "BASEDIR not defined in $CONF" 1>&2 |
|---|
| 18 | exit 1 |
|---|
| 19 | fi |
|---|
| 20 | |
|---|
| 21 | print_subcommands() { |
|---|
| 22 | echo "Available sub-commands:" |
|---|
| 23 | cd "$BASEDIR"/pxe/$1 |
|---|
| 24 | find . -perm -111 -a -type f|sed 's@./@ @' |
|---|
| 25 | cd "$BASEDIR"/tester/$1 |
|---|
| 26 | find . -perm -111 -a -type f|sed 's@./@ @' |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | if [ $# -lt 1 ]; then |
|---|
| 30 | echo "Usage: `basename $0` <sub-command> [<args>...]" 1>&2 |
|---|
| 31 | print_subcommands |
|---|
| 32 | exit 1 |
|---|
| 33 | fi |
|---|
| 34 | |
|---|
| 35 | if [ ! -x "$BASEDIR"/pxe/$1 -a ! -x "$BASEDIR"/tester/$1 ]; then |
|---|
| 36 | echo "Invalid pxemngr sub-command $1" 1>&2 |
|---|
| 37 | print_subcommands |
|---|
| 38 | exit 1 |
|---|
| 39 | fi |
|---|
| 40 | |
|---|
| 41 | PYTHONPATH="$BASEDIR":$PYTHONPATH |
|---|
| 42 | DJANGO_SETTINGS_MODULE=settings |
|---|
| 43 | export PYTHONPATH |
|---|
| 44 | export DJANGO_SETTINGS_MODULE |
|---|
| 45 | |
|---|
| 46 | cmd="$1" |
|---|
| 47 | shift |
|---|
| 48 | |
|---|
| 49 | if [ -x "$BASEDIR"/pxe/$cmd ]; then |
|---|
| 50 | exec "$BASEDIR/pxe/$cmd" "$@" |
|---|
| 51 | else |
|---|
| 52 | exec "$BASEDIR/tester/$cmd" "$@" |
|---|
| 53 | fi |
|---|
| 54 | |
|---|
| 55 | # pxemngr ends here |
|---|