File: sogo-init.d-redhat

package info (click to toggle)
sogo 1.3.16-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 21,620 kB
  • sloc: objc: 99,218; python: 4,840; sh: 1,217; perl: 861; makefile: 132; sql: 53; php: 43; ansic: 4
file content (164 lines) | stat: -rwxr-xr-x 3,445 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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/bin/bash
# chkconfig:	2345 85 15
# description:	SOGo is a groupware server
# processname:  sogod
# config:	/etc/sysconfig/sogo
# config:	/etc/httpd/conf.d/SOGo.conf
# pidfile:	/var/run/sogo/sogod.pid

# SOGo init script for RedHat
#
# Copyright (C) 2007-2009 Inverse inc.
#
# Authors: Wolfgang Sourdeau <wsourdeau@inverse.ca>
#          Francis Lachapelle <flachapelle@inverse.ca>
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING.  If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
PATH=/sbin:/bin:/usr/sbin:/usr/bin

NAME=sogo
DAEMON=/usr/sbin/sogod
DESC="SOGo"

USER=$NAME
PREFORK=1

PIDFILE=/var/run/$NAME/$NAME.pid
LOGFILE=/var/log/$NAME/$NAME.log

if [ -f /etc/sysconfig/$NAME ]; then
    . /etc/sysconfig/$NAME
fi

if [ ! -x $DAEMON ]; then
 echo "$DAEMON is not executable."
 exit 1
fi

checkDir() {
    directory="$1"
    if [ ! -d "$directory" ]
    then
	echo "$directory does not exist."
	exit 1
    fi

    if [ `/usr/bin/stat "$directory" -c %U` != "$USER" ]
    then
	echo "$directory is not owned by the '$USER' user."
	exit 1
    fi
}

checkDir /var/run/$NAME
checkDir /var/spool/$NAME
checkDir /var/log/$NAME

. /etc/rc.d/init.d/functions
if [ -z "$GNUSTEP_SYSTEM_ROOT" ]
then
  . /etc/GNUstep/GNUstep.conf
  . ${GNUSTEP_MAKEFILES}/GNUstep.sh
fi

DAEMON_OPTS="-WOWorkersCount $PREFORK -WOPidFile $PIDFILE -WOLogFile $LOGFILE"

RETVAL=0

start() {
    echo $"Starting $DESC: "
    pid="`cat $PIDFILE 2> /dev/null`"
    if [ -n "$pid" ]
    then
        pid="`ps --pid ${pid} -o pid=`"
	if [ -n "$pid" ]
	then
	    echo "  $NAME already running. Skipped."
	    RETVAL=0
	else
	    rm -f $PIDFILE
	    daemon --user="$USER" --pidfile="$PIDFILE" "$DAEMON" $DAEMON_OPTS
	    RETVAL=$?
	    echo "  $NAME (stale pid file removed)"
	fi
    else
	daemon --user="$USER" --pidfile="$PIDFILE" "$DAEMON" $DAEMON_OPTS
	RETVAL=$?
        echo "  $NAME"
    fi
    return $RETVAL
}

stop() {
    echo $"Stopping $DESC: "
    pid="`cat $PIDFILE 2> /dev/null`"
    if [ -n "$pid" ]
    then
        pid="`ps --pid ${pid} -o pid=`"
	if [ -n "$pid" ]
	then
	    kill $pid >& /dev/null
	    RETVAL=$?
	    echo "  $NAME stopped"
	else
	    echo "  $NAME not running"
	    RETVAL=0
	fi
    else
	echo "  $NAME not running"
	RETVAL=0
    fi
    return $RETVAL
}

restart() {
    echo $"Restarting $DESC: "
    pid="`cat $PIDFILE 2> /dev/null`"
    if [ -n "$pid" ]
    then
	kill $pid >& /dev/null
    fi
    sleep 1
    daemon --user="$USER" --pidfile="$PIDFILE" "$DAEMON" $DAEMON_OPTS
    echo "  $NAME"
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart)
	restart
	;;
  condrestart|try-restart)
	if status -p "$PIDFILE" $DAEMON >&/dev/null; then
	  restart
	fi
	;;
  status)
  	status -p "$PIDFILE" $DAEMON
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|condrestart|status}" >&2
	exit 1
	;;
esac

exit $?