~ubuntu-branches/ubuntu/wily/trafficserver/wily

« back to all changes in this revision

Viewing changes to rc/trafficserver.in

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2012-12-17 22:28:16 UTC
  • mfrom: (5.1.8 raring-proposed)
  • Revision ID: package-import@ubuntu.com-20121217222816-7xwjsx5k76zkb63d
Tags: 3.2.0-1ubuntu1
* Revert FreeBSD strerror_r() fixes that give errors with glibc 2.16.
* Apply patch from Konstantinos Margaritis to define barriers on ARM.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
UNAME_S=$(uname -s)
43
43
 
44
44
if [ -e /etc/SuSE-release ]; then
45
 
  DISTRIB_ID="suse"
 
45
    DISTRIB_ID="suse"
46
46
elif [ -e /etc/fedora-release ]; then
47
 
  DISTRIB_ID="fedora"
 
47
    DISTRIB_ID="fedora"
48
48
elif [ -e /etc/redhat-release ]; then
49
 
  DISTRIB_ID="redhat" # also exists on Fedora
 
49
    DISTRIB_ID="redhat" # also exists on Fedora
50
50
elif [ -e /etc/lsb-release ]; then
51
 
  DISTRIB_ID="ubuntu"
 
51
    DISTRIB_ID="ubuntu"
52
52
elif [ -e /etc/debian_version ]; then
53
 
  DISTRIB_ID="debian" # also exists on Ubuntu
 
53
    DISTRIB_ID="debian" # also exists on Ubuntu
54
54
elif [ -e /etc/slackware-version ]; then
55
 
  DISTRIB_ID="slackware"
 
55
    DISTRIB_ID="slackware"
56
56
elif [ "$UNAME_S" = "Darwin" ]; then
57
 
  DISTRIB_ID="Darwin"
 
57
    DISTRIB_ID="Darwin"
58
58
elif [ "$UNAME_S" = "FreeBSD" ]; then
59
 
  DISTRIB_ID="FreeBSD"
 
59
    DISTRIB_ID="FreeBSD"
60
60
fi
61
61
 
62
62
# We might want to move over to use /etc/system-release for more distros?
63
63
# I know at least Fedora supports it as well.
64
64
if [ "" = "$DISTRIB_ID" -a -e /etc/system-release ]; then
65
65
    case $(cat /etc/system-release) in
66
 
       *Amazon*)
67
 
           DISTRIB_ID="redhat" # Amazon AMI is mostly like RHEL
68
 
           ;;
69
 
       *)
70
 
           ;;
 
66
        *Amazon*)
 
67
            DISTRIB_ID="redhat" # Amazon AMI is mostly like RHEL
 
68
            ;;
 
69
        *)
 
70
            ;;
71
71
    esac
72
72
fi
73
73
 
84
84
PATH=/usr/sbin:/usr/bin:/sbin:/bin
85
85
DESC="start/stop Traffic Server"
86
86
NAME=trafficserver
 
87
SLEEP_TIME=5
87
88
TS_PREFIX="@prefix@"
88
89
 
89
90
TS_ROOT=${TS_ROOT:-$TS_PREFIX}
94
95
TC_NAME=${TC_NAME:-traffic_cop}
95
96
TM_NAME=${TM_NAME:-traffic_manager}
96
97
TS_NAME=${TS_NAME:-traffic_server}
 
98
TL_NAME=${TL_NAME:-traffic_line}
97
99
TC_DAEMON=${TC_DAEMON:-$TS_BASE@exp_bindir@/traffic_cop}
98
100
TC_DAEMON_ARGS=""
99
101
TM_DAEMON=${TM_DAEMON:-$TS_BASE@exp_bindir@/traffic_manager}
111
113
STDERRLOG=${STDERRLOG:-$TS_BASE@exp_logdir@/traffic_server.stderr}
112
114
 
