#!/bin/bash set -euo pipefail # Exit on any error export PORT=1666 export P4PORT=localhost:$PORT # Start P4D p4d -r /app/data -p $PORT & # The time needed for P4D to start listening on the TCP port varies greatly from 2 to +10 secs # Waiting for the port to be available instead is more reliable than an arbitrary sleep echo "Waiting for server to listen on port $PORT..." while ! nc -z localhost $PORT $CLIENT_ROOT/main.cpp && p4 add $CLIENT_ROOT/main.cpp echo "This is change main.h #1" > $CLIENT_ROOT/main.h && p4 add $CLIENT_ROOT/main.h echo "This is change common.h #1" > $CLIENT_ROOT/common.h && p4 add $CLIENT_ROOT/common.h echo "This is change unused.cpp #1" > $CLIENT_ROOT/unused.cpp && p4 add $CLIENT_ROOT/unused.cpp echo "This is change data.txt #1" > $CLIENT_ROOT/Data/data.txt && p4 add $CLIENT_ROOT/Data/data.txt p4 submit -d "Initial import" # Changelist #3 p4 edit main.cpp echo "This is change main.cpp #2" > $CLIENT_ROOT/main.cpp p4 submit -d "Improvement to main.cpp" # Changelist #4 p4 delete unused.cpp p4 submit -d "Delete an unused file" # Changelist #5 p4 edit common.h p4 move common.h shared.h p4 submit -d "Rename common.h to shared.h" # Changelist #6 p4 edit main.cpp p4 edit main.h echo "This is change main.cpp #3" > $CLIENT_ROOT/main.cpp echo "This is change main.h #2" > $CLIENT_ROOT/main.h p4 submit -d "Some updates to main" # Changelist #7 echo "This is change moredata.txt #1" > $CLIENT_ROOT/Data/moredata.txt && p4 add $CLIENT_ROOT/Data/moredata.txt p4 submit -d "Add more data" # Changelist #8 p4 change -i << EOF Change: new Description: A shelved CL EOF echo "This is change shelved.cpp #1" > $CLIENT_ROOT/shelved.cpp && p4 add -c 8 $CLIENT_ROOT/shelved.cpp p4 edit -c 8 main.h && echo "This is change main.h #3" > $CLIENT_ROOT/main.h p4 delete -c 8 main.cpp p4 shelve -c 8 # Stop server running in background kill "$(pidof p4d)"