Repository navigation
Expand file tree
/
Copy pathstartup-script
More file actions
138 lines (132 loc) · 3.74 KB
/
Copy pathstartup-script
File metadata and controls
138 lines (132 loc) · 3.74 KB
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
#!/bin/sh
#
# /etc/rc.d/init.d/p4dti -- startup script for the P4DTI replicator daemon
#
# $Id: //info.ravenbrook.com/project/p4dti/version/2.4/packaging/linux/startup-script#1 $
#
# This is the startup script for the replicator daemon which is part of
# the Perforce Defect Tracking Integration (P4DTI). It is normally
# installed in the /etc/rc.d/init.d directory on Linux machines so
# that the daemon is automatically started and stopped by the system,
# and can be managed by the system administrator.
#
# ---
#
# These fields are used by the "chkconfig(8)" utility and must appear in the
# first comment in this script.
#
# chkconfig: 345 95 10
# description: P4DTI replicates information between a Perforce repository \
# and a defect tracking system.
#
# ---
#
# This file is copyright (c) 2001 Perforce Software, Inc. All rights
# reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
# DAMAGE.
#
# The following definitions are detected by the RPM scripts and edited.
P4DTIDIR=/opt/p4dti
LOCKFILE=/var/lock/subsys/p4dti
PIDFILE=/var/run/p4dti.pid
# See how we were called.
case "$1" in
start)
if [ -d $P4DTIDIR ]
then
cd $P4DTIDIR
else
printf "p4dti directory (%s) does not exist\n" $P4DTIDIR
exit 1
fi
if [ -f $LOCKFILE ]
then
printf "p4dti subsystem is locked\n"
exit 1
fi
printf "Starting p4dti:\n"
if [ "$(id -u)" = "0" ]
then
su p4dti -c 'python run.py >/dev/null& echo $!' >$PIDFILE
else
python run.py >/dev/null&
echo $! >$PIDFILE
fi
touch $LOCKFILE
;;
stop)
# I believe that stop should succeed even if the process is
# not running or broken.
printf "Shutting down p4dti:\n"
if [ -f $PIDFILE ]
then
pp=$(cat $PIDFILE)
if [ -d /proc/$pp ]
then
kill -TERM $pp
else
printf "p4dti does not appear to be running\n"
fi
fi
echo
rm -f $LOCKFILE
rm -f $PIDFILE
;;
status)
if [ -f $PIDFILE ]
then
pp=$(cat $PIDFILE)
if [ -d /proc/$pp ]
then
printf "%s is running.\n" $pp
else
printf "p4dti is stopped (but pidfile is present).\n"
fi
else
printf "p4dti is stopped.\n"
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit 0
#
# A. REFERENCES
#
#
# B. DOCUMENT HISTORY
#
# 2000-12-21 FJMD Created.
# 2001-01-29 FJMD Finished editing.
# 2001-02-14 RB Prepared for check-in to master sources.
# 2001-03-02 RB Transferred copyright to Perforce under their license.
# 2001-03-20 NB Moved code from /opt/p4dti/bin to /opt/p4dti