File: sqlrelay.init

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 (81 lines) | stat: -rw-r--r-- 1,629 bytes parent folder | download | duplicates (2)
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
#!/bin/sh
#
# init file for sqlrelay
#
# Written by Andreas Tille <tille@debian.org>.
# Changed by Florian M. Weps <fweps@greenmail.ch>.

SQLRSTART=/usr/bin/sqlr-start
RUNASUSER=sqlrelay
CONFFILE=/etc/sqlrelay/sqlrelay.conf
INSTFILE=/etc/sqlrelay/instances

if [ ! -f $INSTFILE ]
then
  echo "$INSTFILE missing"
  echo "Please read /usr/share/doc/sqlrelay/README.Debian."
  exit 0
fi
if [ `grep -cv '^#' $INSTFILE` -eq 0 ]
then
  echo "$INSTFILE empty."
  echo "Please read /usr/share/doc/sqlrelay/README.Debian."
  exit 0
fi

test -x $SQLRSTART || exit 0

if [ ! -O $CONFFILE ] ; then
   echo $CONFFILE is not owned by root.
   exit 0
fi
#if [ `ls -l $CONFFILE | sed "s/-..\(.*\)  *1 .*$/---\1/"` != ---------- ] ; then
#   echo $CONFFILE has insufficient rights.
#   exit 0
#fi

#
# dirty fix
#

chown -R sqlrelay:sqlrelay /var/cache/sqlrelay

case "$1" in
  start)
    echo -n "Starting SQL Relay ... "
    grep -v '^#' $INSTFILE | while read i j
    do
      if [ ! -z $i ]; then
        if [ -z $j ]; then j=$CONFFILE; fi
        if ( xmllint -noout --valid $j ); then
	  OLDUMASK=`umask`
	  umask 002
          su $RUNASUSER -c "/usr/bin/sqlr-start -id $i -config $j"
	  umask $OLDUMASK
        else
          echo -n "SQL Relay not started"
        fi
      fi
    done 
    echo "."
    ;;
  stop)
    echo -n "Stopping SQL Relay ..."
    /usr/bin/sqlr-stop
    /usr/bin/sqlr-ipclean
    echo "."
    ;;
  reload)
    echo "Not implemented."
    ;;
  force-reload|restart)
    $0 stop
    $0 start
    ;;
  *)
    echo "Usage: /etc/init.d/sqlrelay {start|stop|restart|force-reload|reload}"
    exit 1
    ;;
esac

exit 0