113
115
if [ -d /etc/rc.d/init.d ]; then
114
 
  SCRIPTNAME=/etc/rc.d/init.d/$NAME # Fedora
 
116
    SCRIPTNAME=/etc/rc.d/init.d/$NAME # Fedora
115
117
elif [ -d /etc/init.d ]; then
116
 
  SCRIPTNAME=/etc/init.d/$NAME # Ubuntu
 
118
    SCRIPTNAME=/etc/init.d/$NAME # Ubuntu
117
119
elif [ "$DISTRIB_ID" = "Darwin" ]; then
118
 
  SCRIPTNAME=$0 # Darwin
 
120
    SCRIPTNAME=$0 # Darwin
119
121
elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
120
 
  SCRIPTNAME=$0 # FreeBSD 
 
122
    SCRIPTNAME=$0 # FreeBSD 
121
123
else
122
 
  echo "This script needs to be ported to this OS"
123
 
  exit 1
 
124
    echo "This script needs to be ported to this OS"
 
125
    exit 1
124
126
fi
125
127
 
126
 
 
127
128
# Exit if the package can not be found
128
129
if [ ! -x "$TS_DAEMON" ]; then
129
 
  echo "Error: Can not find $TS_DAEMON using TS_ROOT=$TS_ROOT"
130
 
  echo "       Please set TS_ROOT to point to base installation."
131
 
  exit 0
 
130
    echo "Error: Can not find $TS_DAEMON using TS_ROOT=$TS_ROOT"
 
131
    echo "       Please set TS_ROOT to point to base installation."
 
132
    exit 0
132
133
fi
133
134
 
134
135
# Ubuntu: Read configuration variable file if it is present
152
153
# with native OS rc.subr(8) features.
153
154
test -f /etc/rc.subr && . /etc/rc.subr
154
155
 
 
156
if [ ! -d @exp_runtimedir@ ]
 
157
then
 
158
        mkdir -p @exp_runtimedir@
 
159
        chown @pkgsysuser@:@pkgsysgroup@ @exp_runtimedir@
 
160
fi
155
161
 
156
162
#
157
163
# Fedora:
162
168
#  because 'daemon' expects $1 to fork itself
163
169
forkdaemon()
164
170
{
165
 
  local i=0
166
 
 
167
 
  # launch in background, i.e. fork
168
 
  # and redirect stdout and stderr to files
169
 
  $* >> $STDOUTLOG 2>> $STDERRLOG &
170
 
 
171
 
  while (( $i < $PIDFILE_CHECK_RETRIES ))
172
 
  do
173
 
 
174
 
    # check for regular file and size greater than 0
175
 
    if [[ -f $TC_PIDFILE ]] && [[ -s $TC_PIDFILE ]]
176
 
    then
177
 
      success
178
 
      return 0
179
 
    fi
180
 
 
181
 
    sleep 1  # zzz for 1 second
182
 
    (( i++ ))
183
 
 
184
 
  done
185
 
 
186
 
  failure
187
 
  return 1
 
171
    local i=0
 
172
 
 
173
    # launch in background, i.e. fork
 
174
    # and redirect stdout and stderr to files
 
175
    $* >> $STDOUTLOG 2>> $STDERRLOG &
 
176
 
 
177
    while (( $i < $PIDFILE_CHECK_RETRIES ))
 
178
    do
 
179
        # check for regular file and size greater than 0
 
180
        if [[ -f $TC_PIDFILE ]] && [[ -s $TC_PIDFILE ]]
 
181
        then
 
182
            success
 
183
            return 0
 
184
        fi
 
185
 
 
186
        sleep 1  # zzz for 1 second
 
187
        (( i++ ))
 
188
 
 
189
    done
 
190
 
 
191
    failure
 
192
    return 1
188
193
}
189
194
 
190
195
 
197
202
  #   0 if daemon has been started
198
203
  #   1 if daemon was already running
199
204
  #   2 if daemon could not be started
