Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
OpenXchangeJava问题_Java_Installation_Ubuntu 16.04 - Fatal编程技术网

OpenXchangeJava问题

OpenXchangeJava问题,java,installation,ubuntu-16.04,Java,Installation,Ubuntu 16.04,我在安装OpenXchange的过程中遇到了一个java错误 /opt/open-xchange/sbin/registerserver -n oxserver -A oxadminmaster -P admin_master_password 召唤 /opt/open-xchange/lib/oxfunctions.sh: line 73: [: 9-internal: integer expression expected server could not be registered:

我在安装OpenXchange的过程中遇到了一个java错误

/opt/open-xchange/sbin/registerserver -n oxserver -A oxadminmaster -P admin_master_password
召唤

/opt/open-xchange/lib/oxfunctions.sh: line 73: [: 9-internal: integer expression expected

server could not be registered:
Error: Connection refused to host: localhost; nested exception is:
        java.net.ConnectException: Connection refused
以下是oxunctions.sh:

#
#
#   OPEN-XCHANGE legal information
#
#   All intellectual property rights in the Software are protected by
#   international copyright laws.
#
#
#   In some countries OX, OX Open-Xchange, open xchange and OXtender
#   as well as the corresponding Logos OX Open-Xchange and OX are registered
#   trademarks of the OX Software GmbH group of companies.
#   The use of the Logos is not covered by the GNU General Public License.
#   Instead, you are allowed to use these Logos according to the terms and
#   conditions of the Creative Commons License, Version 2.5, Attribution,
#   Non-commercial, ShareAlike, and the interpretation of the term
#   Non-commercial applicable to the aforementioned license is published
#   on the web site http://www.open-xchange.com/EN/legal/index.html.
#
#   Please make sure that third-party modules and libraries are used
#   according to their respective licenses.
#
#   Any modifications to this package must retain all copyright notices
#   of the original copyright holder(s) for the original code used.
#
#   After any such modifications, the original and derivative code shall remain
#   under the copyright of the copyright holder(s) and/or original author(s)per
#   the Attribution and Assignment Agreement that can be located at
#   http://www.open-xchange.com/EN/developer/. The contributing author shall be
#   given Attribution for the derivative code and a license granting use.
#
#    Copyright (C) 2016-2020 OX Software GmbH
#    Mail: info@open-xchange.com
#
#
#    This program is free software; you can redistribute it and/or modify it
#    under the terms of the GNU General Public License, Version 2 as published
#    by the Free Software Foundation.
#
#    This program is distributed in the hope that it will be useful, but
#    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
#    or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
#    for more details.
#
#    You should have received a copy of the GNU General Public License along
#    with this program; if not, write to the Free Software Foundation, Inc., 59
#    Temple Place, Suite 330, Boston, MA 02111-1307 USA

# debian postinst is going to fail when not set'ting +e
set +e

# CentOS moves utils like pidof to /sbin so we have to append it to $PATH if
# not already contained
[[ "$PATH" =~ (^|:)/sbin:* ]] || PATH=${PATH}:/sbin

JAVA_BIN=

ox_set_JAVA_BIN() {
    JAVA_BIN=$(which java)
    if [ -z "$JAVA_BIN" ]; then
        local jb=$JAVA_HOME/bin/java
        if [ -x $jb ]; then
            JAVA_BIN=$jb
        fi
    fi
    if [ -z "$JAVA_BIN" ]; then
        local jb=$JRE_HOME/bin/java
        if [ -x $jb ]; then
            JAVA_BIN=$jb
        fi
    fi
    test -x $JAVA_BIN || die "$0: unable to get path to java vm"
    version=$(detect_java_version)
    if [ $version -lt 7 ]; then
      JAVA_BIN=/opt/open-xchange/sbin/insufficientjava
    fi
}

# Detect the version of the selected JVM
#
# Pre JEP 223:
# JVMs output e.g: java version "1.7.0_80" as part of their version
# specification. From this line we simply extract the minor version which would
# be 7 in this case.
#
# Post JEP 223:
# JVMs output e.g: java version "9-ea", "9" or "9.0.1" as part of their version
# specification. From this line we simply extract the major version which would
# be 9 in this case.
#
# Returns the detected version or -1 if it can't be detected
function detect_java_version () {
    version_line_array=( $($JAVA_BIN -version 2>&1 | grep version) )
    unquoted_version=${version_line_array[2]//\"/}
    version=-1
    if [[ "$unquoted_version" =~ ^1\..* ]]  
    then
        version_components=( ${unquoted_version//./ } )
        version=${version_components[1]}
    elif [[ "$unquoted_version" =~ ^[1-9]([0-9])*-ea$ ]]  
    then
        version_components=( ${unquoted_version//./ } )
        version=${unquoted_version//-ea/}
    elif [[ "$unquoted_version" =~ ^[1-9]([0-9])*(\..*)* ]]  
    then
        version_components=( ${unquoted_version//./ } )
        version=${version_components[0]}
    fi
    echo $version
}

DEBIAN=1
REDHAT=2
SUSE=4
LSB=8
UCS=16
ox_system_type() {
    local ret=0
    local isucs=$(uname -r|grep ucs)
    if [ -f /etc/debian_version ] && [ -z "$isucs" ]; then
        ret=$(( $ret | $DEBIAN ))
    elif [ -n "$isucs" ]; then
        ret=$(( $ret | $UCS))
    elif [ -f /etc/SuSE-release ]; then
        ret=$(( $ret | $SUSE ))
        ret=$(( $ret | $LSB ))
    elif [ -f /etc/redhat-release ]; then
        ret=$(( $ret | $REDHAT ))
        ret=$(( $ret | $LSB ))
    fi
    return $ret
}

# init script stuff

ox_start_daemon() {
    local path="$1"
    local name="$2"
    local user="$3"
    local group="$4"
    test -z "$path" && die "ox_start_daemon: missing path argument (arg 1)"
    test -x $path   || die "ox_start_daemon: $path is not executable"
    test -z "$name" && die "ox_start_daemon: missing name argument (arg 2)"
    local runasuser=
    test -n "$user"   && runasuser="--chuid $user"
    local runasgroup=
    test -n "$group"  && runasgroup="--group $group"
    ox_system_type
    local type=$?
    if [ $type -eq $DEBIAN -o $type -eq $UCS ]; then
        start-stop-daemon $runasuser $runasgroup --background --start --oknodo --startas $path --make-pidfile --pidfile /var/run/${name}.pid
    elif [ $(( $type & $LSB )) -eq $LSB ]; then
        if [ -n "$user" ] && [ "$user" != "root" ]; then
            su -s /bin/bash $user -c $path > /dev/null 2>&1 & echo $! > /var/run/${name}.pid
        else
            $path > /dev/null 2>&1 & echo $! > /var/run/${name}.pid
        fi
    else
        die "Unable to handle unknown system type"
    fi
}

ox_is_running() {
    local name="$1"
    local pattern="$2"
    local pid="$3"
    test -z "$name" && die "ox_is_running: missing name argument (arg 1)"
    test -z "$pattern" && die "ox_is_running: missing pattern argument (arg 2)"

    if [ -z "$pid" ]; then
       if [ -e /var/run/${name}.pid ]; then
          read pid < /var/run/${name}.pid
       fi
    fi
    if [ -n "$pid" ]; then
        # take care nothing influences line length if ps output
        COLUMNS=1000
        if ps $pid | grep "$pattern" > /dev/null; then
           return 0
        else
           return 1
        fi
    else
        return 1
    fi
}

ox_stop_daemon() {
    local name="$1"
    local nonox="$2"
    test -z "$name" && die "ox_stop_daemon: missing name argument (arg 1)"
    ox_system_type
    local type=$?

    if [ ! -f /var/run/${name}.pid ]; then
        return 0
    fi
    read PID < /var/run/${name}.pid
    test -z "$PID" && { echo "No process in pidfile '/var/run/${name}.pid' found running; none killed."; return 1; }
    if [ -z "$nonox" ]; then
        ps $PID > /dev/null && /opt/open-xchange/sbin/shutdown -w > /dev/null 2>&1
    fi
    ps $PID > /dev/null && kill -QUIT $PID
    ps $PID > /dev/null && kill -TERM $PID
    rm -f /var/run/${name}.pid
}

ox_daemon_status() {
    local pidfile="$1"
    test -z "$pidfile" && die "ox_daemon_status: missing pidfile argument (arg 1)"
    if [ ! -f $pidfile ]; then
        # not running
        return 1
    fi
    read PID < $pidfile
    running=$(ps $PID | grep $PID)
    if [ -n "$running" ]; then
        # running
        return 0
    else
        # not running
        return 1
    fi
}

# usage:
# ox_set_property property value /path/to/file
#
ox_set_property() {
    local prop="$1"
    local val="$2"
    local propfile="$3"
    test -z "$prop"     && die "ox_set_property: missing prop argument (arg 1)"
    test -z "$propfile" && die "ox_set_property: missing propfile argument (arg 3)"
    test -e "$propfile" || die "ox_set_property: $propfile does not exist"
    local tmp=${propfile}.tmp$$
    cp -a --remove-destination $propfile $tmp

    ox_system_type
    local type=$?
    if [ $type -eq $DEBIAN -o $type -eq $UCS ]; then
        local origfile="${propfile}.dpkg-new"
        if [ ! -e $origfile ]; then
            local origfile="${propfile}.dpkg-dist"
        fi
    else
        local origfile="${propfile}.rpmnew"
    fi
    if [ -n "$origfile" ] && [ -e "$origfile" ]; then
        export origfile
        export propfile
        export prop
        export val

        perl -e '
use strict;

open(IN,"$ENV{origfile}") || die "unable to open $ENV{origfile}: $!";
open(OUT,"$ENV{propfile}") || die "unable to open $ENV{propfile}: $!";

my @LINES = <IN>;
my @OUTLINES = <OUT>;

my $opt = $ENV{prop};
my $val = $ENV{val};
my $count = 0;
my $back  = 1;
my $out = "";
foreach my $line (@LINES) {
    if ( $line =~ /^$opt\s*[:=]/ ) {
      $out = $line;
      $out =~ s/^(.*?[:=]).*$/$1$val/;
      while ( $LINES[$count-$back] =~ /^#/ ) {
          $out = $LINES[$count-$back++].$out;
      }
    }
    $count++;
}

$back  = 0;
$count = 0;

# either the line where the comments above the property start or the line where
# the matching property was found (end)
my $start = 0;

# the line where we found the matching property
my $end = 0;

# > 0 if found
my $found = 0;
foreach my $line (@OUTLINES) {
    # we can not properly match commented out properties, they might be contained
    # in comments themselves
    if ( $line =~ /^$opt\s*[:=]/ ) {
        # we got a match
        $found=1;

        # set end to the line where we found the match
        $end=$count;

        # increase back while lines above are comments
        while ( $OUTLINES[$count-++$back] =~ /^#/ ) {
        }
        ;
        # if we found at least one comment line start at the comments otherwise
        # start at the property
        if ( $count > 0 && $back > 1 ) {
            $start=$count-$back+1;
        } else {
            $start=$end;
        }
    }
    $count++;
}

#if we did not find the property set it to provided values
if ( length($out) == 0 ) {
    $out=$opt."=".$val."\n";
}

if ( $found ) {
    for (my $i=0; $i<=$#OUTLINES; $i++) {
        if ( $i < $start || $i > $end ) {
            print $OUTLINES[$i];
            print "\n" if( substr($OUTLINES[$i],-1) ne "\n" );
        }
        if ( $i == $start ) {
            # add newline unless first line or line above is emtpy
            if ($i > 0 && $OUTLINES[$i-1] !~ /^\s*$/) {
              print "\n";
            }
            print $out;
            print "\n" if( substr($OUTLINES[$i],-1) ne "\n" );
        }
    }
} else {
    print @OUTLINES;
    print "\n" if( substr($OUTLINES[-1],-1) ne "\n" );
    # add newline unless line above is emtpy
    if ($OUTLINES[-1] !~ /^\s*$/) {
      print "\n";
    }
    print $out;
    print "\n";
}
' > $tmp
        if [ $? -gt 0 ]; then
            rm -f $tmp
            die "ox_set_property: FATAL: error setting property $prop to \"$val\" in $propfile"
        else
            mv $tmp $propfile
        fi
        unset origfile
        unset propfile
        unset prop
        unset val
    else
        # quote & in URLs to make sed happy
        test -n "$val" && val="$(echo $val | sed 's/\&/\\\&/g')"
        if grep -E "^$prop *[:=]" $propfile >/dev/null; then
            cat<<EOF | sed -f - $propfile > $tmp
s;\(^$prop[[:space:]]*[:=]\).*$;\1${val};
EOF
        else
        # add a newline to the last line if it doesn't exist
        sed -i -e '$a\' $tmp
            echo "${prop}=$val" >> $tmp
        fi
        if [ $? -gt 0 ]; then
            rm -f $tmp
            die "ox_set_property: FATAL: error setting property $prop to \"$val\" in $propfile"
        else
            mv $tmp $propfile
        fi
    fi
}

# usage:
# ox_exists_property property /path/to/file
#
ox_exists_property() {
    local prop="$1"
    local propfile="$2"
    test -z "$prop"     && die "ox_exists_property: missing prop argument (arg 1)"
    test -z "$propfile" && die "ox_exists_property: missing propfile argument (arg 2)"
    test -e "$propfile" || die "ox_exists_property: $propfile does not exist"

    local escaped=$(sed 's/[]\.|$(){}?+*^[]/\\&/g' <<< "$prop")
    grep -E "^$escaped *[:=]" $propfile >/dev/null || return 1
}

# savely find key/val in keys and values containing all kind of ugly chars
# delimiter must be either = or :
save_read_prop() {
    export prop="$1"
    export propfile="$2"
    perl -e '
use strict;

my $file=$ENV{"propfile"};
my $search=$ENV{"prop"};
open(FILE,$file) || die "unable to open $file: $!";
my $val=undef;
while(<FILE>) {
    chomp;
    my $len=length($search);
    if( substr($_,0,$len) eq $search ) {
        if( substr($_,$len,$len+1) !~ /^[\s=:]/ ) {
           next;
        }
        foreach my $dl ( "=", ":" ) {
           my $idx=index($_,$dl);
           if( $idx >= $len ) {
              $val=substr($_,$idx+1);
           }
           last if defined($val);
        }
        last;
    }
}
print "$val\n";

close(FILE);
'
}

# usage:
# ox_read_property property /path/to/file
#
ox_read_property() {
    local prop="$1"
    local propfile="$2"
    test -z "$prop"     && die "ox_read_property: missing prop argument (arg 1)"
    test -z "$propfile" && die "ox_read_property: missing propfile argument (arg 2)"
    test -e "$propfile" || die "ox_read_property: $propfile does not exist"

    # sed -n -e "/^$prop/Is;^$prop *[:=]\(.*\).*$;\1;p" < $propfile
    # UGLY: we have keys containing /
    save_read_prop "$prop" "$propfile"
}

# usage:
# ox_remove_property property /path/to/file
#
ox_remove_property() {
    local prop="$1"
    local propfile="$2"
    test -z "$prop"     && die "ox_remove_property: missing prop argument (arg 1)"
    test -z "$propfile" && die "ox_remove_property: missing propfile argument (arg 2)"
    test -e "$propfile" || die "ox_remove_property: $propfile does not exist"

    local tmp=${propfile}.tmp$$
    cp -a --remove-destination $propfile $tmp

    export propfile
    export prop
    perl -e '
use strict;

open(IN,"$ENV{propfile}") || die "unable to open $ENV{propfile}: $!";

my @LINES = <IN>;

my $opt = $ENV{prop};
my $count = 0;
my $back  = 1;
my $start = 0;
my $end = 0;
foreach my $line (@LINES) {
    if ( $line =~ /^$opt\s*[:=]/ ) {
        $end=$count;
        while ( $LINES[$count-$back++] =~ /^#/ ) {
        }
        $start=$count-$back;
    }
    $count++;
}
if ( $LINES[$end+1] =~ /^\s*$/ ) {
    $end++;
}
for (my $i=0; $i<=$#LINES; $i++) {
    if ( $i <= $start+1 || $i > $end ) {
        print $LINES[$i];
    }
}
' > $tmp
    if [ $? -gt 0 ]; then
        rm -f $tmp
        die "ox_remove_property: FATAL: error removing property $prop from $propfile"
    else
        mv $tmp $propfile
    fi
    unset propfile
    unset prop
}

# adding or removing comment (ONLY # supported)
#
# usage:
# ox_comment property action /path/to/file
# where action can be add/remove
#
ox_comment(){
    local prop="$1"
    local action="$2"
    local propfile="$3"
    test -z "$prop"     && die "ox_comment: missing prop argument (arg 1)"
    test -z "$action"      && die "ox_comment: missing action argument (arg 2)"
    test -z "$propfile" && die "ox_comment: missing propfile argument (arg 3)"
    test -e "$propfile" || die "ox_comment: $propfile does not exist"
    local tmp=${propfile}.tmp$$
    local prop_in=$(quote_s_in $prop)
    local prop_re=$(quote_s_re $prop)
    cp -a --remove-destination $propfile $tmp
    if [ "$action" == "add" ]; then
        sed "s/^$prop_in/# $prop_re/" < $propfile > $tmp;
        if [ $? -gt 0 ]; then
            rm -f $tmp
            die "ox_comment: FATAL: could not add comment in file $propfile to $prop"
        else
            mv $tmp $propfile
        fi
    elif [ "$action" == "remove" ];then
      sed "s/^#[ ]*\($prop_in[ ]*=\)/\1/" < $propfile > $tmp;
        if [ $? -gt 0 ]; then
            rm -f $tmp
            die "ox_comment: FATAL: could not remove comment in file $propfile for $prop"
        else
            mv $tmp $propfile
        fi
    else
        die "ox_handle_hash: action must be add or remove while it is $action"
    fi
}

ox_update_permissions(){
    local pfile="$1"
    local owner="$2"
    local mode="$3"
    test -z "$pfile" && die "ox_update_permissions: missing pfile argument"
    test -z "$owner" && die "ox_update_permissions: missing owner argument"
    test -z "$mode" && die "ox_update_permissions: missing mode argument"
    test -e "$pfile" || die "ox_update_permissions: $pfile does not exist"

    chmod $mode "$pfile"
    chown $owner "$pfile"
}

die() {
    test -n "$1" && echo 1>&2 "$1" || echo 1>&2 "ERROR"
    exit 1
}

ox_update_config_init() {
    local cini=$1
    local cinitemplate=$2
    local bdir=$3

    test -z "$cini" && die \
        "ox_update_config_init: missing config.ini argument (arg 1)"
    test -z "$cinitemplate" && die \
        "ox_update_config_init: missing config.ini template argument (arg 2)"
    test -z "$bdir" && die \
        "ox_update_config_init: missing bundle.d argument (arg 3)"

    test -d $bdir || die "$bdir is not a directory"
    test -f $cinitemplate || die "$cinitemplate does not exist"
    test "$(echo $bdir/*.ini)" == "$bdir/*.ini" && die "$bdir is empty"

    # read all installed bundles into an array
    local dirbundles=()
    local bpath=
    for bundle in $bdir/*.ini; do
        read bpath < $bundle
        dirbundles=( ${dirbundles[*]} "reference\:file\:${bpath}" )
    done

    if [ -f $cini ]; then
        # read all bundles listed in config.ini into an array
        local configbundles=( $(sed -e \
            '/^osgi.bundles.*/Is;^osgi.bundles=\(.*\);\1;' \
            -n -e 's;,; ;gp' < $cini ) )
    fi

    cp $cinitemplate $cini
    echo "osgi.bundles=$(echo ${dirbundles[@]} | sed 's; ;,;g')" >> $cini
}

ox_save_backup() {
    local name=$1
    test -z "$name" && die "ox_save_backup: missing name argument (arg1)"

    local backup_name="${name}.old"
    if [ -e $name ]; then
        mv $name $backup_name
    fi
}

# move configuration file from one location/package to another
# RPM ONLY!
ox_move_config_file() {
    local srcdir="$1"
    local dstdir="$2"
    local srcname="$3"
    local dstname="$4"
    test -z "$srcdir" && die "ox_move_config_file: missing srcdir argument (arg1)"
    test -z "$dstdir" && die "ox_move_config_file: missing dstdir argument (arg2)"
    test -z "$srcname" && die "ox_move_config_file: missing srcname argument (arg3)"
    test -z "$dstname" && dstname=$srcname

    if [ -e "${srcdir}/${srcname}" ]; then
        if [ -e "${dstdir}/${dstname}" ] && \
           ! cmp -s "${dstdir}/${dstname}" "${srcdir}/${srcname}" > /dev/null; then
           mv "${dstdir}/${dstname}" "${dstdir}/${dstname}.rpmnew"
        fi
        mv "${srcdir}/${srcname}" "${dstdir}/${dstname}"
    fi
}

# kill all leftover readerengine instances from a previous start
ox_kill_readerengine_instances() {
    local programname="soffice.bin"

    for PID in $(pidof ${programname}); do
        if ! ps ${PID} > /dev/null; then
            return 0
        fi

        kill -KILL ${PID}
    done

    rm -f /tmp/OSL_PIPE_*
}

# ox_add_property property value /path/to/file
# verifies first that the property does not already exist in file and adds it then
ox_add_property() {
    local property="$1"
    local value="$2"
    local propfile="$3"
    test -z "$property" && die "ox_add_property: missing property argument (arg 1)"
    test -z "$propfile" && die "ox_add_property: missing propfile argument (arg 3)"
    test -e "$propfile" || die "ox_add_property: $propfile does not exist"

    if ! ox_exists_property "$property" "$propfile"
    then
        ox_set_property "$property" "$value" "$propfile"
    fi
}

# quote for sed s-command input as in: s/input/replacement/
# by prefixing each character of the character set "]\/$*.^|[" with a "\"
# and thus escaping them
quote_s_in () {
  sed -e 's/[]\/$*.^|[]/\\&/g' <<< "$1"
}

# quote for sed s-command replacement as in: s/input/replacement/
# by prefixing "\", "/" and "&" with a "\" and thus escaping 
#the backslash itself, the default s-command separator and the matched string
quote_s_re () {
  sed -e 's/[\/&]/\\&/g' <<< "$1"
}
#
#
#开放式交换法律信息
#
#软件中的所有知识产权受
#国际版权法。
#
#
#在一些国家,OX、OX开放交换、开放交换和OX投标
#以及相应的标识OX Open Xchange和OX已注册
#OX Software GmbH集团公司的商标。
#GNU通用公共许可证不包括徽标的使用。
#相反,您可以根据条款和要求使用这些徽标
#知识共享许可证条件,2.5版,归属,
#非商业性、类似股份和术语的解释
#发布了适用于上述许可证的非商业许可证
#在网站上http://www.open-xchange.com/EN/legal/index.html.
#
#请确保使用了第三方模块和库
#根据各自的许可证。
#
#对本软件包的任何修改必须保留所有版权声明
#所使用的原始代码的原始版权持有人。
#
#任何此类修改后,原代码和衍生代码应保持不变
#版权所有人和/或原作者根据
#归属和转让协议,可位于
#   http://www.open-xchange.com/EN/developer/. 撰稿人应为:
#衍生代码和许可证授予使用的给定属性。
#
#版权所有(C)2016-2020 OX软件有限公司
#邮寄:info@open-xchange.com
#
#
#这个程序是自由软件;您可以重新分发和/或修改它
#根据GNU通用公共许可证的条款,发布的第2版
自由软件基金会。
#
#这个程序的发布是希望它会有用,但是
#无任何保证;甚至没有对适销性的默示保证
#或适合某一特定目的。请参阅GNU通用公共许可证
#更多细节。
#
#您应该已经收到了GNU通用公共许可证的副本
#有了这个节目,;如果没有,请写信给自由软件基金会,59
#美国马萨诸塞州波士顿市坦普尔广场330室02111-1307
#如果不设置'ting+e',debian postinst将失败
set+e
#CentOS将pidof之类的UTIL移动到/sbin,因此如果
#尚未包含
[[“$PATH”=~(^ |:)/sbin:][]| | PATH=${PATH}:/sbin
渣华斌=
ox_set_JAVA_BIN(){
JAVA_BIN=$(哪个JAVA)
如果[-z“$JAVA_BIN”];则
本地jb=$JAVA_HOME/bin/JAVA
如果[-x$jb];则
JAVA_BIN=$jb
fi
fi
如果[-z“$JAVA_BIN”];则
本地jb=$JRE_HOME/bin/java
如果[-x$jb];则
JAVA_BIN=$jb
fi
fi
test-x$JAVA_BIN | | die“$0:无法获取到JAVA虚拟机的路径”
版本=$(检测java版本)
如果[$version-lt 7];则
JAVA_BIN=/opt/open-xchange/sbin/insufficientjava
fi
}
#检测所选JVM的版本
#
#JEP223之前:
#JVM输出,例如:java版本“1.7.0_80”作为其版本的一部分
#规格。从这一行中,我们只提取次要版本
#在这种情况下是7。
#
#JEP223之后:
#JVM输出例如:java版本“9-ea”、“9”或“9.0.1”作为其版本的一部分
#规格。从这一行中,我们只提取主要版本
#在这种情况下是9。
#
#返回检测到的版本,如果无法检测,则返回-1
函数检测java版本(){
version_line_array=($($JAVA_BIN-version 2>&1 | grep version))
unquoted\u version=${version\u line\u数组[2]/\“/}
版本=-1
如果[[“$unquoted_version”=~^1\..*]
然后
version_components=(${unquoted_version/./})
版本=${version\u组件[1]}
elif[“$unquoted_version”=~^[1-9]([0-9])*-ea$]]
然后
version_components=(${unquoted_version/./})
版本=${unquoted_version//-ea/}
elif[[“$unquoted\u version”=~^[1-9]([0-9])*(\..*)*]
然后
version_components=(${unquoted_version/./})
版本=${version\u组件[0]}
fi
echo$版本
}
DEBIAN=1
红帽=2
SUSE=4
LSB=8
UCS=16
ox_系统_类型(){
本地ret=0
本地isucs=$(uname-r | grep ucs)
如果[-f/etc/debian_version]&&[-z“$isucs”];则
ret=$($ret |$DEBIAN))
elif[-n“$isucs”];然后
ret=$($ret |$UCS))
elif[-f/etc/SuSE release];然后
ret=$($ret |$SUSE))
ret=$($ret |$LSB))
elif[-f/etc/redhat release];然后
ret=$($ret |$REDHAT))
ret=$($ret |$LSB))
fi
返回$ret
}
#初始化脚本的东西
ox_启动_守护进程(){
本地路径=“$1”
本地名称=“$2”
本地用户=“3美元”
本地组=“$4”
test-z“$path”和&die“ox_start_守护进程:缺少路径参数(arg 1)”
测试-x$path | | die“ox_start_守护程序:$path不可执行”
测试-z“$name”和&die“ox_start_守护进程:缺少名称参数(arg 2)”
本地runasuser=
测试-n“$user”和&runasuser=“--chuid$user”
本地runasgroup=
测试-n“$group”和&runasgroup=“--group$group”
ox_系统_类型
本地类型=$?
如果[$type-eq$DEBIAN-o$type-eq$UCS];则
start-stop守护程序$runasuser$runasgroup--background--start--oknodo--startas$path--make-pidfile--pidfile/var/run/${name}.pid
elif[$($type&$LSB))-eq$LSB];然后
如果[-n“$user”]&&[“$user”!=“root”];则
su-s/bin/bash$user-c$path>/dev/null 2>&1&echo$!>/var/run/${name}.pid
其他的
$path>/dev/null 2>&1&echo$!>/var/run/${name}.pid
fi
其他的
die“无法处理未知的系统类型”
fi
}
牛在跑{
本地名称=“$1”
本地模式=“2美元”
本地pid=“$3”
测试-z“$name”和&die“ox_正在运行:缺少name参数(arg 1)”
测试-z“$pattern”
/opt/open-xchange/sbin/oxinstaller --add-license=YOUR-OX-LICENSE-CODE \
--servername=oxserver --configdb-pass=db_password \
--master-pass=admin_master_password --network-listener-host=localhost --servermemory MAX_MEMORY_FOR_JAVAVM
/opt/open-xchange/sbin/registerserver -n oxserver -A oxadminmaster -P admin_master_password