#!/bin/bash
if [ "$#" -lt 4 ]; then
echo "Incorrect number of parameters."
echo "Usage:"
echo "$0 SDP_INSTANCE REPLICA_NAME SVCUSER_PASSWORD MASTERPORT <mandatory>"
exit 1
fi
export SDP_INSTANCE=$1
export REPNAME=$2
export PASSWORD=$3
export REPPORT=$4
export MANDATORY=${5:-nomandatory}
REPMASTER=$(echo $REPNAME | sed "s/-standby.*//")
. /p4/common/bin/p4_vars $SDP_INSTANCE
if [[ $MANDATORY == mandatory ]]; then
$P4BIN server -o $REPNAME | sed "s/^Services:\tstandard/Services:\tforwarding-standby/" | sed "s/nomandatory/mandatory/" | sed "$ a ReplicatingFrom: ${REPMASTER}" | $P4BIN server -i
else
$P4BIN server -o $REPNAME | sed "s/^Services:\tstandard/Services:\tforwarding-standby/" | sed "$ a ReplicatingFrom: ${REPMASTER}" | $P4BIN server -i
fi
$P4BIN configure set "${REPNAME}#P4TARGET=${REPPORT}"
$P4BIN configure set "${REPNAME}#serviceUser=svc_${REPNAME}"
$P4BIN configure set "${REPNAME}#journalPrefix=/p4/${SDP_INSTANCE}/journals.rep/p4_${SDP_INSTANCE}"
$P4BIN configure set "${REPNAME}#serverlog.file.1=/p4/${SDP_INSTANCE}/logs/audit.csv"
$P4BIN configure set "${REPNAME}#db.replication=readonly"
$P4BIN configure set "${REPNAME}#lbr.replication=shared"
$P4BIN configure set "${REPNAME}#startup.1=journalcopy -i 0"
$P4BIN configure set "${REPNAME}#startup.2=pull -L -i 0"
if ! ($P4BIN user -o svc_${REPNAME} | grep "^Type:.*service" > /dev/null); then
$P4BIN user -o svc_${REPNAME} | sed -e "s/^User:/Type: service\nUser:/g" -e "s/ldap/perforce/g" | $P4BIN user -f -i
echo ${PASSWORD} > passwd.txt
echo ${PASSWORD} >> passwd.txt
$P4BIN passwd svc_${REPNAME} < passwd.txt
rm passwd.txt
fi
$P4BIN group -o p4-replicas|sed -e "s/^Users:/Users:\n\tsvc_${REPNAME}/g" -e "s/43200/unlimited/g" -e "s/unset/unlimited/g" | $P4BIN group -i
#$P4BIN group -o service.g|sed -e "s/^Users:/Users:\n\tsvc_${REPNAME}/g" -e "s/43200/unlimited/g" -e "s/unset/unlimited/g" | $P4BIN group -i
#if ! ($P4BIN protect -o|grep "super group service.g" > /dev/null); then
# $P4BIN protect -o| sed -e '$a\\tsuper group service.g * //...'| $P4BIN protect -i
#fi
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #7 | 32865 | Russell C. Jackson (Rusty) |
SDP review fixes: replication topology & failover mkstandby.sh: fix unterminated sed (default standby never converted) + ReplicationFrom typo + mktemp for service-user password. mkstandby_shared.sh: derive ReplicatingFrom from P4MASTER_ID not P4MASTERPORT. convert_standby_to_master.sh: validate recovery journal before deleting the live journal. No errexit added. |
||
| #6 | 32426 | Russell C. Jackson (Rusty) | Claude ai updates. | ||
| #5 | 32388 | Russell C. Jackson (Rusty) | Updates using Claude.ai to clean up the code, reduce duplication, enhanace security, and use current standards. | ||
| #4 | 31865 | Russell C. Jackson (Rusty) | Removed journals.rep setting | ||
| #3 | 31271 | Russell C. Jackson (Rusty) | Updates to use service.g | ||
| #2 | 28941 | Russell C. Jackson (Rusty) | Fixed the REPNAME substitution | ||
| #1 | 28920 | Russell C. Jackson (Rusty) | Modify to work out of the box in current setup. |