200
 
  start-stop-daemon --start --quiet --pidfile $TC_PIDFILE --exec $TC_DAEMON --test > /dev/null \
201
 
    || return 1
202
 
  start-stop-daemon --start --background --quiet --pidfile $TC_PIDFILE --exec $TC_DAEMON -- \
203
 
    $TC_DAEMON_ARGS \
204
 
    || return 2
 
205
    start-stop-daemon --start --quiet --pidfile $TC_PIDFILE --exec $TC_DAEMON --test > /dev/null \
 
206
        || return 1
 
207
    start-stop-daemon --start --background --quiet --pidfile $TC_PIDFILE --exec $TC_DAEMON -- \
 
208
        $TC_DAEMON_ARGS \
 
209
        || return 2
205
210
  # Add code here, if necessary, that waits for the process to be ready
206
211
  # to handle requests from services started subsequently which depend
207
212
  # on this one.  As a last resort, sleep for some time.
208
 
  sleep 1
209
 
  test -f "$TC_PIDFILE" || return 2
 
213
    sleep 1
 
214
    test -f "$TC_PIDFILE" || return 2
210
215
}
211
216
 
212
217
#
219
224
  #   1 if daemon was already stopped
220
225
  #   2 if daemon could not be stopped
221
226
  #   other if a failure occurred
222
 
  start-stop-daemon --stop --quiet --retry=QUIT/30/KILL/5 --pidfile $TC_PIDFILE --name $TC_NAME
223
 
  RETVAL="$?"
224
 
  test "$RETVAL" != 0 && return 2
 
227
    start-stop-daemon --stop --quiet --retry=QUIT/30/KILL/5 --pidfile $TC_PIDFILE --name $TC_NAME
 
228
    RETVAL="$?"
 
229
    test "$RETVAL" != 0 && return 2
225
230
  # Wait for children to finish too if this is a daemon that forks
226
231
  # and if the daemon is only ever run from this initscript.
227
232
  # If the above conditions are not satisfied then add some other code
228
233
  # that waits for the process to drop all resources that could be
229
234
  # needed by services started subsequently.  A last resort is to
230
235
  # sleep for some time.
231
 
  start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $TC_DAEMON
232
 
  test "$?" != 0 && return 2
 
236
    start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $TC_DAEMON
 
237
    test "$?" != 0 && return 2
233
238
        # Need to stop the TM and TS also
234
 
  start-stop-daemon --stop --quiet --retry=QUIT/30/KILL/5 --pidfile $TM_PIDFILE --name $TM_NAME
235
 
  test "$?" != 0 && return 2
236
 
  start-stop-daemon --stop --quiet --retry=QUIT/30/KILL/5 --pidfile $TS_PIDFILE --name $TS_NAME
237
 
  test "$?" != 0 && return 2
 
239
    start-stop-daemon --stop --quiet --retry=QUIT/30/KILL/5 --pidfile $TM_PIDFILE --name $TM_NAME
 
240
    test "$?" != 0 && return 2
 
241
    start-stop-daemon --stop --quiet --retry=QUIT/30/KILL/5 --pidfile $TS_PIDFILE --name $TS_NAME
 
242
    test "$?" != 0 && return 2
238
243
  # Many daemons don't delete their pidfiles when they exit.
239
 
  rm -f $TC_PIDFILE
240
 
  rm -f $TM_PIDFILE
241
 
  rm -f $TS_PIDFILE
242
 
  return "$RETVAL"
243
 
}
244
 
 
245
 
#
246
 
# Ubuntu: Function that sends a SIGHUP to the daemon/service
247
 
#
248
 
do_reload()
249
 
{
250
 
  #
251
 
  # If the daemon can reload its configuration without
252
 
  # restarting (for example, when it is sent a SIGHUP),
253
 
  # then implement that here.
254
 
  #
255
 
  start-stop-daemon --stop --signal 1 --quiet --pidfile $TS_PIDFILE --name $TS_NAME
256
 
  return 0
257
 
}
258
 
 
259
 
 
 
