TestUtility-ResetToBaseline.sh #1

  • //
  • guest/
  • tom_tyler/
  • sw/
  • main/
  • SSO_Cutover/
  • TestUtility-ResetToBaseline.sh
  • View
  • Commits
  • Open Download .zip Download (1 KB)
#!/bin/bash
set -u 

# To test, create the file /opt/perforce/helix-authentication-extension/bin/BASELINE.extension.p4s
# that contains baseline "opt-in" mode Extension configuration, with SSO users and groups defined.

echo "Load shell environment."
source /p4/common/bin/p4_vars 1

echo "Phase 1: Resetting configurables."
for c in auth.sso.allow.passwd auth.sso.nonldap; do
   p4 configure unset $c
done

p4 configure set auth.default.method=ldap

echo "Phase 2: Resetting Extensions to baseline."
p4 extension --configure Auth::loginhook --name loginhook-a1 -i < /opt/perforce/helix-authentication-extension/bin/BASELINE.extension.p4s

echo "Phase 3: Resetting triggers."
echo -e "Triggers:\n\tSetWsOpts form-out client \"/p4/common/bin/triggers/SetWsOptions.py %formfile%\"" > /tmp/trig.txt

p4 triggers -i < /tmp/trig.txt


echo "Phase 4: Reset user data."
for User in $(p4 -ztag -F %User% users); do
   if [[ -n "$(p4 groups "$User" | grep Automation)" ]]; then
      echo "Skipping auth method change for Automation user $User."
   else
      echo "Reset user $User back to LDAP."
      p4 --field AuthMethod=ldap user -o "$User" | p4 user -f -i
   fi
   UserPasswordSetKeyName0="SSO_Cutover.0.$User"
   UserPasswordSetKeyName1="SSO_Cutover.1.$User"
   p4 key -d "$UserPasswordSetKeyName0"
   p4 key -d "$UserPasswordSetKeyName1"
done

# Change User Description Committed
#1 32457 C. Thomas Tyler Added test utility.