3 _ProdServers=" eg35-app1 eg35-app2 eg35-app3 eg35-app4 eg35-util1 eg35-util2"
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 -x Do not warn when extra build steps are required
20 -h Print this message and exit
21 -v Verbose output - echo parameters to stdout
25 while getopts ":f:p:u:bdPxvh" opt
32 b ) BACKUP="-b --suffix=.`date +%Y%m%d%H%M`";;
34 x ) SKIP_BUILD_CHECK="x";;
39 shift $(($OPTIND - 1))
41 if [[ -z "$FILE" ]] || ([[ -z "$DEST" ]] && [[ -z "$AUTOPATH" ]]) | ([[ $# -lt 1 ]] && [[ -z "$PROD" ]])
47 if [[ -z "$SKIP_BUILD_CHECK" ]] ; then
48 if [[ $FILE = *Open-ILS/web/js/ui/default/staff* ]] ; then
49 echo "It looks like you are trying to deploy Evergreen web client JS."
50 echo "In EG 3.1+ and master, you must build JS before copying into place."
51 echo "After making changes, run 'npm run build' before deploying."
52 echo "(Re-run this script with the -x flag to skip this warning.)"
57 # attempt to determine the remote destination path automatically
58 if [[ -n "$AUTOPATH" ]] && [[ -z "$DEST" ]]
64 if [ "$FILE" == "$AUTODEST" ]; then
65 AUTODEST=$(printf '%s' "$FILE" | sed 's|^.*Open-ILS/src/templates/\(.*\)$|/srv/openils/var/templates/\1|')
69 if [ "$FILE" == "$AUTODEST" ]; then
70 AUTODEST=$(printf '%s' "$FILE" | sed 's|^.*Open-ILS/src/perlmods/lib/\(.*\)$|/usr/local/share/perl/5.26.1/\1|')
74 if [ "$FILE" == "$AUTODEST" ]; then
75 AUTODEST=$(printf '%s' "$FILE" | sed 's|^.*Open-ILS/web/\(.*\)$|/srv/openils/var/web/\1|')
79 if [ "$FILE" == "$AUTODEST" ]; then
80 AUTODEST=$(printf '%s' "$FILE" | sed 's|^.*Open-ILS/xul/staff_client/server/\(.*\)$|/srv/openils/var/web/xul/server/\1|')
83 if [ "$FILE" == "$AUTODEST" ]; then
84 echo "Destination path could not be determined.\n"
98 RSYNC_OPTS="-rlpD --chown=${USER}:${USER}"
105 echo "adding ${_ProdServers} to hosts"
106 _hosts="$@$_ProdServers"
111 RSYNC_DEST="${HOST}:${DEST}"
112 if [[ -z "$VERBOSE" ]]; then
113 echo "deploying to ${HOST}"
115 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"
117 rsync -e"${SSH}" $BACKUP $RSYNC_OPTS $FILE $RSYNC_DEST