USAGE for sdp_sync.sh v2.4.0:
sdp_sync.sh [-H <host1>[,<host2>,...]] [-i <instance>] [-a] [-s] [-m] [-c] [-r] [-e|-E] [-L <log>] [-si] [-v<n>] [-n|-N] [-D]
or
sdp_sync.sh [-h|-man|-V]
DESCRIPTION:
This is the "Tight Ship" compliance check script, a part of the
Helix Management System (HMS).
This script keeps the Perforce Helix Server Deployment Package (SDP)
scripts in sync on all SDP hosts, as defined by the SDP_SYNC_HOSTS
setting in the host config file (see FILES bellow). It does this
by doing a 'p4 sync' command to deploy updates, and optionally
doing a 'p4 status' command in key directories to ensure the files
on the machine match version control precisely.
The 'p4 sync' is done targeting a Helix Management System server.
Typically a dedicated 'p4hms.YourCompany.com' virtual machine is
setup as a Linux bastion host, and a dedicated 'hms' instance of SDP
on that machine is used to manage the SDP on all other machines. In
some cases, the hms_ts_setup.sh script is used to initialize the
HMS server instance automatically.
In other cases, an //sdp depot is added to an existing SDP instance
used used for other purposes. This can be done when there is a desire
to maintian a single P4D instance for an entire organization.
If used with the '-c' flag, this script also verifies that versioned
cron files match actual crontab files on each managed host.
This script is intended to be called by a cron job the master server.
It does ssh calls to HMS-managed SDP hosts.
Each target host is expect to have a P4CONFIG file named
/p4/.p4config.SDP that defines Perforce environment settings that
point to Perforce workspaces that enable versioning of the SDP on that
host.
An SDP worskpace must be configured for each host. Typically they
reference paths in the Perforce server that are common across
all SDP servers, e.g. to populate the /p4/common folder.
Other paths are host-specific, like the /p4/N/bin folders
that indicate which instances are active on the machine as well
as which type of servers are active for each instance (p4d,
p4p, p4broker, etc.).
SSH keys must be setup such that the Perforce login (as defined by
OSUSER in /Users/ttyler/pub/sdp/dev/Server/Unix/p4/common/bin/p4_vars) can ssh without a password to all SDP hosts.
To simplify failover, the backup servers should also be able to
ssh to each other without a password; security implications should
be considered here.
TIGHT SHIP COMPLIANCE
This ship considers an environment to be "Tight Ship" compliant
if:
* A 'p4 opened' in the SDP workpsace on all hosts reports files
checked out anywhere.
* A 'p4 sync' in the SDP workspace on all hosts reports no errors.
* A 'p4 status' on key directories in the SDP workspace on all hosts
reports no errors.
* Crontabs on all hosts match the versioned files.
If all these conditions are met, the output will contain the message:
Verified: Tight Ship compliant.
This message can only appear if the '-s' and '-c' flags are used
or implied, indicating all possible checks are done. The '-m flag
implies '-s' and '-a' implies both '-s' and '-c'.
OPTIONS:
-a Specifying '-a' is a shorthand, the equivalent of specifying
'-s -c -r -E'.
-H <host1>[,<host2>,...]
Specify a comma-delimited list of hosts to push to. By default,
the SDP_SYNC_HOSTS value defined in the config file
determines the list of hosts to push to.
-i <instance>
Specify the SDP instance tag. The default is to use the
$SDP_INSTANCE variable if defined. This will be set if the
standard SDP mechanism for setting shell environment variables
is used, e.g. by souring p4_vars with the instance tag name, e.g.:
source /Users/ttyler/pub/sdp/dev/Server/Unix/p4/common/bin/p4_vars 1
If $SDP_INSTANCE is not defined in the shell environment, specifying
'-i <instance>' is required.
-s Specify that a 'p4 status' check should be done in directories
specified by the SDP_STATUS_DIRS variable defined in .
Alternately, a host-specific value for SDP_STATUS_DIRS may be
defined in a file named sdp_status_dirs.<hostname>.cfg in
the /p4/common/config dir.
-m Use with '-s' to specify that the '-m' flag to 'p4 status' should
be used for a faster check (without MD5 digest comparison). If
'-m' is specified without '-s', the '-s' is implied.
-c Specifies that the crontab for the OSUSER () on each machine
should be compared against the the versioned cron file in:
/p4/common/etc/cron.d
In that directory, the cron files are named crontab.<user>.<hostname>
The cron check is done for all hosts defined in the ALL_SDP_HOSTS
setting in .
-r
Specify this option to remove old sdp_sync.*.log files. If this option
is specified, log files named /p4/<n>/logs/sdp_sync.*.log (where '<n>'
is the SDP instance name) that are older than the number of journal
rotations indicated by the KEEPLOGS setting in /Users/ttyler/pub/sdp/dev/Server/Unix/p4/common/bin/p4_vars are removed.
The old log removal occurs only upon successful completion.
-e Send email to MAILTO value defined in /Users/ttyler/pub/sdp/dev/Server/Unix/p4/common/bin/p4_vars in event
of failure only.
-E Send email to MAILTO value defined in /Users/ttyler/pub/sdp/dev/Server/Unix/p4/common/bin/p4_vars.
-v<n> Set verbosity 1-5 (-v1 = quiet, -v5 = highest).
-L <log>
Specify the path to a log file, or the special value 'off' to disable
logging. By default, all output (stdout and stderr) goes to a log
file named sdp_sync.<datestame>.log in .
NOTE: This script is self-logging. That is, output displayed on the screen
is simultaneously captured in the log file. Do not run this script with
redirection operators like '> log' or '2>&1', and do not use 'tee.'
-si Operate silently. All output (stdout and stderr) is redirected to the log
only; no output appears on the terminal. This cannot be used with
'-L off'.
-n No-Op. Prints commands instead of running them.
-N No-Op. Similar to '-n', but this command does execute the 'ssh' calls to
get to the remote host, but then does 'p4 sync -n' rather than' 'p4 sync'
on the remote host.
-D Set extreme debugging verbosity.
HELP OPTIONS:
-h Display short help message
-man Display man-style help message
-V Dispay version info for this script and its libraries.
FILES:
The SDP environment file /Users/ttyler/pub/sdp/dev/Server/Unix/p4/common/bin/p4_vars defines various
SDP settings, and is used by several SDP scripts.
The host config file defines the SDP_SYNC_HOSTS and other
values. The default file is:
There can also be an instance-specific file. If
/p4/common/config/sdp_hosts.<SDP_Instance>.cfg exists,
it is used in place of sdp_hosts.cfg. This file must
define all values that are defined in sdp_hosts.cfg.
If a host-specific dir list file exists, it is used
to override the SDP_STATUS_DIRS for specific hosts.
The host-specific dir list files are named:
/p4/common/config/sdp_status_dirs.<host-shortname>.cfg
Each HMS-mananged SDP host must have a P4CONFIG file,
/p4/.p4config.SDP. That will have settings like these
sample values:
P4PORT=ssl:p4hms.p4demo.com:7467
P4CLIENT=SDP.bos-helix-01
P4TICKETS=/p4/hms/.p4tickets
P4TRUST=/p4/hms/.p4trust
P4USER=perforce
P4IGNORE=.p4ignore
EXAMPLES:
EXAMPLE 1: Cron Usage
Recommended crontab usage for SDP Instance 1:
sdp_sync.sh -i 1 -si -a > /dev/null 2>&1
The redirect to /dev/null is to avoid any output that
would generate a duplicate email from cron. Output is not lost;
it is written to a timestampped log file:
/sdp_sync.<timestamp>.log
EXAMPLE 2: Typical Command line usage:
sdp_sync.sh -i 1 -a
Note that the '-i <n>' flag is required unless
SEE ALSO:
See this related script:
/Users/ttyler/pub/sdp/dev/Server/Unix/p4/common/bin/global_replica_status.sh
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #1 | 29182 | C. Thomas Tyler |
Moved HMS files from /p4/common/bin -> /p4/common/site/bin. Moved HMS files from /p4/common/lib -> /p4/common/site/lib. Removed dependency on SDP libs so that HMS can be deployed with a wider variety of SDP versions. |
||
| //guest/perforce_software/hms/dev/p4/common/hms/doc/sdp_sync.command_summary.txt | |||||
| #1 | 26515 | C. Thomas Tyler |
Updated script docs significantly, formally promoting "Tight Ship" terminology. Added "badge of honor" output when Tight Ship compliance is achieved. Verified: Tight Ship compliant. Tweaked for shellcheck compliance. |
||