YUKI Hiroshi
null+****@clear*****
Mon Oct 22 10:21:47 JST 2012
YUKI Hiroshi 2012-10-22 10:21:47 +0900 (Mon, 22 Oct 2012) New Revision: 560d1b96d2fb27b65bf4f0e583dde641f6834fb9 https://github.com/groonga/gcs/commit/560d1b96d2fb27b65bf4f0e583dde641f6834fb9 Log: Stop to import if there is any error Modified files: bin/gcs-import-examples Modified: bin/gcs-import-examples (+47 -12) =================================================================== --- bin/gcs-import-examples 2012-10-22 10:23:44 +0900 (bcadbab) +++ bin/gcs-import-examples 2012-10-22 10:21:47 +0900 (6fc949e) @@ -3,6 +3,7 @@ GREEN="\033[0;32;1m" RED="\033[0;31;1m" YELLOW="\033[1;33;1m" +CYAN="\033[0;36;1m" RESET="\033[m" cat <<EOT @@ -13,6 +14,27 @@ This script setup an example domain and import data into the domain. EOT +echo "Checking prerequisites..." +echo + +printf "* gcs running..." +curl --silent "http://localhost:7575" > /dev/null +if [ $? -eq 0 ] +then + echo " "$GREEN"OK"$RESET +else + echo " "$RED"not running"$RESET + printf $YELLOW +cat <<"EOT" + +You need to run gcs on port 7575. Just run gcs command without any options on another terminal. + + $ gcs + +EOT + printf $RESET +fi + cat <<EOT NOTICE: @@ -25,6 +47,19 @@ EOT read enter +run() { + "$@" + result=$? + + if [ $result -ne 0 ] + then + echo " "$RED"Failed:"$RESET $CYAN"$@"$RESET $YELLOW"[$PWD]"$RESET + exit $result + fi + + return 0 +} + path_prefixes="`dirname $0`/.." if [ -L "$0" ]; then real_dirname="`dirname $0`/`readlink $0`" @@ -55,12 +90,12 @@ done echo "==== Deleting 'example' domain (if exists)" -$bin_path/gcs-delete-domain --domain-name example --force +run $bin_path/gcs-delete-domain --domain-name example --force echo echo "==== Creating 'example' domain" -$bin_path/gcs-create-domain --domain-name example +run $bin_path/gcs-create-domain --domain-name example echo echo @@ -69,26 +104,26 @@ search_endpoint=`$bin_path/gcs-describe-domain --domain-name example | grep "Sea echo "==== Adding index fields" echo "== Creating 'name' field" -$bin_path/gcs-configure-fields --domain-name example --name name --type text --option result -$bin_path/gcs-configure-fields --domain-name example --name name --type text --option facet +run $bin_path/gcs-configure-fields --domain-name example --name name --type text --option result +run $bin_path/gcs-configure-fields --domain-name example --name name --type text --option facet echo echo "== Creating 'address' field" -$bin_path/gcs-configure-fields --domain-name example --name address --type text --option result -$bin_path/gcs-configure-fields --domain-name example --name address --type text --option facet +run $bin_path/gcs-configure-fields --domain-name example --name address --type text --option result +run $bin_path/gcs-configure-fields --domain-name example --name address --type text --option facet echo echo "== Creating 'email_address' field" -$bin_path/gcs-configure-fields --domain-name example --name email_address --type text --option result -$bin_path/gcs-configure-fields --domain-name example --name email_address --type text --option facet +run $bin_path/gcs-configure-fields --domain-name example --name email_address --type text --option result +run $bin_path/gcs-configure-fields --domain-name example --name email_address --type text --option facet echo echo "== Creating 'products' field" -$bin_path/gcs-configure-fields --domain-name example --name products --type literal --option search -$bin_path/gcs-configure-fields --domain-name example --name products --type literal --option result -$bin_path/gcs-configure-fields --domain-name example --name products --type literal --option facet +run $bin_path/gcs-configure-fields --domain-name example --name products --type literal --option search +run $bin_path/gcs-configure-fields --domain-name example --name products --type literal --option result +run $bin_path/gcs-configure-fields --domain-name example --name products --type literal --option facet echo echo echo "==== Indexing data" -$bin_path/gcs-post-sdf --domain-name example --source $examples_path/example.sdf.json +run $bin_path/gcs-post-sdf --domain-name example --source $examples_path/example.sdf.json echo echo -------------- next part -------------- HTML����������������������������...Download