Hex Artifact Content

Artifact e991615aecef77345cc9595c21c1ef50f5b2f939:


0000: 23 21 20 2f 62 69 6e 2f 62 61 73 68 0a 0a 54 41  #! /bin/bash..TA
0010: 52 47 45 54 3d 22 24 31 22 0a 73 68 69 66 74 0a  RGET="$1".shift.
0020: 0a 62 75 69 6c 64 69 64 3d 22 24 28 28 20 68 6f  .buildid="$(( ho
0030: 73 74 6e 61 6d 65 3b 20 69 64 20 2d 75 3b 20 70  stname; id -u; p
0040: 77 64 20 29 20 7c 20 6f 70 65 6e 73 73 6c 20 73  wd ) | openssl s
0050: 68 61 31 20 7c 20 73 65 64 20 27 73 40 5e 2e 2a  ha1 | sed 's@^.*
0060: 3d 20 2a 40 40 27 29 22 0a 77 6f 72 6b 64 69 72  = *@@')".workdir
0070: 3d 22 2f 74 6d 70 2f 77 6f 72 6b 2d 6b 69 74 63  ="/tmp/work-kitc
0080: 72 65 61 74 6f 72 2d 24 7b 62 75 69 6c 64 69 64  reator-${buildid
0090: 7d 22 0a 0a 68 6f 73 74 55 70 3d 27 30 27 0a 66  }"..hostUp='0'.f
00a0: 6f 72 20 74 72 79 20 69 6e 20 7b 31 2e 2e 33 7d  or try in {1..3}
00b0: 3b 20 64 6f 0a 09 63 68 65 63 6b 4f 6b 3d 22 24  ; do..checkOk="$
00c0: 28 74 69 6d 65 6f 75 74 20 33 30 30 20 73 73 68  (timeout 300 ssh
00d0: 20 2d 71 20 22 24 7b 54 41 52 47 45 54 7d 22 20   -q "${TARGET}" 
00e0: 27 65 63 68 6f 20 6f 6b 27 20 32 3e 2f 64 65 76  'echo ok' 2>/dev
00f0: 2f 6e 75 6c 6c 29 22 0a 0a 09 69 66 20 5b 20 22  /null)"...if [ "
0100: 24 7b 63 68 65 63 6b 4f 6b 7d 22 20 3d 20 27 6f  ${checkOk}" = 'o
0110: 6b 27 20 5d 3b 20 74 68 65 6e 0a 09 09 68 6f 73  k' ]; then...hos
0120: 74 55 70 3d 27 31 27 0a 09 09 62 72 65 61 6b 0a  tUp='1'...break.
0130: 09 66 69 0a 0a 09 73 6c 65 65 70 20 31 30 0a 64  .fi...sleep 10.d
0140: 6f 6e 65 0a 0a 69 66 20 5b 20 22 24 7b 68 6f 73  one..if [ "${hos
0150: 74 55 70 7d 22 20 21 3d 20 27 31 27 20 5d 3b 20  tUp}" != '1' ]; 
0160: 74 68 65 6e 0a 09 65 63 68 6f 20 22 55 6e 61 62  then..echo "Unab
0170: 6c 65 20 74 6f 20 65 73 74 61 62 6c 69 73 68 20  le to establish 
0180: 61 20 6c 69 6e 6b 20 74 6f 20 74 68 65 20 72 65  a link to the re
0190: 6d 6f 74 65 20 73 79 73 74 65 6d 2e 22 20 3e 26  mote system." >&
01a0: 32 0a 0a 09 65 78 69 74 20 31 0a 66 69 0a 0a 72  2...exit 1.fi..r
01b0: 73 79 6e 63 20 2d 61 71 20 2d 2d 64 65 6c 65 74  sync -aq --delet
01c0: 65 20 2d 65 20 73 73 68 20 2e 20 22 24 7b 54 41  e -e ssh . "${TA
01d0: 52 47 45 54 7d 3a 24 7b 77 6f 72 6b 64 69 72 7d  RGET}:${workdir}
01e0: 2f 22 20 7c 7c 20 65 78 69 74 20 31 0a 0a 28 0a  /" || exit 1..(.
01f0: 09 6e 65 77 41 72 67 76 3d 28 22 24 40 22 29 3b  .newArgv=("$@");
0200: 20 64 65 63 6c 61 72 65 20 2d 70 20 6e 65 77 41   declare -p newA
0210: 72 67 76 0a 09 64 65 63 6c 61 72 65 20 2d 70 20  rgv..declare -p 
0220: 77 6f 72 6b 64 69 72 0a 09 65 78 70 6f 72 74 0a  workdir..export.
0230: 09 63 61 74 20 3c 3c 20 5c 5f 45 4f 46 5f 0a 63  .cat << \_EOF_.c
0240: 64 20 22 24 7b 77 6f 72 6b 64 69 72 7d 22 20 7c  d "${workdir}" |
0250: 7c 20 65 78 69 74 20 31 0a 65 78 70 6f 72 74 20  | exit 1.export 
0260: 50 41 54 48 3d 22 24 7b 50 41 54 48 7d 3a 2f 75  PATH="${PATH}:/u
0270: 73 72 2f 6c 6f 63 61 6c 2f 62 69 6e 3a 2f 75 73  sr/local/bin:/us
0280: 72 2f 62 69 6e 22 0a 2e 2f 6b 69 74 63 72 65 61  r/bin"../kitcrea
0290: 74 6f 72 20 22 24 7b 6e 65 77 41 72 67 76 5b 40  tor "${newArgv[@
02a0: 5d 7d 22 0a 65 78 69 74 20 22 24 3f 22 0a 5f 45  ]}".exit "$?"._E
02b0: 4f 46 5f 0a 29 20 7c 20 73 73 68 20 22 24 7b 54  OF_.) | ssh "${T
02c0: 41 52 47 45 54 7d 22 20 62 61 73 68 20 2d 73 0a  ARGET}" bash -s.
02d0: 72 65 74 76 61 6c 3d 22 24 3f 22 0a 0a 72 6d 20  retval="$?"..rm 
02e0: 2d 66 20 2a 2f 62 75 69 6c 64 2e 6c 6f 67 0a 73  -f */build.log.s
02f0: 73 68 20 22 24 7b 54 41 52 47 45 54 7d 22 20 22  sh "${TARGET}" "
0300: 77 6f 72 6b 64 69 72 3d 27 24 7b 77 6f 72 6b 64  workdir='${workd
0310: 69 72 7d 27 3b 20 22 27 63 64 20 22 24 7b 77 6f  ir}'; "'cd "${wo
0320: 72 6b 64 69 72 7d 22 20 26 26 20 74 61 72 20 2d  rkdir}" && tar -
0330: 63 66 20 2d 20 74 63 6c 6b 69 74 2d 2a 20 6c 69  cf - tclkit-* li
0340: 62 74 63 6c 6b 69 74 2a 20 2a 2f 62 75 69 6c 64  btclkit* */build
0350: 2e 6c 6f 67 20 32 3e 2f 64 65 76 2f 6e 75 6c 6c  .log 2>/dev/null
0360: 27 20 7c 20 74 61 72 20 2d 78 66 20 2d 0a 0a 23  ' | tar -xf -..#
0370: 20 43 6c 65 61 6e 2d 75 70 20 69 66 20 61 70 70   Clean-up if app
0380: 72 6f 70 72 69 61 74 65 0a 63 61 73 65 20 22 24  ropriate.case "$
0390: 28 70 77 64 29 22 20 69 6e 0a 09 2f 68 6f 6d 65  (pwd)" in../home
03a0: 2f 72 6b 65 65 6e 65 2f 2a 29 0a 09 09 3b 3b 0a  /rkeene/*)...;;.
03b0: 09 2a 29 0a 09 09 73 73 68 20 22 24 7b 54 41 52  .*)...ssh "${TAR
03c0: 47 45 54 7d 22 20 22 77 6f 72 6b 64 69 72 3d 27  GET}" "workdir='
03d0: 24 7b 77 6f 72 6b 64 69 72 7d 27 3b 20 22 27 72  ${workdir}'; "'r
03e0: 6d 20 2d 72 66 20 22 24 7b 77 6f 72 6b 64 69 72  m -rf "${workdir
03f0: 7d 22 27 0a 09 09 3b 3b 0a 65 73 61 63 0a 0a 65  }"'...;;.esac..e
0400: 78 69 74 20 22 24 7b 72 65 74 76 61 6c 7d 22 0a  xit "${retval}".