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 (112 lines) | stat: -rw-r--r-- 2,014 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#! /bin/sh
#
# sqlrelay   This starts and stops SQL relay.
#
# chkconfig: 345 85 15
# description: Persistent database connection system.

# Source function library.
success() {
	echo success
}
failure() {
	echo failure
}
passed() {
	echo passed
}
if [ -r "/etc/init.d/functions" ]; then
	. /etc/init.d/functions
else
	if [ -r "/etc/rc.d/init.d/functions" ]; then
		. /etc/rc.d/init.d/functions
	fi
fi

# Get config.
test -f /etc/sysconfig/network && . /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "yes" ] || exit 0

prefix=@prefix@
sysconfdir=@sysconfdir@

[ -f ${sysconfdir}/sqlrelay.conf ] || exit 1

RETVAL=0

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

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

stop(){
    echo -n $"Stopping SQL Relay: "
    sqlr-stop >/dev/null 2>&1
    RETVAL=$?
    [ $RETVAL -eq 0 ] && success || failure
    echo
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sqlrelay
    return $RETVAL
}

restart(){
    stop
    start
}

condrestart(){
    [ -e /var/lock/subsys/sqlrelay ] && restart
    return 0
}


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

exit $RETVAL