1#!/bin/sh -e
2
3echo running $0
4
5topdir="$PROJECT_DIR/.."
6
7dest="$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/couchbase-core"
8
9# ns_server bits
10rsync -a --delete "$topdir/install/" "$dest/"
11rm "$dest/bin/couchjs"
12cp "$PROJECT_DIR/Couchbase Server/erl"                "$dest/bin/erl"
13cp "$PROJECT_DIR/Couchbase Server/couchjs.tpl"        "$dest/bin/couchjs.tpl"
14cp "$PROJECT_DIR/Couchbase Server/erl"                "$dest/lib/erlang/bin/erl"
15cp "$PROJECT_DIR/Couchbase Server/start-couchbase.sh" "$dest/../start-server.sh"
16rm "$dest/etc/couchbase/static_config"
17cp "$topdir/ns_server/etc/static_config.in"           "$dest/etc/couchbase/static_config.in"
18
19mkdir -p "$dest/priv" "$dest/logs" "$dest/config" "$dest/tmp"
20
21echo "Installing and fixing up libraries:"
22cd "$dest"
23ruby "$PROJECT_DIR/Couchbase Server/install_libraries.rb"
24
25cd "$topdir/install"
26install_absolute_path=`pwd`
27
28cd "$dest"
29
30# fix the path to lib/python in the Python scripts:
31
32_fix_python_path () {
33    echo "Fixing Python lib path in $1"
34    sed -i '~' -e "s,\/opt\/couchbase,\`dirname \"\$0\"\`\/$2,g" $1
35    rm "$1~"
36}
37
38echo "fixing path for cb* commands in `pwd`"
39_fix_python_path "bin/cbbackup"                 ".."
40_fix_python_path "bin/cbepctl"                  ".."
41_fix_python_path "bin/cbrestore"                ".."
42_fix_python_path "bin/cbstats"                  ".."
43_fix_python_path "bin/cbtransfer"               ".."
44_fix_python_path "bin/cbvbucketctl"             ".."
45_fix_python_path "bin/couchbase-cli"            ".."
46_fix_python_path "bin/cbrecovery"               ".."
47_fix_python_path "bin/cbhealthchecker"          ".."
48
49_fix_python_path "bin/tools/cbanalyze-core"     "../.."
50_fix_python_path "bin/tools/cbdocloader"        "../.."
51_fix_python_path "bin/cbworkloadgen"            ".."
52