244
    rm -f $TC_PIDFILE
 
245
    rm -f $TM_PIDFILE
 
246
    rm -f $TS_PIDFILE
 
247
    return "$RETVAL"
 
248
}
260
249
 
261
250
# main
262
251
case "$1" in
263
 
  start)
264
 
    if [ "$DISTRIB_ID" = "ubuntu" -o "$DISTRIB_ID" = "debian" ] ; then
265
 
      test "x$VERBOSE" != "xno" && log_daemon_msg "Starting $DESC" "$NAME"
266
 
      retval=0
267
 
      do_start
268
 
      test "$?" -ne 0 -a "$?" -ne 1 && retval=1
269
 
      test "x$VERBOSE" != "xno" && log_daemon_msg "$retval"
270
 
      exit "$retval"
271
 
    elif [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
272
 
      action "Starting ${TS_PACKAGE_NAME}:" forkdaemon $TC_DAEMON $TC_DAEMON_ARGS
273
 
    elif [ "$DISTRIB_ID" = "suse" ]; then
274
 
      echo -n "Starting ${TS_PACKAGE_NAME}"
275
 
      startproc -p $TC_PIDFILE $TC_DAEMON $TC_DAEMON_ARGS
276
 
      rc_status -v
277
 
    elif [ "$DISTRIB_ID" = "Darwin" ]; then
278
 
      echo "Starting ${TS_PACKAGE_NAME}"
279
 
      launchctl list $TC_NAME > /dev/null 2>&1 && exit 0
280
 
      launchctl submit -l $TC_NAME -p $TC_DAEMON -o $STDOUTLOG -e $STDERRLOG -- $TC_DAEMON_ARGS
281
 
    elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
282
 
      echo "Starting ${TS_PACKAGE_NAME}"
283
 
      name="$TC_NAME"
284
 
      command="/usr/sbin/daemon"
285
 
      command_args="$TC_DAEMON $TC_DAEMON_ARGS"
286
 
      pidfile="$TC_PIDFILE"
287
 
      run_rc_command "$1"
288
 
    else
289
 
        echo "This script needs to be ported to this OS"
290
 
        exit 1
291
 
    fi
292
 
  ;;
293
 
  stop)
294
 
    if [ "$DISTRIB_ID" = "ubuntu" -o "$DISTRIB_ID" = "debian" ] ; then
295
 
      test "x$VERBOSE" != "xno" && log_daemon_msg "Stopping $DESC" "$NAME"
296
 
      retval=0
297
 
      do_stop
298
 
      test "$?" -ne 0 -a "$?" -ne 1 && retval=1
299
 
      test "x$VERBOSE" != "xno" && log_daemon_msg "$retval"
300
 
      exit "$retval"
