-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp4_changes.sh
executable file
·74 lines (55 loc) · 1.85 KB
/
p4_changes.sh
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
#!/bin/bash
p4_user=svcp4admin
p4_online_db=/srv/perforce
p4_offline_db=/srv/perforce_backups/offline_database
p4_online_db_port=1666
p4_offline_db_port=2666
p4_binary=`which p4`
# CHECK IF P4D ONLINE DB PORT IS LISTENING
echo "Checking p4d:$p4_online_db_port is listening"
netstat -plantu | grep p4d | grep $p4_online_db_port
ret_val=$?
if [[ $ret_val == 1 ]]; then
1>&2 echo "p4d NOT detected on port $p4_online_db_port"
exit 1
fi
# CHECK IF P4D OFFLINE DB PORT IS LISTENING
echo "Checking p4d:$p4_offline_db_port is listening"
netstat -plantu | grep p4d | grep $p4_offline_db_port
ret_val=$?
if [[ $ret_val == 1 ]]; then
1>&2 echo "p4d NOT detected on port $p4_offline_db_port"
exit 1
fi
# START ONLINEDB CHECKS
# EXPORT ONLINEDB PORT
export P4PORT=$p4_online_db_port
# VALIDATE P4_USER KNOWN TO PERFORCE ONLINEDB
echo "Checking for $p4_user in $p4_online_db"
$p4_binary users | grep $p4_user
ret_val=$?
if [[ $ret_val == 1 ]]; then
1>&2 echo "$p4_user not found in $p4_online_db"
exit 1
fi
# ONLINEDB FETCH CHANGELIST
online_db_changelist=$($p4_binary -p localhost:$p4_online_db_port -u $p4_user changes)
# EXPORT OFFLINEDB PORT
export P4PORT=$p4_offline_db_port
# VALIDATE P4_USER KNOWN TO PERFORCE ONLINEDB
echo "Checking for $p4_user in $p4_offline_db"
$p4_binary users | grep $p4_user
ret_val=$?
if [[ $ret_val == 1 ]]; then
1>&2 echo "$p4_user not found in $p4_offline_db"
exit 1
fi
# OFFLINEDB FETCH CHANGELIST
offline_db_changelist=$($p4_binary -p localhost:$p4_offline_db_port -u $p4_user changes)
# VALIDATE P4 CHANGELISTS ARE THE SAME BETWEEN ONLINE AND OFFLINE DB
if [[ $online_db_changelist == $offline_db_changelist ]]; then
echo "$p4_online_db and $p4_offline_db are the same"
else
1>&2 echo "$p4_online_db and $p4_offline_db are NOT the same"
exit 1
fi