3 if [ -z "$1" -o -z "$2" -o -z "$3" -o -z "$4" -o -z "$5" -o -z "$6" ] ; then
5 echo "Usage: ./remote.sh user host port files results_from results_to [args...]"
7 echo "user is the username on the remote system to use for building"
9 echo "host is the ssh hostname to build the packages"
11 echo "port is the ssh port on the remote system"
13 echo "files is a string of possibly multiple files to copy over"
14 echo "to the remote system. The files will be copied to the"
15 echo "/home/user/barrychroot directory and any arguments will be"
16 echo "run from there. Normally, the tarball and the script"
17 echo "will be included in this list at a minimum."
19 echo "results_from is the directory on the remote system where the"
20 echo "results will be found after running the arguments. i.e. if you"
21 echo "run make-deb.sh on the remote system, results_from is the"
22 echo "directory where the resulting binary packages can be found."
23 echo "This path is a remote path and does not include the hostname."
24 echo "For example: /home/user/results"
26 echo "results_to is the local directory into which the resulting files"
27 echo "will be copied. The directory will be created if it"
28 echo "does not already exist."
30 echo "Expects to be run as a normal user."
45 function RemoteRun
() {
46 ssh -x -2 -p $HOSTPORT $REMOTEUSER@
$HOST "$1"
49 REMOTEDIR
="/home/$REMOTEUSER/barryremote"
51 # create target work directory
52 RemoteRun
"rm -rf '$REMOTEDIR'"
53 RemoteRun
"mkdir -p '$REMOTEDIR'"
55 # copy source tarball and script to chroot system
56 scp
-P $HOSTPORT $FILES "$REMOTEUSER@$HOST:$REMOTEDIR"
58 # create a quoted argument string
62 QUOTEDARGS
="$QUOTEDARGS '$arg'"
66 RemoteRun
"cd '$REMOTEDIR' && $QUOTEDARGS"
68 # copy the results back to the target directory
69 mkdir
-p "$RESULTS_TO"
70 scp
-P $HOSTPORT "$REMOTEUSER@$HOST:$RESULTS_FROM/*" "$RESULTS_TO"
72 # cleanup source tarball and script
73 RemoteRun
"rm -rf '$REMOTEDIR'"