301
 
    elif [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
302
 
      action "Stopping ${TC_NAME}:" killproc -p $TC_PIDFILE $TC_DAEMON
303
 
      action "Stopping ${TM_NAME}:" killproc -p $TM_PIDFILE $TM_DAEMON
304
 
      action "Stopping ${TS_NAME}:" killproc -p $TS_PIDFILE $TS_DAEMON
305
 
    elif [ "$DISTRIB_ID" = "suse" ]; then
306
 
      echo -n "Stopping ${TC_NAME}"
307
 
      killproc -p $TC_PIDFILE $TC_DAEMON
308
 
      rc_status -v
309
 
      echo -n "Stopping ${TM_NAME}"
310
 
      killproc -p $TM_PIDFILE $TM_DAEMON
311
 
      rc_status -v
312
 
      echo -n "Stopping ${TS_NAME}"
313
 
      killproc -p $TS_PIDFILE $TS_DAEMON
314
 
      rc_status -v
315
 
    elif [ "$DISTRIB_ID" = "Darwin" ]; then
316
 
      echo "Stopping ${TS_PACKAGE_NAME}"
317
 
      launchctl list $TC_NAME > /dev/null 2>&1 || exit 0
318
 
      echo "Stopping ${TC_NAME}"
319
 
      launchctl remove ${TC_NAME}
320
 
      rm -f ${TC_PIDFILE}
321
 
      echo "Stopping ${TM_NAME}"
322
 
      kill $(cat $TM_PIDFILE)
323
 
      rm -f ${TM_PIDFILE}
324
 
      echo "Stopping ${TS_NAME}"
325
 
      kill $(cat $TS_PIDFILE)
326
 
      rm -f ${TS_PIDFILE}
327
 
    elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
328
 
      echo "Stopping ${TS_PACKAGE_NAME}"
329
 
      if [ -e "$TC_PIDFILE" ]; then 
330
 
          kill $(cat $TC_PIDFILE)
331
 
          rm -f ${TC_PIDFILE}
332
 
      fi
333
 
      if [ -e "$TM_PIDFILE" ]; then 
334
 
          kill $(cat $TM_PIDFILE)
335
 
          rm -f ${TM_PIDFILE}
336
 
      fi
337
 
    else
338
 
      echo "This script needs to be ported to this OS"
339
 
      exit 1
340
 
    fi
341
 
  ;;
342
 
  #reload|force-reload)
343
 
  #
344
 
  # If do_reload() is not implemented then leave this commented out
345
 
  # and leave 'force-reload' as an alias for 'restart'.
346
 
  #
347
 
  #log_daemon_msg "Reloading $DESC" "$NAME"
348
 
  #do_reload
349
 
  #log_end_msg $?
350
 
  #;;
351
 
  restart|force-reload)
352
 
    if [ "$DISTRIB_ID" = "ubuntu" -o "$DISTRIB_ID" = "debian" ] ; then
 
252
    start)
 
253
        if [ "$DISTRIB_ID" = "ubuntu" -o "$DISTRIB_ID" = "debian" ] ; then
 
254
            test "x$VERBOSE" != "xno" && log_daemon_msg "Starting $DESC" "$NAME"
 
255
            retval=0
 
256
            do_start
 
257
            test "$?" -ne 0 -a "$?" -ne 1 && retval=1
 
258
            test "x$VERBOSE" != "xno" && log_daemon_msg "$retval"
 
259
            exit "$retval"
 
260
        elif [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
 
261
            action "Starting ${TS_PACKAGE_NAME}:" forkdaemon $TC_DAEMON $TC_DAEMON_ARGS
 
262
        elif [ "$DISTRIB_ID" = "suse" ]; then
 
263
            echo -n "Starting ${TS_PACKAGE_NAME}"
 
264
            startproc -p $TC_PIDFILE $TC_DAEMON $TC_DAEMON_ARGS
 
265
            rc_status -v
 
266
        elif [ "$DISTRIB_ID" = "Darwin" ]; then
 
267
            echo "Starting ${TS_PACKAGE_NAME}"
 
268
            launchctl list $TC_NAME > /dev/null 2>&1 && exit 0
 
269
            launchctl submit -l $TC_NAME -p $TC_DAEMON -o $STDOUTLOG -e $STDERRLOG -- $TC_DAEMON_ARGS
 
270
        elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
 
271
            echo "Starting ${TS_PACKAGE_NAME}"
 
272
            name="$TC_NAME"
 
273
            command="/usr/sbin/daemon"
 
274
            command_args="$TC_DAEMON $TC_DAEMON_ARGS"
 
275
            pidfile="$TC_PIDFILE"
 
276
            run_rc_command "$1"
 
277
        else
 
278
            echo "This script needs to be ported to this OS"
 
279
            exit 1
 
280
        fi
 
281
        ;;
 
282
    stop)
 
283
        if [ "$DISTRIB_ID" = "ubuntu" -o "$DISTRIB_ID" = "debian" ] ; then
 
