]> git.sur5r.net Git - bacula/bacula/blob - gui/bweb/script/starthttp
bweb: permit relatif path to starthttp command
[bacula/bacula] / gui / bweb / script / starthttp
1 #!/bin/sh
2
3 # start bweb with lighttpd
4
5 BASE=$(dirname $0)
6
7 if [ -f $PWD/html/bweb.js ]; then
8    BWEBBASE=$PWD
9
10 elif [ -f $PWD/../html/bweb.js ]; then
11     BWEBBASE=$(dirname $PWD)
12
13 elif [ -f $BASE/html/bweb.js ]; then
14     BWEBBASE=$BASE
15
16 elif [ -f $BASE/../html/bweb.js ]; then
17     BWEBBASE=$(cd $BASE; dirname $(pwd))
18
19 else
20     echo "Can't determine bweb installation directory"
21     exit 1
22 fi
23
24 grep /etc/bacula/bweb.conf $BWEBBASE/lib/Bweb.pm > /dev/null
25 if [ $? -eq 0 ]; then
26     echo "Adjusting bweb.conf path"
27     sed -i~ "s:/etc/bacula/bweb.conf:$BWEBBASE/bweb.conf:" $BWEBBASE/lib/Bweb.pm
28 fi
29
30 if [ ! -f $BWEBBASE/bweb.conf ]; then
31     echo "Making configuration template in $BWEBBASE/bweb.conf"
32     cat > $BWEBBASE/bweb.conf <<EOF
33 \$VAR1 = { template_dir => '$BWEBBASE/lang',
34            bconsole => 'bconsole -n',
35            fv_write_path => '/tmp/',
36  };
37 EOF
38 fi
39
40 host=$(awk -F'"' '/bind/ { print $2 }' $BWEBBASE/script/httpd.conf)
41 port=$(awk '/port/ { print $3 }' $BWEBBASE/script/httpd.conf)
42
43 echo "Using bweb on $BWEBBASE,  use firefox http://$host:$port"
44 export BWEBBASE
45
46 if [ x$1 = x -o x$1 = xstart ]; then
47     lighttpd -f $BWEBBASE/script/httpd.conf
48
49     if [ $? -ne 0 ]; then
50         echo "Something is wrong with lighttpd, be sure that it is installed"
51         exit $?
52     fi
53 fi
54
55 if [ x$1 = xstop ]; then
56     killall lighttpd
57 fi