diff options
-rw-r--r-- | .SRCINFO | 16 | ||||
-rw-r--r-- | PKGBUILD | 57 | ||||
-rw-r--r-- | orientdb-community.install | 102 | ||||
-rw-r--r-- | orientdb.service | 15 | ||||
-rw-r--r-- | server2.sh | 88 | ||||
-rw-r--r-- | shutdown2.sh | 97 |
6 files changed, 311 insertions, 64 deletions
@@ -1,21 +1,25 @@ pkgbase = orientdb-community pkgdesc = The Graph-Document NoSQL - Community Edition pkgver = 2.1.3 - pkgrel = 1 + pkgrel = 2 url = http://www.orientdb.org install = orientdb-community.install arch = any license = Apache makedepends = unzip - depends = java-runtime-headless - depends = apache-ant + depends = sh + depends = java-environment conflicts = orientdb conflicts = orientdb-git conflicts = orientdb-graphed-git conflicts = orientdb-graphed - source = https://github.com/orientechnologies/orientdb/archive/2.1.3.tar.gz + source = http://orientdb.com/download.php?email=unknown@unknown.com&file=orientdb-community-2.1.3.tar.gzhttps://github.com/orientechnologies/orientdb/archive/2.1.3.tar.gz source = orientdb.service - md5sums = 8f5454b58dff94b15c380979e81e9387 - md5sums = 687903eba3737f9733bf1c45c4e68e6d + source = server2.sh + source = shutdown2.sh + md5sums = 4c90eec15ae214addd19d8aa8812e99d + md5sums = 2845ee26c2b4a370fde6ada6815b5eeb + md5sums = 4a5fe9143276adf167dbb7ae46a4f3f2 + md5sums = e9482fd3b41fc56af333365c6287b5a6 pkgname = orientdb-community @@ -3,8 +3,9 @@ # Contributor: John Radley <jradxl [at] gmail [dot] com> ## -## This is a build from source +## This is an install from Orient's tar.gz, and does not build Java sources ## + pkgname=orientdb-community ## PKGBUILD:pkgver is not allowed to contain colons, hyphens or whitespace @@ -17,15 +18,13 @@ pkgsuffix= pkgver=$pkgversion pkgtmp= -pkgrel=1 +pkgrel=2 #epoch=1 -pkgdesc="The Graph-Document NoSQL - Community Edition" +pkgdesc="OrientDB Graph-Document NoSQL - Community Edition" arch=('any') license=('Apache') url="http://www.orientdb.org" -depends=('java-runtime-headless') -makedepends=('unzip') -depends=('java-runtime-headless' 'apache-ant') +depends=('sh' 'java-environment') makedepends=('unzip') conflicts=('orientdb' 'orientdb-git' 'orientdb-graphed-git' 'orientdb-graphed') install=$pkgname.install @@ -40,29 +39,34 @@ noextract=() changelog="" # -# Using the github release of source, which has no package name. +# Using Orient's explict tar.gz download for this version. +# server2.sh and shutdown2.sh are versions more suited to systemd usage. # -source=("https://github.com/orientechnologies/orientdb/archive/${pkgversion}${pkgsuffix}.tar.gz" - 'orientdb.service') - -md5sums=('8f5454b58dff94b15c380979e81e9387' - '687903eba3737f9733bf1c45c4e68e6d') +source=( + "http://orientdb.com/download.php?email=unknown@unknown.com&file=orientdb-community-${pkgversion}${pkgsuffix}.tar.gz" + 'orientdb.service' + 'server2.sh' + 'shutdown2.sh' +) + +md5sums=( + '4c90eec15ae214addd19d8aa8812e99d' + '2845ee26c2b4a370fde6ada6815b5eeb' + '4a5fe9143276adf167dbb7ae46a4f3f2' + 'e9482fd3b41fc56af333365c6287b5a6' +) #prepare() {} -build() { - # - #Parse '-community' from pkgname - # - cd "${srcdir}"/$(echo ${pkgname} | sed s/-community//)-${pkgversion}${pkgsuffix} - ant -} +#No Build required +#build() {} #check() {} -package() { - # Build has created a 'releases' dir in the parent. - cd ${srcdir}/releases/${pkgname}-${pkgversion}${pkgsuffix} +package() +{ + + cd "${srcdir}"/${pkgname}-${pkgver} # Create directories with permissions install -dm755 "${pkgdir}"/opt/orientdb @@ -78,13 +82,19 @@ package() { # Recursively copy files cp -r . "${pkgdir}"/opt/orientdb + # Add the improved systemd server management scripts + install -m700 "${srcdir}"/server2.sh "${pkgdir}"/opt/orientdb/bin + install -m700 "${srcdir}"/shutdown2.sh "${pkgdir}"/opt/orientdb/bin + # Set permissions on the executables + # --no World permissions are intended, so namcap errors can be ignored. install -m700 bin/*.sh "${pkgdir}"/opt/orientdb/bin/ install -m755 bin/console.sh "${pkgdir}"/opt/orientdb/bin/ # Remove DOS bat files find "${pkgdir}"/opt/orientdb -type f -name "*.bat" -exec rm -f {} \; + # Empty dirs for Install - namcap errors can be ignored. install -d "${pkgdir}"/usr/bin install -d "${pkgdir}"/var/log/orientdb install -d "${pkgdir}"/usr/lib/systemd/system @@ -96,5 +106,8 @@ package() { sed -i 's|YOUR_ORIENTDB_INSTALLATION_PATH|/opt/orientdb|' "${pkgdir}"/opt/orientdb/bin/orientdb.sh sed -i 's|USER_YOU_WANT_ORIENTDB_RUN_WITH|orient|' "${pkgdir}"/opt/orientdb/bin/orientdb.sh + #Prevent server.sh being run from root + sed -i '/PRG="$0"/a if [[ $(id -u) -eq 0 ]] ; then echo "" ; echo "Please do not try to start Orientdb Server as root." ; exit 1 ; fi' "${pkgdir}"/opt/orientdb/bin/server.sh + install -m644 "${srcdir}"/orientdb.service "${pkgdir}"/usr/lib/systemd/system/ } diff --git a/orientdb-community.install b/orientdb-community.install index e4cfcd10bced..1a8913842f86 100644 --- a/orientdb-community.install +++ b/orientdb-community.install @@ -1,47 +1,81 @@ # -# Install scriptlet for OrientDB version +# Install scriptlet for OrientDB # -post_install() { - groupadd -r orient - useradd -r -g orient -d /opt/orientdb -c "OrientDB The Graph-Document NoSQL - Community Edition" orient - chown -R orient.orient /opt/orientdb - chown -R orient.orient /var/log/orientdb +post_install() +{ + groupadd -r orientdb && echo Group orientdb added + + #A home dir is needed as virtualbox writes to dir if su is used. + useradd -r -g orientdb -m -d /home/orientdb -c "OrientDB Graph-Document NoSQL - Community Edition" orientdb && echo User orientdb added + + chown -R orientdb.orientdb /opt/orientdb + chown -R orientdb.orientdb /var/log/orientdb ln -sf /opt/orientdb/log /var/log/orientdb ln -sf /opt/orientdb/config /etc/orientdb ln -sf /opt/orientdb/bin/console.sh /usr/bin/orientdb-console - echo "==> OrientDB server should be launched from user 'orient'. Please keep that in mind." + echo "==> OrientDB has been installed." + echo "==> This install is compatible with systemd and orientdb.service is available." + echo "==> OrientDB server should be launched from user 'orientdb' or by systemctl start orientdb." + echo "==> When started for the first time, a non-encrypted root password will be generated" + echo " automatically and it can be found in /opt/orientdb/config/orientdb-server-config.xml" + echo "==> The Studio Console can be accessed by browsing localhost:2480" + + systemctl daemon-reload } -post_upgrade() { - chown -R orient.orient /opt/orientdb - chown -R orient.orient /var/log/orientdb +post_upgrade() +{ + #In case the Group and User are not present after re-installing or an upgrade. + groupadd -r orientdb && echo Group orientdb added + + #A homedir is needed as virtualbox writes to dir if su is used. + useradd -r -g orientdb -m -d /home/orientdb -c "OrientDB Graph-Document NoSQL - Community Edition" orientdb && echo User orientdb added + + # Remove extra groups and always force User orientdb to have a primary group of orientdb + if [ $(groups orientdb | wc -w) -gt 1 ]; then + usermod -G "" orientdb + echo "Removed extra groups for User orientdb" + fi + usermod -g orientdb orientdb + + chown -R orientdb.orientdb /opt/orientdb + chown -R orientdb.orientdb /var/log/orientdb + + systemctl daemon-reload } -pre_remove() { +pre_remove() +{ # Cannot use echo -n in this context as stdout is not flushed # Server may have been started manually, so systemctl will not stop it - # Grep only the Server entry, as an orient User session may be present - if [ "$(ps aux | grep -e '^orient' | grep -e com.orientechnologies.orient.server)" != "" ]; then - - echo "==> OrientDB server is running. Stopping OrientDB. Wait 60 seconds before using Cntl-C." - echo "..........." - - systemctl stop orientdb.service 2>&1 - echo "..........." + # Grep only the Server entry, as an orientdb User session may be present + if [ "$( ps aux | grep -e ^orient | grep com.orientechnologies.orient )" != "" ]; then + echo "==> OrientDB server is running. Stopping OrientDB. Please wait 60 seconds before using Cntl-C." + echo "==> Trying systemctl ..........." + systemctl daemon-reload + systemctl stop orientdb.service + sleep 5 + echo "==> Testing if systemctl has stopped Server." + if [ "$( ps aux | grep -e ^orient | grep com.orientechnologies.orient )" != "" ]; then + echo "==> systemctl did not stop Server. Trying directly. Please wait 60 seconds before using Cntl-C." + else + echo "==> systemctl succeeded. Proceeding to remove." + fi + fi counter1=0 counter2=0 - while [ "$(ps aux | grep -e '^orient' | grep -e com.orientechnologies.orient.server)" != "" ]; do + while [ "$( ps aux | grep -e ^orient | grep com.orientechnologies.orient )" != "" ]; do sleep 1 counter1=`expr $counter1 + 1` counter2=`expr $counter2 + 1` - if [ $counter1 -le 10 ] + if [ $counter1 -le 9 ] then echo -n "." else @@ -49,29 +83,34 @@ pre_remove() { counter1=0 fi - if [ $counter2 = 30 ] + if [ $counter2 = 20 ] then echo "" - echo "Shutting down OrientDB directly." - su orient /opt/orientdb/bin/shutdown.sh + echo "==> Shutting down OrientDB directly." + #It is correct to use shutdown.sh here as systemd is not involved. + su -c "/opt/orientdb/bin/shutdown.sh >/dev/null 2>/dev/null" - orientdb + echo " Server has been sent shutdown. Please wait for script to end." fi - if [ $counter2 -gt 60 ] + if [ $counter2 -gt 39 ] then + echo "Server has not stopped. Please resolve manually." break fi done - fi + echo "" - rm -rf /etc/orientdb /usr/bin/orientdb-console /opt/orientdb/log || /bin/true + rm -rf /etc/orientdb /usr/bin/orientdb-console /usr/lib/systemd/system/orientdb.service /opt/orientdb/log || /bin/true } -post_remove() { - userdel orient - groupdel orient 2>/dev/null || /bin/true +post_remove() +{ + userdel -r orientdb && echo "User orientdb removed" + groupdel orientdb && echo "Group orientdb removed" if [ -d /opt/orientdb ]; then + echo "" echo "==> OrientDB directory is not empty and will not be removed." echo " Backup database?" echo " Please check path '/opt/orientdb' and remove directory manually." @@ -80,5 +119,6 @@ post_remove() { if [ -d /var/log/orientdb ]; then rm -rf /var/log/orientdb fi -} + systemctl daemon-reload +} diff --git a/orientdb.service b/orientdb.service index 30a7142b86c1..547ca24bad9c 100644 --- a/orientdb.service +++ b/orientdb.service @@ -1,14 +1,19 @@ # -# Service config for OrientDB version 1.7-rc1 +# Service config for OrientDB Graph-Document NoSQL # [Unit] -Description=OrientDB The Graph-Document NoSQL - Community Edition +Description=OrientDB Graph-Document NoSQL - Community Edition +DefaultDependencies=false [Service] Type=simple -User=orient -ExecStart=/opt/orientdb/bin/server.sh -ExecStop=/opt/orientdb/bin/shutdown.sh +#Both User and Group are significant to the correct running of systemd and orientdb +User=orientdb +Group=orientdb + +#server2.sh and shutdown2.sh are used as these have modifications for use with systemd +ExecStart=/opt/orientdb/bin/server2.sh +ExecStop=/opt/orientdb/bin/shutdown2.sh -w -t [Install] WantedBy=multi-user.target diff --git a/server2.sh b/server2.sh new file mode 100644 index 000000000000..8895b59a42bb --- /dev/null +++ b/server2.sh @@ -0,0 +1,88 @@ +#!/bin/bash +# +# Copyright (c) Orient Technologies LTD (http://www.orientechnologies.com) +# +# +# HISTORY: +# 2015-10-08: modified John Radley (jradxl at gmail dot com) for use with Manjaro and Ubuntu systemd. +# removed the "exec" as this was causing systemd to report a failure on shutdown. +# added test to abort script is a server is already running. +# + +if [[ $(id -u) -eq 0 ]] ; then + echo "Please do not try to start Orientdb Server as root." ; + exit 1; +fi + +# resolve links - $0 may be a softlink +PRG="$0" + +#Exit the script if a Server is running +while true ; do + ps -ef | grep java | grep $ORIENTDB_HOME/lib/orientdb-server > /dev/null || break + echo Server is already running. + exit 0; +done + +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 + echo $PRG +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 + +# Raspberry Pi check (Java VM does not run with -server argument on ARMv6) +if [ `uname -m` != "armv6l" ]; then + JAVA_OPTS="$JAVA_OPTS -server " +fi +export JAVA_OPTS + +# 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 +WWW_PATH=$ORIENTDB_HOME/www +ORIENTDB_SETTINGS="-Dprofiler.enabled=true" +JAVA_OPTS_SCRIPT="-Djna.nosys=true -XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true -Dfile.encoding=UTF8 -Drhino.opt.level=9" + +# ORIENTDB MAXIMUM HEAP. USE SYNTAX -Xmx<memory>, WHERE <memory> HAS THE TOTAL MEMORY AND SIZE UNIT. EXAMPLE: -Xmx512m +MAXHEAP=-Xmx512m +# ORIENTDB MAXIMUM DISKCACHE IN MB, EXAMPLE, ENTER -Dstorage.diskCache.bufferSize=8192 FOR 8GB +MAXDISKCACHE="-Dstorage.diskCache.bufferSize=512" + +#Original, commented out +#exec "$JAVA" $JAVA_OPTS $MAXHEAP $JAVA_OPTS_SCRIPT $ORIENTDB_SETTINGS $MAXDISKCACHE -Djava.util.logging.config.file="$LOG_FILE" \ +#-Dorientdb.config.file="$CONFIG_FILE" -Dorientdb.www.path="$WWW_PATH" -Dorientdb.build.number="0" \ +#-cp "$ORIENTDB_HOME/lib/orientdb-server-2.1.3.jar:#$ORIENTDB_HOME/lib/*" $* com.orientechnologies.orient.server.OServerMain + +#Modified, "exec" has been removed as causing a systemd error message on shutdown +$JAVA $JAVA_OPTS $MAXHEAP $JAVA_OPTS_SCRIPT $ORIENTDB_SETTINGS $MAXDISKCACHE \ +-Djava.util.logging.config.file="$LOG_FILE" \ +-Dorientdb.config.file="$CONFIG_FILE" \ +-Dorientdb.www.path="$WWW_PATH" \ +-Dorientdb.build.number="0" \ +-cp "$ORIENTDB_HOME/lib/orientdb-server-2.1.3.jar:$ORIENTDB_HOME/lib/*" com.orientechnologies.orient.server.OServerMain + +exit 0 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 |