summarylogtreecommitdiffstats
path: root/shutdown2.sh
diff options
context:
space:
mode:
authorNeng Xu2015-10-09 14:21:38 -0700
committerNeng Xu2015-10-09 14:21:38 -0700
commit9e1102bae957debb1cbb35399e2a20647fe663bd (patch)
tree99c64bd948c254534b2c6f04cc7f5f88caabe8ad /shutdown2.sh
parent89e62e9db1d0384f404442cc9103d40a6b7a7f03 (diff)
downloadaur-9e1102bae957debb1cbb35399e2a20647fe663bd.tar.gz
2.1.3-2 incorporated changes from jradxl
Diffstat (limited to 'shutdown2.sh')
-rw-r--r--shutdown2.sh97
1 files changed, 97 insertions, 0 deletions
diff --git a/shutdown2.sh b/shutdown2.sh
new file mode 100644
index 000000000000..731c8d3e230c
--- /dev/null
+++ b/shutdown2.sh
@@ -0,0 +1,97 @@
+#!/bin/bash
+#
+# Copyright (c) Orient Technologies LTD (http://www.orientechnologies.com)
+#
+# HISTORY:
+# 2012-07-31: Added -w option
+#
+# 2015-10-08: modified John Radley (jradxl at gmail dot com) for use with Ubuntu and Manjaro systemd
+# added -t option, which checks whether the Server is running before trying to shutdown
+#
+
+# resolve links - $0 may be a softlink
+PRG="$0"
+
+#Test for no arguments (comment out if you need no arguments option)
+if [ $# -eq 0 ]; then
+ echo "usage: either -w | --wait and/or -t | --test"
+ exit 1
+fi
+
+#Process the Arguments
+while [[ $# > 0 ]]
+do
+ key="$1"
+ case $key in
+ -w|--wait)
+ wait="yes"
+ ;;
+ -t|--test)
+ test="test"
+ ;;
+ *)
+ echo "usage: either -w | --wait and/or -t | --test"
+ exit 1
+ ;;
+ esac
+ shift 1
+done
+
+#Exit the script if Server is not running
+if [ "x$test" = "xtest" ] ; then
+ while true ; do
+ ps -ef | grep java | grep $ORIENTDB_HOME/lib/orientdb-server > /dev/null || exit 0
+ break;
+ done
+fi
+
+while [ -h "$PRG" ]; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`/"$link"
+ fi
+done
+
+# Get standard environment variables
+PRGDIR=`dirname "$PRG"`
+
+# Only set ORIENTDB_HOME if not already set
+[ -f "$ORIENTDB_HOME"/bin/server.sh ] || ORIENTDB_HOME=`cd "$PRGDIR/.." ; pwd`
+export ORIENTDB_HOME
+cd "$ORIENTDB_HOME/bin"
+
+if [ ! -f "${CONFIG_FILE}" ]
+then
+ CONFIG_FILE=$ORIENTDB_HOME/config/orientdb-server-config.xml
+fi
+
+# Set JavaHome if it exists
+if [ -f "${JAVA_HOME}/bin/java" ]; then
+ JAVA=${JAVA_HOME}/bin/java
+else
+ JAVA=java
+fi
+export JAVA
+
+LOG_FILE=$ORIENTDB_HOME/config/orientdb-server-log.properties
+LOG_LEVEL=warning
+WWW_PATH=$ORIENTDB_HOME/www
+JAVA_OPTS=-Djava.awt.headless=true
+
+#Use the Server's shutdown comment
+$JAVA -client $JAVA_OPTS \
+-Dorientdb.config.file="$CONFIG_FILE" \
+-cp "$ORIENTDB_HOME/lib/orientdb-tools-2.1.3.jar:$ORIENTDB_HOME/lib/*" com.orientechnologies.orient.server.OServerShutdownMain
+
+#Wait for the Server to stop.
+if [ "x$wait" = "xyes" ] ; then
+ while true ; do
+ ps -ef | grep java | grep $ORIENTDB_HOME/lib/orientdb-server > /dev/null || break
+ sleep 1;
+ done
+fi
+
+exit 0