284
            test "x$VERBOSE" != "xno" && log_daemon_msg "Stopping $DESC" "$NAME"
 
285
            retval=0
 
286
            do_stop
 
287
            test "$?" -ne 0 -a "$?" -ne 1 && retval=1
 
288
            test "x$VERBOSE" != "xno" && log_daemon_msg "$retval"
 
289
            exit "$retval"
 
290
        elif [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
 
291
            action "Stopping ${TC_NAME}:" killproc -p $TC_PIDFILE $TC_DAEMON
 
292
            action "Stopping ${TM_NAME}:" killproc -p $TM_PIDFILE $TM_DAEMON
 
293
            action "Stopping ${TS_NAME}:" killproc -p $TS_PIDFILE $TS_DAEMON
 
294
        elif [ "$DISTRIB_ID" = "suse" ]; then
 
295
            echo -n "Stopping ${TC_NAME}"
 
296
            killproc -p $TC_PIDFILE $TC_DAEMON
 
297
            rc_status -v
 
298
            echo -n "Stopping ${TM_NAME}"
 
299
            killproc -p $TM_PIDFILE $TM_DAEMON
 
300
            rc_status -v
 
301
            echo -n "Stopping ${TS_NAME}"
 
302
            killproc -p $TS_PIDFILE $TS_DAEMON
 
303
            rc_status -v
 
304
        elif [ "$DISTRIB_ID" = "Darwin" ]; then
 
305
            echo "Stopping ${TS_PACKAGE_NAME}"
 
306
            launchctl list $TC_NAME > /dev/null 2>&1 || exit 0
 
307
            echo "Stopping ${TC_NAME}"
 
308
            launchctl remove ${TC_NAME}
 
309
            rm -f ${TC_PIDFILE}
 
310
            echo "Stopping ${TM_NAME}"
 
311
            kill $(cat $TM_PIDFILE)
 
312
            rm -f ${TM_PIDFILE}
 
313
            echo "Stopping ${TS_NAME}"
 
314
            kill $(cat $TS_PIDFILE)
 
315
            rm -f ${TS_PIDFILE}
 
316
        elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
 
317
            echo "Stopping ${TS_PACKAGE_NAME}"
 
318
            if [ -e "$TC_PIDFILE" ]; then 
 
319
                kill $(cat $TC_PIDFILE)
 
320
                rm -f ${TC_PIDFILE}
 
321
            fi
 
322
            if [ -e "$TM_PIDFILE" ]; then 
 
323
                kill $(cat $TM_PIDFILE)
 
324
                rm -f ${TM_PIDFILE}
 
325
            fi
 
326
        else
 
327
            echo "This script needs to be ported to this OS"
 
328
            exit 1
 
329
        fi
 
330
        ;;
 
331
    reload|force-reload)
 
332
        if [ "$DISTRIB_ID" = "ubuntu" -o "$DISTRIB_ID" = "debian" ] ; then
 
333
            test "x$VERBOSE" != "xno" && log_daemon_msg "Reloading ${NAME}:"
 
334
            retval=0
 
335
            $TL_NAME -x
 
336
            test "$?" -ne 0 -a "$?" -ne 1 && retval=1
 
337
            test "x$VERBOSE" != "xno" && log_daemon_msg "$retval"
 
338
            exit "$retval"
 
339
        elif [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
 
340
            action "Reloading ${NAME}:" $TL_NAME -x
 
341
        elif [ "$DISTRIB_ID" = "suse" ]; then
 
342
            echo -n "Reloading ${NAME}"
 
343
            $TL_NAME -x
 
344
            rc_status -v
 
345
        elif [ "$DISTRIB_ID" = "Darwin" ]; then
 
346
            echo "Reloading ${NAME}"
 
347
            $TL_NAME -x
 
348
        elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
 
349
            echo "Reloading ${NAME}"
 
350
            $TL_NAME -x
 
351
        else
 
352
            echo "This script needs to be ported to this OS"
 
353
            exit 1
 
354
        fi
 
355
        ;;
 
356
    restart)
 
