Skip to content
This repository
tree: c53a991e6f
Fetching contributors…

Cannot retrieve contributors at this time

executable file 80 lines (65 sloc) 1.85 kb
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
#!/bin/sh

if [ "$#" -ne 3 ]; then
    echo "Usage: load-from-stage.sh hostname xdbc-port user:pass"
    exit -1
fi

    TARGET_FILE=$0
    cd `dirname $TARGET_FILE`
    TARGET_FILE=`basename $TARGET_FILE`
    
    # Iterate down a (possible) chain of symlinks
    while [ -L "$TARGET_FILE" ]
    do
        TARGET_FILE=`readlink $TARGET_FILE`
        cd `dirname $TARGET_FILE`
        TARGET_FILE=`basename $TARGET_FILE`
    done
    
    # Compute the canonicalized name by finding the physical path
    # for the directory we're in and appending the target file.
    PHYS_DIR=`pwd -P`
    RESULT=$PHYS_DIR/$TARGET_FILE

if [ "${OS}" == "Windows_NT" ]; then
    SEP=';'
    BASE="." # assume we're in the directory of the script for now
    echo "Running on Windows"
else
    BASE=$PHYS_DIR
    SEP=':'
fi

CP=$BASE/lib/xcc.jar
CP=${CP}${SEP}${BASE}/lib/xstream-1.3.1.jar
CP=${CP}${SEP}${BASE}/lib/xqsync.jar

if [ -d "$JAVA_HOME" ]; then
  JAVA=$JAVA_HOME/bin/java
else
  JAVA=java
fi

if [ "{$OS}" == "windowsnt" ]; then
    CP=`cygpath -wa $BASE/lib/xcc.jar`
    CP=`cygpath -wa ${CP}${SEP}${BASE}/lib/xstream-1.3.1.jar`
    CP=`cygpath -wa ${CP}${SEP}${BASE}/lib/xqsync.jar`
fi


F=dmc-stage.marklogic.com:8007
T=${1}:${2}
# And some credentials
FCREDS='reader:read3r'
TCREDS=${3}

FROM=$F
TO=$T
FROMCREDS=$FCREDS
TOCREDS=$TCREDS

DIRS="/"
DOCS=""

read -p "Loading All URIS under / from $FROM to $TO (as $TCREDS) Continue? [n] " yesno
shopt -s nocasematch
case "$yesno" in
  y|Y|Yes) ;;
  * ) echo "Aborted"; exit -1 ;;
esac

echo "Copying $FROM to $TO"
"$JAVA" -cp "$CP" -Dfile.encoding=UTF-8 -DLOG_LEVEL=ALL \
    -DLOG_HANDLER=FILE \
    -DINPUT_CONNECTION_STRING=xcc://$FROMCREDS@$FROM/RunDMC2 \
    -DOUTPUT_CONNECTION_STRING=xcc://$TOCREDS@$TO/RunDMC \
    -DINPUT_DIRECTORY_URI="$DIRS" \
    com.marklogic.ps.xqsync.XQSync

#cleanup
Something went wrong with that request. Please try again.