/usr/bin/scriptingserviceexample is in rsplib-services 3.0.1-1ubuntu3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | #!/bin/bash
# $Id: scriptingserviceexample 2608 2011-11-23 07:52:38Z dreibh $
# --------------------------------------------------------------------------
#
# //===// //===== //===// // // //===//
# // // // // // // // // //
# //===// //===== //===// // // //===<<
# // \\ // // // // // //
# // \\ =====// // //===== // //===// Version II
#
# ------------- An Efficient RSerPool Prototype Implementation -------------
#
# Copyright (C) 2002-2012 by Thomas Dreibholz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Contact: dreibh@iem.uni-due.de
if [ $# -lt 1 ] ; then
echo "Usage: ssdistribute [Unique ID] [Environment]"
exit 1
fi
DIRECTORY="."
UNIQUE_ID="$1"
ENVIRONMENT="$2"
shift ; shift
POOLHANDLE="ScriptingPool"
SS_TEMPDIR="ssTEMP-$UNIQUE_ID"
SS_IN_NAME="ssIN-$UNIQUE_ID.tar.gz"
SS_OUT_NAME="ssOUT-$UNIQUE_ID.tar.gz"
SS_ENVIRONMENT_BYTES=5000
SS_INPUT_BYTES=2500
SS_OUTPUT_BYTES=2000
# This is the run script.
SS_RUNSCRIPT=" \
OUTPUT_ARCHIVE=\$1
ENVIRONMENT_FILE=\$2
echo \"This is the run script!\" && \
echo \" + Output will be written to \\\"\$OUTPUT_ARCHIVE\\\" ...\" && \
echo \" + Input string is \\\"\`cat my-input.data\`\\\"\" && \
if [ \"\$ENVIRONMENT_FILE\" != \"\" ] ; then \
echo \" + Environment file is \\\"\$ENVIRONMENT_FILE\\\" ...\" && \
echo \" SHA1 hash is:\" && \
sha1sum \$ENVIRONMENT_FILE ; \
fi && \
\
echo \" + Simulating some work (your program may do something more useful here!)\" && \
date >my-output.data && \
dd if=/dev/urandom of=my-output.random bs=$SS_OUTPUT_BYTES count=1 && \
sleep 10 && \
\
echo \" + Writing results archive \\\"\$OUTPUT_ARCHIVE\\\" ...\" && \
tar czvf \$OUTPUT_ARCHIVE my-output.data my-output.random && \
\
echo \" + Script processing successfully finished!\"
"
echo "Preparing input ..." && \
if [ -e "$DIRECTORY/$SS_TEMPDIR" ] ; then
rm -rf "$DIRECTORY/$SS_TEMPDIR"
fi
echo " + Creating directory \"$DIRECTORY/$SS_TEMPDIR\"" && \
mkdir "$DIRECTORY/$SS_TEMPDIR" && \
echo " + Changing to directory \"$DIRECTORY/$SS_TEMPDIR\" ..." && \
cd "$DIRECTORY/$SS_TEMPDIR" && \
\
echo " + Writing input files \"my-input.data\" and \"my-input.random\" ..." && \
echo "This is an example input for ID $UNIQUE_ID" >my-input.data && \
dd if=/dev/urandom of=my-input.random bs=$SS_INPUT_BYTES count=1 && \
\
echo " + Writing runscript \"ssrun\" ..." && \
echo "$SS_RUNSCRIPT" >ssrun && \
\
echo " + Archiving \"ssrun\" and \"my-input.data\" into \"$SS_IN_NAME\" ..." && \
tar chzf ../$SS_IN_NAME ssrun my-input.data my-input.random && \
cd .. || exit 1
if [ "$ENVIRONMENT" != "" ] ; then
if [ ! -e "$ENVIRONMENT" ] ; then
echo " + Creating environment file \"$ENVIRONMENT\" ..."
dd if=/dev/urandom of=$ENVIRONMENT bs=$SS_ENVIRONMENT_BYTES count=1 || exit 1
fi
fi
echo "Distributing and processing ..."
echo " + Input file is \"$SS_IN_NAME\""
echo " + Output will be written into \"$SS_OUT_NAME\""
echo " + Calling scriptingclient ..."
echo ""
env PATH=$PATH:. scriptingclient -runid="Example ID=$UNIQUE_ID" -environment=$ENVIRONMENT -input=$SS_IN_NAME -output=$SS_OUT_NAME -poolhandle=$POOLHANDLE $@ || exit 1
echo " + scriptingclient has returned"
echo "Extracting ..."
if [ -s "$SS_OUT_NAME" ] ; then
echo " + Unpacking output file \"$SS_OUT_NAME\" ..."
( tar xzvf "$SS_OUT_NAME" | xargs touch ) || exit 1 # This will also update the time stamp!
echo " + Results string is \"`cat my-output.data`\""
echo " + Removing temporary files $SS_IN_NAME and $SS_OUT_NAME ..."
rm -f $SS_IN_NAME $SS_OUT_NAME
echo " + Removing temporary directory $SS_TEMPDIR"
rm -rf $SS_TEMPDIR
exit 0
else
echo "ERROR: No results have been created in directory $DIRECTORY!"
exit 1
fi
|