357
        if [ "$DISTRIB_ID" = "ubuntu" -o "$DISTRIB_ID" = "debian" ] ; then
353
358
      #
354
359
      # If the "reload" option is implemented then remove the
355
360
      # 'force-reload' alias
356
361
      #
357
 
      log_daemon_msg "Restarting $DESC" "$NAME"
358
 
      do_stop
359
 
      case "$?" in
360
 
          0|1)
361
 
            do_start
 
362
            log_daemon_msg "Restarting $DESC" "$NAME"
 
363
            do_stop
362
364
            case "$?" in
363
 
              0) log_end_msg 0 ;;
364
 
              1) log_end_msg 1 ;; # Old process is still running
365
 
              *) log_end_msg 1 ;; # Failed to start
 
365
                0|1)
 
366
                    sleep $SLEEP_TIME
 
367
                    do_start
 
368
                    case "$?" in
 
369
                        0) log_end_msg 0 ;;
 
370
                        1) log_end_msg 1 ;; # Old process is still running
 
371
                        *) log_end_msg 1 ;; # Failed to start
 
372
                    esac
 
373
                    ;;
 
374
                *)
 
375
            # Failed to stop
 
376
                    log_end_msg 1
 
377
                    ;;
366
378
            esac
367
 
          ;;
368
 
          *)
369
 
            # Failed to stop
370
 
            log_end_msg 1
371
 
          ;;
372
 
      esac
373
 
    else
 
379
        else
374
380
      # This is the typical process for restart
375
 
      sh $0 'stop'
376
 
      sh $0 'start'
377
 
    fi
378
 
  ;;
379
 
  status)
380
 
    if [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
381
 
      status -p $TC_PIDFILE $TC_NAME
382
 
    elif [  "$DISTRIB_ID" = "suse" ]; then
383
 
      echo -n "Checking for service ${DM}: "
384
 
      checkproc -p $TC_PIDFILE $TC_NAME
385
 
      rc_status -v
386
 
    elif [ "$DISTRIB_ID" = "Darwin" ]; then
387
 
      /bin/echo -n "${TS_PACKAGE_NAME} is "
388
 
      launchctl list $TC_NAME > /dev/null 2>&1
389
 
      status=$?
390
 
      [ $status -eq 0 ] || /bin/echo -n "not "
391
 
      echo "running."
392
 
    elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
393
 
        if pgrep $TM_NAME > /dev/null ; then 
394
 
                echo "$TM_NAME running as pid `cat $TM_PIDFILE`" ; else 
395
 
                echo "$TM_NAME not running" 
396
 
        fi
397
 
        if pgrep $TS_NAME > /dev/null ; then 
398
 
                echo "$TS_NAME running as pid `cat $TS_PIDFILE`"; else 
399
 
                echo "$TS_NAME not running" 
400
 
        fi
401
 
        if pgrep $TC_NAME > /dev/null ; then 
402
 
                echo "$TC_NAME running as pid `cat $TC_PIDFILE`"; else 
403
 
                echo "$TC_NAME not running" ; 
404
 
        fi
405
 
      exit $status
406
 
    else
407
 
      echo "This script needs to be ported to this OS"
408
 
      exit 1
409
 
    fi
410
 
  ;;
411
 
  condrestart)
412
 
    if [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
413
 
      if ! $0 'status'
414
 
      then
415
 
        sh $0 'stop'
416
 
        sh $0 'start'
417
 
      fi
418
 
    else
419
 
      echo "This script needs to be ported to this OS"
420
 
      exit 1
421
 
    fi
422
 
  ;;
423
 
  *)
424
 
    if [ "$DISTRIB_ID" = "ubuntu" -o "$DISTRIB_ID" = "debian" ] ; then
425
 
      echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
