File: sqlrelay.in

package info (click to toggle)
sqlrelay 1%3A0.35-10
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 11,944 kB
  • ctags: 6,102
  • sloc: cpp: 41,419; python: 11,007; ansic: 10,279; java: 9,833; perl: 9,500; php: 9,229; ruby: 9,182; sh: 8,700; makefile: 3,474; tcl: 5
file content (85 lines) | stat: -rw-r--r-- 1,609 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#! /bin/sh
#
# sqlrelay   This starts and stops SQL relay.
#
# chkconfig: 345 85 15
# description: Persistent database connection system.

prefix=@prefix@
sysconfdir=@sysconfdir@

if ( test ! -r "${sysconfdir}/sqlrelay.conf" ); then
        exit 1
fi

RETVAL=0

# Add appropriate bin/lib paths
if ( test "${prefix}" != "/usr" ); then
        PATH=$PATH:${prefix}/bin
        LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${prefix}/lib
        export PATH LD_LIBRARY_PATH
fi

start(){
    echo -n $"Starting SQL Relay: "
    if ( test -r "/etc/sqlrelay" ); then
        launched=0
        for connid in `grep -v ^# /etc/sqlrelay`; do
            echo
            echo -n $"Launching instance with id '${connid}':"
            sqlr-start -id ${connid} >/dev/null 2>&1
            RETVAL=$?
            if ( test "$RETVAL" -eq "0" ); then
                echo "success"
            else
                echo "failure"
            fi
            launched=1
        done
        if ( test "$launched" -ne "1" ); then
            echo "passed"
        fi
        echo
    else
        echo "failure"
    fi
    return $RETVAL
}

stop(){
    echo -n $"Stopping SQL Relay: "
    sqlr-stop >/dev/null 2>&1
    RETVAL=$?
    if ( test "$RETVAL" -eq "0" ); then
        echo "success"
    else
        echo "failure"
    fi
    echo
    return $RETVAL
}

restart(){
    stop
    start
}


# See how we were called.
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        restart
        ;;
    *)
        echo "Usage: sqlrelay {start|stop|restart}"
        RETVAL=1
esac

exit $RETVAL