updated on Sat Jan 14 12:12:45 UTC 2012
[aur-mirror.git] / sedna / sedna.rc
blob085fd16b2394cc7a2f510cbdc5ab34117644ace9
1 #!/bin/bash
3 if [ "$(id -u)" != 0 ] ; then
4 echo "You must be root to start Sedna DB as daemon."
5 exit 2
6 fi
8 # general config
9 USECOLOR="YES"
10 . /etc/rc.d/functions
11 . /etc/conf.d/sednad
12 pid="pidof se_gov"
13 dsc="Sedna XML Database Server"
14 dsc1="Sedna DB"
15 log="/var/log/sedna.log"
17 if [ -z $user ] ; then
18 echo "Unable to run $dsc. You must set a user in /etc/conf.d/sednad"
19 exit 2
22 # [ -f $log ] && rm -f $log
24 case "$1" in
25 start)
26 stat_busy "Starting $dsc"
27 if [ `$pid` ]; then
28 stat_fail
29 printf "${C_FAIL}$dsc already running.${C_OTHER} \n"
30 exit 2
31 else
32 #chown -R $user /opt/sedna/data /opt/sedna/cfg - перенес в install скрипт
33 su $user -s /bin/sh -c "/opt/sedna/bin/se_gov &> $log "
34 if [ ! -z "$(grep 'ERROR' $log)" ] ; then
35 stat_fail
36 printf "${C_FAIL}`cat $log`${C_OTHER} \n"
37 exit 2
38 else
39 add_daemon sednad
40 stat_done
41 # start databases
42 if [ ! -z $databases ] ; then
43 for db in ${databases[@]}; do
44 stat_busy "Starting $dsc1 '$db'"
45 su $user -s /bin/sh -c "/opt/sedna/bin/se_sm $db &> $log "
46 if [ ! -z "$(grep 'ERROR' $log)" ] ; then
47 stat_fail
48 printf "${C_FAIL}`cat $log`${C_OTHER} \n"
49 else
50 stat_done
51 #cat $log
53 done
55 exit 0
59 stop)
60 # stop databases
61 if [ ! -z $databases ] ; then
62 for db in ${databases[@]}; do
63 stat_busy "Stopping $dsc1 '$db'"
64 su $user -s /bin/sh -c "/opt/sedna/bin/se_smsd $db &> $log "
65 if [ ! -z "$(grep 'ERROR' $log)" ] ; then
66 stat_fail
67 printf "${C_FAIL}`cat $log`${C_OTHER} \n"
68 else
69 stat_done
71 done
73 stat_busy "Stopping $dsc"
74 su $user -s /bin/sh -c "/opt/sedna/bin/se_stop &> $log "
75 if [ ! -z "$(grep 'ERROR' $log)" ]; then
76 stat_fail
77 printf "${C_FAIL}`cat $log`${C_OTHER} \n"
78 exit 2
79 else
80 rm_daemon sednad
81 stat_done
82 exit 0
85 restart)
86 $0 stop
87 sleep 3
88 $0 start
91 echo "usage: $0 {start|stop|restart}"
92 esac