426
 
    elif [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
427
 
      echo "Usage: $0 {start|stop|status|restart|condrestart}"
428
 
    elif [ "$DISTRIB_ID" = "suse" ]; then
429
 
      echo "Usage: $0 {start|stop|restart|status}"
430
 
    elif [ "$DISTRIB_ID" = "Darwin" ]; then
431
 
      echo "Usage: $0 {start|stop|restart|status}"
432
 
   elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
433
 
      echo "Usage: $0 Usage: (start|stop|restart|status)"
434
 
      echo "NB: FreeBSD's ports system installs a rc script in"
435
 
      echo "/usr/local/etc/rc.d/ with native rc.subr(8) features."
436
 
   else
437
 
      echo "This script needs to be ported to this OS"
438
 
      exit 1
439
 
    fi
440
 
    exit 3
441
 
  ;;
 
381
            sh $0 'stop'
 
382
            sleep $SLEEP_TIME
 
383
            sh $0 'start'
 
384
        fi
 
385
        ;;
 
386
    status)
 
387
        if [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
 
388
            status -p $TC_PIDFILE $TC_NAME
 
389
        elif [  "$DISTRIB_ID" = "suse" ]; then
 
390
            echo -n "Checking for service ${DM}: "
 
391
            checkproc -p $TC_PIDFILE $TC_NAME
 
392
            rc_status -v
 
393
        elif [ "$DISTRIB_ID" = "Darwin" ]; then
 
394
            /bin/echo -n "${TS_PACKAGE_NAME} is "
 
395
            launchctl list $TC_NAME > /dev/null 2>&1
 
396
            status=$?
 
397
            [ $status -eq 0 ] || /bin/echo -n "not "
 
398
            echo "running."
 
399
        elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
 
400
            if pgrep $TM_NAME > /dev/null ; then 
 
401
                echo "$TM_NAME running as pid `cat $TM_PIDFILE`" ; else 
 
402
                echo "$TM_NAME not running" 
 
403
            fi
 
404
            if pgrep $TS_NAME > /dev/null ; then 
 
405
                echo "$TS_NAME running as pid `cat $TS_PIDFILE`"; else 
 
406
                echo "$TS_NAME not running" 
 
407
            fi
 
408
            if pgrep $TC_NAME > /dev/null ; then 
 
409
                echo "$TC_NAME running as pid `cat $TC_PIDFILE`"; else 
 
410
                echo "$TC_NAME not running" ; 
 
411
            fi
 
412
            exit $status
 
413
        else
 
414
            echo "This script needs to be ported to this OS"
 
415
            exit 1
 
416
        fi
 
417
        ;;
 
418
    condrestart)
 
419
        if [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
 
420
            if $0 'status'
 
421
            then
 
422
                sh $0 'stop'
 
423
                sh $0 'start'
 
424
            fi
 
425
        else
 
426
            echo "This script needs to be ported to this OS"
 
427
            exit 1
 
428
        fi
 
429
        ;;
 
430
    *)
 
431
        if [ "$DISTRIB_ID" = "ubuntu" -o "$DISTRIB_ID" = "debian" ] ; then
 
432
            echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
 
433
        elif [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
 
434
            echo "Usage: $0 {start|stop|status|restart|condrestart}"
 
435
        elif [ "$DISTRIB_ID" = "suse" ]; then
 
436
            echo "Usage: $0 {start|stop|restart|status}"
 
437
        elif [ "$DISTRIB_ID" = "Darwin" ]; then
 
438
            echo "Usage: $0 {start|stop|restart|status}"
 
439
        elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
 
440
            echo "Usage: $0 Usage: (start|stop|restart|status)"
 
441
            echo "NB: FreeBSD's ports system installs a rc script in"
 
442
            echo "/usr/local/etc/rc.d/ with native rc.subr(8) features."
 
443
        else
 
444
            echo "This script needs to be ported to this OS"
 
445
            exit 1
 
446
        fi
 
447
        exit 3
 
448
        ;;
442
449
esac
443