-
Notifications
You must be signed in to change notification settings - Fork 0
/
p4proxy
76 lines (68 loc) · 1.27 KB
/
p4proxy
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
#!/bin/bash
#
# P4P (Perforce PROXY) start/stop script
#
# chkconfig: 345 20 80
# description: Perforce Proxy (p4p) start/stop script
#
# Koray Oksay - 20140203
# Source function library.
. /etc/init.d/functions
# Set parameters
P4P_PORT="proxyhost:1999"
P4P_REMOTE="remotehost:1666"
P4P_CACHEDIR="/perforce/cache"
P4P_BIN="/perforce/bin/p4p"
P4P_LOG="/perforce/log/p4p.log"
P4P_USER="perforce"
P4P_NAME="p4p"
start() {
echo -n "Starting $P4P_NAME: "
echo -n `date '+%Y%m%d-%H:%M:%S '` " " >> $P4P_LOG
su - $P4P_USER -c "$P4P_BIN -d -p $P4P_PORT -t $P4P_REMOTE -r $P4P_CACHEDIR" >> $P4P_LOG 2>> $P4P_LOG
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
success
echo
return 0
else
failure
echo
return 1
fi
}
stop() {
echo -n $"Stopping $P4P_NAME: "
echo -n `date '+%Y%m%d-%H:%M:%S '` " " >> $P4P_LOG
pidlist=`pidof $P4P_NAME`
kill $pidlist >/dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
success
echo
else
failure
echo
echo "Perforce Proxy failed to stop...">> $P4P_LOG
fi
}
# main
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $P4P_NAME
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac