3 _ProdServers=" app1-1 app1-2 app2-1 app2-2 app3-1 app3-2 stanns sip2 bibc-prod"
9 ./deployfile.sh -f filename -p /path/to/destination/ [ -u remoteuser ] [ -b ] host1 [ host2 ... ]
10 ./deployfile.sh -f evergreen.git/Open-ILS/something/something -d [ -u remoteuser ] [ -b ] host1 [ host2 ... ]
13 -f Name of file to be deployed
14 -p Path on remote server where file should be deployed to (overrides -d)
15 -d Determine remote path automatically (experimental; ignored if a path is specified with -p)
16 -u Username to use when logging into remote server; if not provided, defaults to current user
17 -b Backup flag (optional); creates a backup instead of overwriting file on remote server
18 -P Auto add all production machines to host list
19 -h Print this message and exit
20 -v Verbose output - echo parameters to stdout
24 while getopts ":f:p:u:bdPvh" opt
31 b ) BACKUP="-b --suffix=.`date +%Y%m%d%H%M`";;
37 shift $(($OPTIND - 1))
39 if [[ -z "$FILE" ]] || ([[ -z "$DEST" ]] && [[ -z "$AUTOPATH" ]]) | ([[ $# -lt 1 ]] && [[ -z "$PROD" ]])
45 # attempt to determine the remote destination path automatically
46 if [[ -n "$AUTOPATH" ]] && [[ -z "$DEST" ]]
52 if [ "$FILE" == "$AUTODEST" ]; then
53 AUTODEST=$(printf '%s' "$FILE" | sed 's|^.*Open-ILS/src/templates/\(.*\)$|/srv/openils/var/templates/\1|')
57 if [ "$FILE" == "$AUTODEST" ]; then
58 AUTODEST=$(printf '%s' "$FILE" | sed 's|^.*Open-ILS/src/perlmods/lib/\(.*\)$|/usr/local/share/perl/5.14.2/\1|')
62 if [ "$FILE" == "$AUTODEST" ]; then
63 AUTODEST=$(printf '%s' "$FILE" | sed 's|^.*Open-ILS/web/\(.*\)$|/srv/openils/var/web/\1|')
67 if [ "$FILE" == "$AUTODEST" ]; then
68 AUTODEST=$(printf '%s' "$FILE" | sed 's|^.*Open-ILS/xul/staff_client/server/\(.*\)$|/srv/openils/var/web/xul/server/\1|')
71 if [ "$FILE" == "$AUTODEST" ]; then
72 echo "Destination path could not be determined.\n"
91 echo "adding ${_ProdServers} to hosts"
92 _hosts="$@$_ProdServers"
97 RSYNC_DEST="${HOST}:${DEST}"
98 if [[ -z "$VERBOSE" ]]; then
99 echo -e "$HOST:\n\tFILE=$FILE\n\tDEST=$DEST\n\tUSER=$USER\n\tBACKUP=$BACKUP\n\tSSH=$SSH\n\tRSYNC_DEST=$RSYNC_DEST\n\tAUTOPATH=$AUTOPATH\n\tAUTODEST=$AUTODEST\n"
101 rsync -e"${SSH}" $BACKUP -avz $FILE $RSYNC_DEST