The Unified and Autonomous Development Platform
chore: Use onedev wrapper instead of JSW for service wrapping
Robin Shenc50f2107fe13
diff --git a/.gitignore b/.gitignoreindex 63290dda41..3efefafacc 100644--- a/.gitignore+++ b/.gitignore@@ -2,6 +2,9 @@ server-product/docker/build/server-product/docker/onedev-*/target/bin/+# Prepared wrapper launchers are release inputs, not IDE output directories.+!server-product/wrapper/distribution/**/bin/+!server-product/wrapper/distribution/**/bin/****/.classpath**/.gitignore**/.settingsdiff --git a/pom.xml b/pom.xmlindex 15f2fd3fd7..01b38be222 100644--- a/pom.xml+++ b/pom.xml@@ -56,7 +56,7 @@<plugin><groupId>io.onedev</groupId><artifactId>plugin-maven</artifactId>- <version>2.9.0</version>+ <version>2.9.1</version><executions><execution><?m2e execute onConfiguration,onIncremental?>@@ -718,8 +718,8 @@</repository></repositories><properties>- <commons.version>4.2.8</commons.version>- <agent.version>3.3.8</agent.version>+ <commons.version>4.2.9</commons.version>+ <agent.version>3.3.9</agent.version><slf4j.version>2.0.17</slf4j.version><logback.version>1.5.33</logback.version><antlr.version>4.13.2</antlr.version>diff --git a/server-core/src/main/java/io/onedev/server/OneDev.java b/server-core/src/main/java/io/onedev/server/OneDev.javaindex b796de6d30..4a4835d410 100644--- a/server-core/src/main/java/io/onedev/server/OneDev.java+++ b/server-core/src/main/java/io/onedev/server/OneDev.java@@ -105,7 +105,7 @@ public class OneDev extends AbstractPlugin implements Serializable, Runnable {public OneDev() {try {- wrapperManagerClass = Class.forName("org.tanukisoftware.wrapper.WrapperManager");+ wrapperManagerClass = Class.forName("io.onedev.wrapper.WrapperManager");} catch (ClassNotFoundException ignored) {}thread = new Thread(this);diff --git a/server-core/src/main/java/io/onedev/server/commandhandler/Upgrade.java b/server-core/src/main/java/io/onedev/server/commandhandler/Upgrade.javaindex 49d3727a73..5f0e5c24d1 100644--- a/server-core/src/main/java/io/onedev/server/commandhandler/Upgrade.java+++ b/server-core/src/main/java/io/onedev/server/commandhandler/Upgrade.java@@ -985,6 +985,9 @@ public class Upgrade extends AbstractPlugin {try {File wrapperConfFile = new File(upgradeDir, "conf/wrapper.conf");String wrapperConf = FileUtils.readFileToString(wrapperConfFile, UTF_8);+ wrapperConf = wrapperConf.replaceAll(+ "(?m)^(\\h*wrapper\\.java\\.mainclass\\h*=\\h*)[\\w.]+\\.WrapperSimpleApp\\h*$",+ "$1io.onedev.wrapper.WrapperSimpleApp");wrapperConf = Strings.CS.replace(wrapperConf, "com.gitplex.commons.bootstrap.Bootstrap","io.onedev.commons.launcher.bootstrap.Bootstrap");wrapperConf = Strings.CS.replace(wrapperConf, "com.gitplex.launcher.bootstrap.Bootstrap",@@ -1149,8 +1152,6 @@ public class Upgrade extends AbstractPlugin {writeStringToFile(logbackConfigFile, logbackConfig, UTF_8);- FileUtils.copyFile(new File(Bootstrap.installDir, "conf/wrapper-license.conf"),- new File(upgradeDir, "conf/wrapper-license.conf"));FileUtils.copyFile(new File(Bootstrap.installDir, "readme.txt"), new File(upgradeDir, "readme.txt"));FileUtils.copyFile(new File(Bootstrap.installDir, "license.txt"), new File(upgradeDir, "license.txt"));FileUtils.copyFile(new File(Bootstrap.installDir, RELEASE_PROPS_FILE), new File(upgradeDir, RELEASE_PROPS_FILE));diff --git a/server-plugin/server-plugin-archetype/src/main/resources/archetype-resources/pom.xml b/server-plugin/server-plugin-archetype/src/main/resources/archetype-resources/pom.xmlindex 7cd9c5eff9..81383a152d 100644--- a/server-plugin/server-plugin-archetype/src/main/resources/archetype-resources/pom.xml+++ b/server-plugin/server-plugin-archetype/src/main/resources/archetype-resources/pom.xml@@ -33,7 +33,7 @@<plugin><groupId>io.onedev</groupId><artifactId>plugin-maven</artifactId>- <version>2.9.0</version>+ <version>2.9.1</version><executions><execution><?m2e execute onConfiguration,onIncremental?>diff --git a/server-product/docker/entrypoint-server.sh b/server-product/docker/entrypoint-server.shindex 3a7f1c7131..822cc872c4 100755--- a/server-product/docker/entrypoint-server.sh+++ b/server-product/docker/entrypoint-server.sh@@ -19,7 +19,7 @@ elseCPUARCH="x86-64"fi-/app/boot/wrapper-linux-$CPUARCH /app/conf/wrapper.conf -- upgrade /opt/onedev &+/app/boot/wrapper-linux-$CPUARCH /app/conf/wrapper.conf wrapper.restart.disabled=TRUE -- upgrade /opt/onedev &child=$!wait "$child"diff --git a/server-product/jsw/App.sh.in b/server-product/jsw/App.sh.indeleted file mode 100644index c41bfc1685..0000000000--- a/server-product/jsw/App.sh.in+++ /dev/null@@ -1,3139 +0,0 @@-#! /bin/sh--#-# Copyright (c) 1999, 2022 Tanuki Software, Ltd.-# http://www.tanukisoftware.com-# All rights reserved.-#-# This software is the proprietary information of Tanuki Software.-# You shall use it only in accordance with the terms of the-# license agreement you entered into with Tanuki Software.-# http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html-#-# Java Service Wrapper sh script. Suitable for starting and stopping-# wrapped Java applications on UNIX platforms.-# Optimized for use with version 3.5.51-st of the Wrapper.-#--#------------------------------------------------------------------------------# These settings can be modified to fit the needs of your application--# IMPORTANT - Please always stop and uninstall an application before making-# any changes to this file. Failure to do so could remove the-# script's ability to control the application.--# NOTE - After loading the variables below, the script will attempt to locate a-# file with the same basename as this script and having a '.shconf' extension.-# If such file exists, it will be executed giving the user a chance to-# override the default settings. Having the customized configuration in a-# separate '.shconf' file makes it easier to upgrade the Wrapper, as the-# present script file can then be replaced with minimal changes (although at-# least the 'INIT INFO' below needs to be updated).--# Initialization block for the install_initd and remove_initd scripts used by-# SUSE linux, CentOS and RHEL distributions. Also used by update-rc.d.-# Note: From CentOS 6, make sure the BEGIN INIT INFO section is before any line-# of code otherwise the service won't be displayed in the Service-# Configuration GUI.-### BEGIN INIT INFO-# Provides: @app.name@-# Required-Start: $remote_fs $syslog-# Should-Start: $network $time-# Should-Stop: $network $time-# Required-Stop: $remote_fs $syslog-# Default-Start: 2 3 4 5-# Default-Stop: 0 1 6-# Short-Description: @app.long.name@-# Description: @app.description@-### END INIT INFO--# Application name and long name: If these variables are not set (or left to-# the default tokens), APP_NAME will default to the name of the script, then-# APP_LONG_NAME will default to the value of APP_NAME.-APP_NAME="@app.name@"-APP_LONG_NAME="@app.long.name@"--# If uncommented (and set to false), APP_NAME and APP_LONG_NAME will no longer-# be passed to the wrapper. See documentation for details.-#APP_NAME_PASS_TO_WRAPPER=false--# Wrapper-WRAPPER_CMD="../boot/wrapper"-WRAPPER_CONF="../conf/wrapper.conf"--# Priority at which to run the wrapper. See "man nice" for valid priorities.-# nice is only used if a priority is specified.-PRIORITY=--# Location of the pid file.-PIDDIR="."--# PIDFILE_CHECK_PID tells the script to double check whether the pid in the pid-# file actually exists and belongs to this application. When not set, only-# check the pid, but not what it is. This is only needed when multiple-# applications need to share the same pid file.-PIDFILE_CHECK_PID=true--# FIXED_COMMAND tells the script to use a hard coded action rather than-# expecting the first parameter of the command line to be the command.-# By default the command will be expected to be the first parameter.-@set_fixed_command@--# PASS_THROUGH controls how the script arguments should be passed to the-# Wrapper. Possible values are:-# - commented or 'false': the arguments will be ignored (not passed).-# - 'app_args' or 'true': the arguments will be passed through the Wrapper as-# arguments for the Java Application.-# - 'both': both Wrapper properties and Application arguments can be passed to-# the Wrapper. The Wrapper properties come in first position. The-# user can optionally add a '--' separator followed by application-# arguments.-# NOTE - If FIXED_COMMAND is set to true the above applies to all arguments,-# otherwise it applies to arguments starting with the second.-# NOTE - Passing arguments is only valid with the following commands:-# - 'console'-# - 'start', 'restart', 'condrestart' (if not installed as a daemon)-@set_pass_through@--# If uncommented, causes the Wrapper to be shutdown using an anchor file.-# When launched with the 'start' command, it will also ignore all INT and-# TERM signals.-#IGNORE_SIGNALS=true--# Wrapper will start the JVM asynchronously. Your application may have some-# initialization tasks and it may be desirable to wait a few seconds-# before returning. For example, to delay the invocation of following-# startup scripts. Setting WAIT_AFTER_STARTUP to a positive number will-# cause the start command to delay for the indicated period of time-# (in seconds).-WAIT_AFTER_STARTUP=0--# If set, wait for the wrapper to report that the daemon has started-WAIT_FOR_STARTED_STATUS=true-WAIT_FOR_STARTED_TIMEOUT=120--# If set, the status, start_msg and stop_msg commands will print out detailed-# state information on the Wrapper and Java processes.-#DETAIL_STATUS=true--# If set, the 'pause' and 'resume' commands will be enabled. These make it-# possible to pause the JVM or Java application without completely stopping-# the Wrapper. See the wrapper.pausable and wrapper.pausable.stop_jvm-# properties for more information.-#PAUSABLE=true--# Set the mode used to 'pause' or 'resume' the Wrapper. Possible values are-# 'signals' which uses SIGUSR1 and SIGUSR2, and 'file' which uses the command-# file to communicate these actions. The default value is 'signals'.-# Be aware that depending on the mode, the properties wrapper.signal.mode.usr1,-# wrapper.signal.mode.usr2, or wrapper.commandfile of the configuration file may-# be overriden.-#PAUSABLE_MODE=signals--# If set, the Wrapper will be run as the specified user.-# IMPORTANT - Make sure that the user has the required privileges to write-# the PID file and wrapper.log files. Failure to be able to write the log-# file will cause the Wrapper to exit without any way to write out an error-# message.-# NOTES - This will set the user which is used to run the Wrapper as well as-# the JVM and is not useful in situations where a privileged resource or-# port needs to be allocated prior to the user being changed.-# - Setting this variable will cause stdin to be closed. While this-# should not be a problem when running as Daemon, it would disable ability-# for console applications to receive inputs.-#RUN_AS_USER=--# When RUN_AS_USER is set, the 'runuser' command will be used to substitute the-# user. If not present on the machine, 'su' will be used as a fallback.-# The parameter below lets you specify option(s) for the 'runuser' (or 'su')-# command.-# NOTES - The '-u' option is not allowed. Please set the user with RUN_AS_USER.-# - On GNU/Linux systems, if the user specified by RUN_AS_USER doesn't-# have a default shell please specify one with the '-s' option.-#SU_OPTS="-s /bin/bash"--# By default we show a detailed usage block. Uncomment to show brief usage.-#BRIEF_USAGE=true--# Set which service management tool to use.-# Possible values are:-# for linux...: auto, systemd, upstart, initd-# for aix.....: auto, src, initd-# When set to 'auto', this script file will try to detect in the order of the-# list for each platform which service management tool to use to install the Wrapper.-SERVICE_MANAGEMENT_TOOL=auto--# Specify how the Wrapper daemon and its child processes should be killed-# when using systemd.-# The default is 'control-group' which tells systemd to kill all child-# processes (including detached ones) in the control group of the daemon-# when it stops.-# Alternatively, 'process' can be specified to prevent systemd from-# killing the child processes leaving this responsibility to the Wrapper.-# In this case child processes marked as 'detached' will not be killed on shutdown.-# NOTE - the daemon must be reinstalled for any changes on this property to take effect.-SYSTEMD_KILLMODE=control-group--# When installing on Mac OSX platforms, the following domain will be used to-# prefix the plist file name.-PLIST_DOMAIN=org.tanukisoftware.wrapper--# When installing on Mac OSX platforms, this parameter controls whether the daemon-# is to be kept continuously running or to let demand and conditions control the-# invocation.-MACOSX_KEEP_RUNNING="false"--# The following two lines are used by the chkconfig command. Change as is-# appropriate for your application. They should remain commented.-# chkconfig: 2345 20 80-# description: @app.long.name@--# Set run level to use when installing the application to start and stop on-# system startup and shutdown. It is important that the application always-# be uninstalled before making any changes to the run levels.-# It is also possible to specify different run levels based on the individual-# platform. When doing so this script will look for defined run levels in-# the following order:-# 1) "RUN_LEVEL_S_$DIST_OS" or "RUN_LEVEL_K_$DIST_OS", where "$DIST_OS" is-# the value of DIST_OS. "RUN_LEVEL_S_solaris=20" for example.-# 2) RUN_LEVEL_S or RUN_LEVEL_K, to specify specify start or stop run levels.-# 3) RUN_LEVEL, to specify a general run level.-RUN_LEVEL=20--# List of files to source prior to executing any commands. Use ';' as delimiter.-# For example:-# FILES_TO_SOURCE="/home/user/.bashrc;anotherfile;../file3"-FILES_TO_SOURCE=--# Do not modify anything beyond this point-#-------------------------------------------------------------------------------gettext() {- "$WRAPPER_CMD" --translate "$1" "$WRAPPER_CONF" 2>/dev/null- if [ $? != 0 ] ; then- echo "$1"- fi-}--checkIsRoot() {- if [ `id -u` != "0" ] ; then- IS_ROOT=false- else- IS_ROOT=true- fi-}--mustBeRootOrExit() {- checkIsRoot- if [ "$IS_ROOT" != "true" ] ; then- eval echo `gettext 'Must be root to perform this action.'`- exit 1- fi-}--##-# Normalize a dir path.-#-# $1: the name of the variable to set (without the $)-# $2: the path to normalize-normalizeDirPath() {- # NOTE: Variables are prefixed with 'ndp_' to avoid conflict with code- # outside this function. Keyword 'local' is not supported on some- # systems (z/OS, Solaris 10)- #- # Use '&&' to ensure pwd is only executed on an existing directory- ndp_normalDirPath=`unset CDPATH && cd "$2" 2>/dev/null && pwd`- ndp_ret=$?- if [ $ndp_ret -eq 0 ] ; then- eval "$1=$ndp_normalDirPath"- else- eval "$1=$2"- fi- return $ndp_ret-}--##-# Normalize a file path.-#-# $1: the name of the variable to set (without the $)-# $2: the path to normalize-normalizeFilePath() {- # NOTE: Variables are prefixed with 'nfp_' to avoid conflict with code- # outside this function. Keyword 'local' is not supported on some- # systems (z/OS, Solaris 10)- nfp_dirPath=`dirname "$2"`- normalizeDirPath nfp_normalDirPath $nfp_dirPath- nfp_ret=$?- if [ $nfp_ret -eq 0 ] ; then- nfp_fileName=`basename "$2"`- eval "$1=$nfp_normalDirPath/$nfp_fileName"- else- eval "$1=$2"- fi- return $nfp_ret-}--##-# Resolves the location of a system command.-#-# $1: the name of the variable to set (without the $)-# $2: the name of the command-# $3: an ordered and semicolon-separated list of paths where the command should-# be searched. The list should contain an empty value for the command to be-# searched using the PATH environment variable.-# $4: 1 to be strict (the script will stop with an error), 0 otherwise.-resolveLocation() {- eval "CMD_TEMP=\$$1"- if [ "X$CMD_TEMP" = "X" ] ; then- found=0-- OIFS=$IFS- IFS=';'- for CMD_PATH in $3- do- if [ -z "$CMD_PATH" ] ; then- # empty path- CMD_TEMP="$2"- ret=`command -v $CMD_TEMP 2>/dev/null`- if [ $? -eq 0 ] ; then- found=1- break- fi- else- CMD_TEMP="${CMD_PATH}/$2"- if [ -x "$CMD_TEMP" ] ; then- found=1- break- fi- fi- done- IFS=$OIFS-- if [ $found -eq 1 ] ; then- eval "$1=$CMD_TEMP"- elif [ $4 -eq 1 ] ; then- eval echo `gettext 'Unable to locate "$2".'`- eval echo `gettext 'Please report this message along with the location of the command on your system.'`- exit 1- else- # return the error- return 1- fi- fi- return 0-}--resolveIdLocation() {- # On Solaris, the version in /usr/xpg4/bin should be used in priority.- resolveLocation ID_BIN id "/usr/xpg4/bin;;/usr/bin" 1-}--resolveCurrentUser() {- if [ "X$CURRENT_USER" = "X" ] ; then- resolveIdLocation- CURRENT_USER=`$ID_BIN -u -n 2>/dev/null`- fi-}--validateRunUser() {- if [ "X$RUN_AS_USER" != "X" ]- then- resolveCurrentUser- if [ "$CURRENT_USER" = "$RUN_AS_USER" ]- then- # Already running as the configured user.- RUN_AS_USER=""- fi- fi- if [ "X$RUN_AS_USER" != "X" ]- then- # Make sure the user exists- if [ "`$ID_BIN -u -n "$RUN_AS_USER" 2>/dev/null`" != "$RUN_AS_USER" ]- then- eval echo `gettext 'User $RUN_AS_USER does not exist.'`- exit 1- fi-- # Make sure to be root when using RUN_AS_USER. This is required for runuser. For su, it is technically possible to use- # it with a normal user, but we are using the command several times so this would result in multiple password prompts.- checkIsRoot- if [ "$IS_ROOT" != "true" ] ; then- eval echo `gettext 'Must be root to run with RUN_AS_USER=$RUN_AS_USER.'`- exit 1- fi-- # Resolve the location of the 'runuser' command, or fall back on 'su' if it is not present.- resolveLocation RUNUSER_BIN runuser ";/sbin;/usr/sbin" 0- ret=$?- if [ $ret -eq 1 ] ; then- resolveLocation RUNUSER_BIN su ";/bin" 0- ret=$?- fi- if [ $ret -eq 1 ] ; then- eval echo `gettext 'Unable to locate the command to run with a substitute user.'`- exit 1- fi- fi-}--# Make sure APP_NAME is less than 14 characters, otherwise in AIX, the commands-# "lsitab" or "lssrc" will fail-validateAppNameLength() {- if [ ${#APP_NAME} -gt 14 ] ; then- eval echo `gettext ' APP_NAME must be less than 14 characters long. Length of ${APP_NAME} is ${#APP_NAME}.'`- exit 1- fi-}--# Method to check if systemd is running.-# Returns 0 if systemd is found, otherwise returns 1.-systemdDetection() {- if [ ! -d "/etc/systemd" ] ; then- return 1- fi-- resolveLocation PIDOF_BIN pidof ";/bin;/usr/sbin" 1- result=`$PIDOF_BIN systemd`- return $?-}--# Detect if upstart is installed-# Returns 0 if upstart is found, otherwise returns 1.-upstartDetection() {- if [ ! -d "/etc/init" ] ; then- return 1- fi-- INITCTL_BIN="initctl"- result=`command -v $INITCTL_BIN 2>/dev/null`- if [ $? -ne 0 ] ; then- INITCTL_BIN="/sbin/initctl"- if [ ! -x "$INITCTL_BIN" ] ; then- return 1- fi- fi-- result=`$INITCTL_BIN version 2>/dev/null`- if [ $? -eq 0 ] ; then- # if the word "upstart" is in the result, then we assume upstart is installed.- result=`echo $result | grep upstart`- if [ $? -eq 0 ] ; then- return 0- fi- fi-- # The command /sbin/initctl may fail if the user doesn't have enough privilege- # but that doesn't mean upstart is not present.- # In this case we can assume upstart exists if the service was previously- # installed by the root user.- if [ -f "/etc/init/${APP_NAME}.conf" ] ; then- return 0- fi-- return 1-}--# Method to check if SRC is running.-# Returns 0 if SRC is found, otherwise returns 1.-srcDetection() {- # $PS_BIN has already been resolved at startup- result=`$PS_BIN -A | grep srcmstr`- return $?-}--setServiceManagementToolLinux() {- case "$SERVICE_MANAGEMENT_TOOL" in- 'auto')- systemdDetection- if [ $? -eq 0 ] ; then- USE_SYSTEMD=1- return- fi-- upstartDetection- if [ $? -eq 0 ] ; then- USE_UPSTART=1- return- fi- ;;- 'systemd')- USE_SYSTEMD=1- ;;- 'upstart')- USE_UPSTART=1- ;;- 'initd')- ;;- *)- return 1- esac-}--setServiceManagementToolAix() {- case "$SERVICE_MANAGEMENT_TOOL" in- 'auto')- srcDetection- if [ $? -eq 0 ] ; then- USE_SRC=1- fi- ;;- 'src')- USE_SRC=1- ;;- 'initd')- ;;- *)- return 1- esac-}--# Resolve the service management tool for linux and aix.-setServiceManagementTool() {- if [ ! -n "$SERVICE_MANAGEMENT_TOOL" ] ; then- # Set the default value to auto.- SERVICE_MANAGEMENT_TOOL=auto- fi-- if [ "$DIST_OS" = "linux" ] ; then- setServiceManagementToolLinux- elif [ "$DIST_OS" = "aix" ] ; then- setServiceManagementToolAix- else- if [ "$SERVICE_MANAGEMENT_TOOL" != "auto" ] ; then- eval echo `gettext 'The script does not support the service management tool \"$SERVICE_MANAGEMENT_TOOL\" on this platform.'`- SERVICE_MANAGEMENT_TOOL=auto- fi- return- fi-- if [ $? = 1 ] ; then- eval echo `gettext 'Service management tool value is invalid: $SERVICE_MANAGEMENT_TOOL.'`- exit 1- fi-}--# default location for the service file-SYSTEMD_SERVICE_FILE="/etc/systemd/system/$APP_NAME.service"--# Installation status-SERVICE_NOT_INSTALLED=0-SERVICE_INSTALLED_DEFAULT=1-SERVICE_INSTALLED_SYSTEMD=2-SERVICE_INSTALLED_UPSTART=4-SERVICE_INSTALLED_SRC=8-SERVICE_INSTALLED_SRC_PARTIAL=16 #incomplete installation with SRC (lssrc or lsitab failed to return a record)--getServiceControlMethod() {- if [ "$DIST_OS" = "macosx" -a -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then- CTRL_WITH_LAUNCHD=true- elif [ "$DIST_OS" = "linux" -a -n "$USE_UPSTART" ] && [ -f "/etc/init/${APP_NAME}.conf" ] ; then- CTRL_WITH_UPSTART=true- elif [ "$DIST_OS" = "linux" -a -n "$USE_SYSTEMD" -a -z "$SYSD" ] && [ -f "${SYSTEMD_SERVICE_FILE}" ] ; then- CTRL_WITH_SYSTEMD=true- elif [ "$DIST_OS" = "aix" -a -n "$USE_SRC" ] && [ -n "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then- CTRL_WITH_SRC=true- else- CTRL_WITH_DEFAULT=true- fi-}--checkInstalled() {- # Install status- installedStatus=$SERVICE_NOT_INSTALLED- installedWith=""-- if [ "$DIST_OS" = "solaris" ] ; then- if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then- installedStatus=$SERVICE_INSTALLED_DEFAULT- fi- elif [ "$DIST_OS" = "linux" ] ; then- if [ "X$1" != "Xstrict" -o \( -z "$USE_SYSTEMD" -a -z "$USE_UPSTART" \) ] ; then- if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then- installedStatus=$SERVICE_INSTALLED_DEFAULT- installedWith="init.d"- fi- fi- if [ "X$1" != "Xstrict" -o -n "$USE_SYSTEMD" ] ; then- if [ -f "${SYSTEMD_SERVICE_FILE}" ] ; then- installedStatus=`expr $installedStatus + $SERVICE_INSTALLED_SYSTEMD`- installedWith="${installedWith}${installedWith:+, }systemd"- fi- fi- if [ "X$1" != "Xstrict" -o -n "$USE_UPSTART" ] ; then- if [ -f "/etc/init/${APP_NAME}.conf" ] ; then- installedStatus=`expr $installedStatus + $SERVICE_INSTALLED_UPSTART`- installedWith="${installedWith}${installedWith:+, }upstart"- fi- fi- elif [ "$DIST_OS" = "hpux" ] ; then- if [ -f "/sbin/init.d/$APP_NAME" -o -L "/sbin/init.d/$APP_NAME" ] ; then- installedStatus=$SERVICE_INSTALLED_DEFAULT- fi- elif [ "$DIST_OS" = "aix" ] ; then- if [ "X$1" != "Xstrict" -o -z "$USE_SRC" ] ; then- if [ -f "/etc/rc.d/init.d/$APP_NAME" -o -L "/etc/rc.d/init.d/$APP_NAME" ] ; then- installedStatus=$SERVICE_INSTALLED_DEFAULT- installedWith="init.d"- fi- fi- if [ "X$1" != "Xstrict" -o -n "$USE_SRC" ] ; then- validateAppNameLength- if [ "$IS_ROOT" = "true" ] ; then- # Check both lssrc & lsitab to make sure the installation is complete. lsitab requires root privileges.- # We will go through this case before installing or removing a service, so we can redo a clean installation- # or a clean removal if installedStatus=5- if [ -n "`/usr/sbin/lsitab $APP_NAME`" -a -n "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then- installedStatus=`expr $installedStatus + $SERVICE_INSTALLED_SRC`- installedWith="${installedWith}${installedWith:+, }SRC"- elif [ -n "`/usr/sbin/lsitab $APP_NAME`" -o -n "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then- installedStatus=`expr $installedStatus + $SERVICE_INSTALLED_SRC_PARTIAL`- installedWith="${installedWith}${installedWith:+, }SRC"- fi- else- # Using lssrc is enough to test normal installations and doesn't require root privileges- if [ -n "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then- installedStatus=`expr $installedStatus + $SERVICE_INSTALLED_SRC`- installedWith="${installedWith}${installedWith:+, }SRC"- fi- fi- fi- elif [ "$DIST_OS" = "freebsd" ] ; then- if [ -f "/etc/rc.d/$APP_NAME" -o -L "/etc/rc.d/$APP_NAME" ] ; then- installedStatus=$SERVICE_INSTALLED_DEFAULT- fi- elif [ "$DIST_OS" = "macosx" ] ; then- if [ -f "/Library/LaunchDaemons/${APP_PLIST}" -o -L "/Library/LaunchDaemons/${APP_PLIST}" ] ; then- installedStatus=$SERVICE_INSTALLED_DEFAULT- fi- elif [ "$DIST_OS" = "zos" ] ; then- if [ -f /etc/rc.bak ] ; then- installedStatus=$SERVICE_INSTALLED_DEFAULT- fi- fi-}--showUsage() {- # $1 bad command-- if [ -n "$1" ]- then- eval echo `gettext 'Unexpected command: $1'`- echo "";- fi-- if [ "X${PASS_THROUGH}" = "Xapp_args" ] ; then- ARGS=" {JavaAppArgs}"- elif [ "X${PASS_THROUGH}" = "Xboth" ] ; then- ARGS=" {WrapperProperties} [-- {JavaAppArgs}]"- else- ARGS=""- fi-- eval MSG=`gettext 'Usage: '`- if [ -n "$FIXED_COMMAND" ] ; then- echo "${MSG} $0${ARGS}"- else- setServiceManagementTool- checkInstalled "strict"- if [ $installedStatus -eq $SERVICE_NOT_INSTALLED ] ; then- # not installed, allow arguments to be passed through- ARGS_START=$ARGS- else- ARGS_START=""- fi- if [ -n "$PAUSABLE" ] ; then- echo "${MSG} $0 [ console${ARGS} | start${ARGS_START} | stop | restart${ARGS_START} | condrestart${ARGS_START} | pause | resume | status | install | installstart | remove | dump ]"- else- echo "${MSG} $0 [ console${ARGS} | start${ARGS_START} | stop | restart${ARGS_START} | condrestart${ARGS_START} | status | install | installstart | remove | dump ]"- fi- fi-- if [ ! -n "$BRIEF_USAGE" ]- then- echo "";- if [ ! -n "$FIXED_COMMAND" ] ; then- echo "`gettext 'Commands:'`"- echo "`gettext ' console Launch in the current console.'`"- echo "`gettext ' start Start in the background as a daemon process.'`"- echo "`gettext ' stop Stop if running as a daemon or in another console.'`"- echo "`gettext ' restart Stop if running and then start.'`"- echo "`gettext ' condrestart Restart only if already running.'`"- if [ -n "$PAUSABLE" ] ; then- echo "`gettext ' pause Pause if running.'`"- echo "`gettext ' resume Resume if paused.'`"- fi- echo "`gettext ' status Query the current status.'`"- echo "`gettext ' install Install to start automatically when system boots.'`"- echo "`gettext ' installstart Install and start running as a daemon process.'`"- echo "`gettext ' remove Uninstall.'`"- echo "`gettext ' dump Request a Java thread dump if running.'`"- echo "";- fi- if [ "X${PASS_THROUGH}" = "Xapp_args" -o "X${PASS_THROUGH}" = "Xboth" ] ; then- if [ "X${PASS_THROUGH}" = "Xboth" ] ; then- echo "WrapperProperties:"- echo "`gettext ' Optional configuration properties which will be passed to the Wrapper.'`"- echo "";- fi- echo "JavaAppArgs:"- echo "`gettext ' Optional arguments which will be passed to the Java application.'`"- echo "";- fi- fi-- exit 1-}--# Output help to understand why the working directory is not accessible.-# The permissions of each folder composing the path will be printed.-# If a folder doesn't have enough permissions, the wrapper binaries or the-# script located in that directory won't be able to execute.-# - When running with the current user, this means we won't be able to detect-# whether the Wrapper binaries are executable, nor send requests such as-# --translate, --request_delta_binary_bits, --request_log_file.-# - When RUN_AS_USER is set, we must be root so the current user should always-# have enough permission. However the command to substitute the user would-# fail if the specified user doesn't have permission on the full path.-#-# $1: The name of the user for which we fail to execute a command in the-# working directory.-reportRealDirNotAccessible() {- # Unfortunately the following message will not be translated because currently the Wrapper fails to execute correctly when it can't access to the absolute path.- eval echo `gettext 'Failed to access the script using an absolute path. Insufficient permissions may prevent the user \"$1\" from traversing one of the folders. Please check the following permissions:'`-- OIFS=$IFS- IFS='/'- for DIR in $REALDIR- do- # REALDIR should already be normalized, but skip '.' if any remains.- if [ "$DIR" != "" -a "$DIR" != "." ] ; then- INT_PATH="${INT_PATH}/$DIR"- ALL_PATHS="${ALL_PATHS} ${INT_PATH}"- result=`cd "${INT_PATH}" 2>/dev/null`- if [ $? -ne 0 ] ; then- # no access to this folder and so to the rest of the path.- break- fi- fi- done- IFS=$OIFS- ls -dal $ALL_PATHS-}--# check if we are running under Cygwin terminal.-# Note: on some OS's (for example Solaris, MacOS), -o is not a valid parameter-# and it shows an error message. We redirect stderr to null so the error message-# doesn't show up.-CYGWIN=`uname -o 2>/dev/null`-if [ "$CYGWIN" = "Cygwin" ]-then- eval echo `gettext 'This script is not compatible with Cygwin. Please use the Wrapper batch files to control the Wrapper.'`- exit 1-fi--# Resolve the location of the 'ps' & 'tr' command-resolveLocation PS_BIN ps "/usr/ucb;/usr/bin;/bin" 1-resolveLocation TR_BIN tr "/usr/bin;/bin" 1--# Resolve the OS (needs to be done before any call to showUsage, checkInstalled, etc.)-DIST_OS=`uname -s | $TR_BIN "[A-Z]" "[a-z]" | $TR_BIN -d ' '`-case "$DIST_OS" in- 'sunos')- DIST_OS="solaris"- ;;- 'hp-ux' | 'hp-ux64')- # HP-UX needs the XPG4 version of ps (for -o args)- DIST_OS="hpux"- UNIX95=""- export UNIX95- PATH=$PATH:/usr/bin- ;;- 'darwin')- DIST_OS="macosx"- ;;- 'unix_sv')- DIST_OS="unixware"- ;;- 'os/390')- DIST_OS="zos"- ;;- 'linux')- DIST_OS="linux"- ;;-esac--# check if there is a parameter "sysd"-SYSD=-if [ $# -gt 1 ] ; then- if [ $2 = "sysd" ] ; then- SYSD=1- fi-fi--# Get the fully qualified path to the script-case $0 in- /*)- SCRIPT="$0"- ;;- *)- PWD=`pwd`- if [ $? -ne 0 ] ; then- # On some systems pwd may fail if one of the parent folder has insufficient permissions.- # Is there a way to access the current location which would allow to print the permissions- # for each folder like we do below?- exit 1- fi- SCRIPT="$PWD/$0"- ;;-esac--# Resolve the true real path without any sym links.-CHANGED=true-while [ "X$CHANGED" != "X" ]-do- # Change spaces to ":" so the tokens can be parsed.- SAFESCRIPT=`echo "$SCRIPT" | sed -e 's; ;:;g'`- # Get the real path to this script, resolving any symbolic links- TOKENS=`echo $SAFESCRIPT | sed -e 's;/; ;g'`- REALPATH=- for C in $TOKENS; do- # Change any ":" in the token back to a space.- C=`echo $C | sed -e 's;:; ;g'`- REALPATH="$REALPATH/$C"- # If REALPATH is a sym link, resolve it. Loop for nested links.- while [ -h "$REALPATH" ] ; do- LS="`ls -ld "$REALPATH"`"- LINK="`expr "$LS" : '.*-> \(.*\)$'`"- if expr "$LINK" : '/.*' > /dev/null; then- # LINK is absolute.- REALPATH="$LINK"- else- # LINK is relative.- REALPATH="`dirname "$REALPATH"`""/$LINK"- fi- done- done-- if [ "$REALPATH" = "$SCRIPT" ]- then- CHANGED=""- else- SCRIPT="$REALPATH"- fi-done--normalizeFilePath REALPATH $REALPATH--# Try to source a file with the same filename as the script and with the '.shconf' extension.-case $REALPATH in- *.sh)- SHCONF_FILE=`echo $REALPATH | rev | cut -d "." -f2- | rev`- ;;- *)- SHCONF_FILE="$REALPATH"- ;;-esac--SHCONF_FILE="${SHCONF_FILE}.shconf"--if [ -f "$SHCONF_FILE" ] ; then- if [ ! -x "$SHCONF_FILE" ] ; then- # We should stop here because the configuration expected in the shconf file will not be loaded.- eval echo `gettext 'Found $SHCONF_FILE but could not execute it. Please make sure that the file has execute permissions.'`- exit 1- fi- . "$SHCONF_FILE"-fi--if [ -n "$FIXED_COMMAND" ] ; then- COMMAND="$FIXED_COMMAND"- FIRST_ARG=$1-else- COMMAND="$1"- FIRST_ARG=$2-fi--if [ "X${PASS_THROUGH}" = "Xtrue" -o "X${PASS_THROUGH}" = "Xapp_args" ] ; then- PASS_THROUGH=app_args-elif [ "X${PASS_THROUGH}" != "Xboth" ] ; then- PASS_THROUGH=false-fi--# Get the location of the script.-REALDIR=`dirname "$REALPATH"`--if [ "X$IS_SUBSTITUTE_USER" = "X" ] ; then- # First check if the command is valid for the current user.- case "$COMMAND" in- 'console' | 'dump' | 'start_msg' | 'stop_msg')- validateRunUser- ;;- 'install' | 'installstart' | 'remove')- mustBeRootOrExit- ;;- 'start' | 'stop' | 'restart' | 'condrestart')- setServiceManagementTool- getServiceControlMethod- if [ "$CTRL_WITH_DEFAULT" = "true" -o "$CTRL_WITH_SYSTEMD" = "true" ] ; then- validateRunUser- else- mustBeRootOrExit- fi- ;;- 'launchdinternal' | 'upstartinternal')- if [ ! "$DIST_OS" = "macosx" -o ! -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then- validateRunUser- fi- ;;- 'pause' | 'resume')- if [ -z "$PAUSABLE" ] ; then- showUsage "$COMMAND"- fi- ;;- 'status')- ;;- *)- showUsage "$COMMAND"- ;;- esac-- # The user has appropriate rights for the given command, but we still need to verify that it has permission to acccess the real dir.- # NOTE: This is not necessary when running as a substitute user because runuser (or su) would have failed if the specified user could not access the real dir.- result=`cd "${REALDIR}" 2>/dev/null`- if [ $? -ne 0 ] ; then- # The command can be run with a normal user, but we don't have sufficient permission to access the real dir.- resolveCurrentUser- reportRealDirNotAccessible $CURRENT_USER- exit 1- fi-fi--# If the PIDDIR is relative, set its value relative to the full REALPATH to avoid problems if-# the working directory is later changed.-FIRST_CHAR=`echo $PIDDIR | cut -c1,1`-if [ "$FIRST_CHAR" != "/" ]-then- PIDDIR=$REALDIR/$PIDDIR- normalizeDirPath PIDDIR $PIDDIR-fi-# Same test for WRAPPER_CMD-FIRST_CHAR=`echo $WRAPPER_CMD | cut -c1,1`-if [ "$FIRST_CHAR" != "/" ]-then- WRAPPER_CMD=$REALDIR/$WRAPPER_CMD-fi-# Same test for WRAPPER_CONF-FIRST_CHAR=`echo $WRAPPER_CONF | cut -c1,1`-if [ "$FIRST_CHAR" != "/" ]-then- WRAPPER_CONF=$REALDIR/$WRAPPER_CONF-fi--# Give default values to $APP_NAME and $APP_LONG_NAME-DELIMITER="@"-if [ "X$APP_NAME" = "X" -o "$APP_NAME" = "${DELIMITER}app.name${DELIMITER}" ] ; then- APP_NAME=`basename -- "$0"`-fi-if [ "X$APP_LONG_NAME" = "X" -o "$APP_LONG_NAME" = "${DELIMITER}app.long.name${DELIMITER}" ] ; then- APP_LONG_NAME=$APP_NAME-fi--# Process ID-ANCHORFILE="$PIDDIR/$APP_NAME.anchor"-COMMANDFILE="$PIDDIR/$APP_NAME.command"-STATUSFILE="$PIDDIR/$APP_NAME.status"-JAVASTATUSFILE="$PIDDIR/$APP_NAME.java.status"-PIDFILE="$PIDDIR/$APP_NAME.pid"-LOCKDIR="/var/lock/subsys"-LOCKFILE="$LOCKDIR/$APP_NAME"-pid=""--# Compare Versions $1<$2=0, $1==$2=1, $1>$2=2-compareVersions () {- if [ "$1" = "$2" ]- then- return 1- else- local i=1- while true- do- local v1=`echo "$1" | cut -d '.' -f $i`- local v2=`echo "$2" | cut -d '.' -f $i`- if [ "X$v1" = "X" ]- then- if [ "X$v2" = "X" ]- then- return 1- fi- v1="0"- elif [ "X$v2" = "X" ]- then- v2="0"- fi- if [ $v1 -lt $v2 ]- then- return 0- elif [ $v1 -gt $v2 ]- then- return 2- fi- i=`expr $i + 1`- done- fi-}--# Resolve the architecture-if [ "$DIST_OS" = "macosx" ]-then- OS_VER=`sw_vers | grep 'ProductVersion:' | grep -o '[0-9]*\.[0-9]*\.[0-9]*\|[0-9]*\.[0-9]*'`- DIST_ARCH=`uname -p 2>/dev/null | $TR_BIN "[A-Z]" "[a-z]" | $TR_BIN -d ' '`- if [ "X${DIST_ARCH}" = "Xarm" ]- then- DIST_ARCH="arm"- else- DIST_ARCH="universal"- fi- compareVersions "$OS_VER" "10.5.0"- if [ $? -lt 1 ]- then- DIST_BITS="32"- KEY_KEEP_ALIVE="OnDemand"- else- # Note: "OnDemand" has been deprecated and replaced from Mac OS X 10.5 by "KeepAlive"- KEY_KEEP_ALIVE="KeepAlive"-- if [ "X`/usr/sbin/sysctl -n hw.cpu64bit_capable`" = "X1" ]- then- DIST_BITS="64"- else- DIST_BITS="32"- fi- fi- APP_PLIST_BASE=${PLIST_DOMAIN}.${APP_NAME}- APP_PLIST=${APP_PLIST_BASE}.plist-elif [ "$DIST_OS" = "zos" ] ; then- # Z/Os is not supported in the Delta Pack, therefore we only provide a binary- # file named "wrapper". However this script will still check for a file named- # "wrapper-zos-390-32" and "wrapper-zos-390-64" in case the user edited the name.- DIST_ARCH="390"- DIST_BITS="64"-else- if [ "$DIST_OS" = "linux" ]- then- DIST_ARCH=- else- DIST_ARCH=`uname -p 2>/dev/null | $TR_BIN "[A-Z]" "[a-z]" | $TR_BIN -d ' '`- fi- if [ "X$DIST_ARCH" = "X" ]- then- DIST_ARCH="unknown"- fi- if [ "$DIST_ARCH" = "unknown" ]- then- DIST_ARCH=`uname -m 2>/dev/null | $TR_BIN "[A-Z]" "[a-z]" | $TR_BIN -d ' '`- fi- case "$DIST_ARCH" in- 'athlon' | 'i386' | 'i486' | 'i586' | 'i686')- DIST_ARCH="x86"- if [ "${DIST_OS}" = "solaris" ] ; then- DIST_BITS=`isainfo -b`- else- DIST_BITS="32"- fi- ;;- 'amd64' | 'x86_64')- DIST_ARCH="x86"- DIST_BITS="64"- ;;- 'ia32')- DIST_ARCH="ia"- DIST_BITS="32"- ;;- 'ia64' | 'ia64n' | 'ia64w')- DIST_ARCH="ia"- DIST_BITS="64"- ;;- 'ip27')- DIST_ARCH="mips"- DIST_BITS="32"- ;;- 'ppc64le')- DIST_ARCH="ppcle"- DIST_BITS="64"- ;;- 'power' | 'powerpc' | 'power_pc' | 'ppc64')- if [ "${DIST_ARCH}" = "ppc64" ] ; then- DIST_BITS="64"- else- DIST_BITS="32"- fi- DIST_ARCH="ppcbe"-- if [ "${DIST_OS}" = "aix" ] ; then- DIST_ARCH="ppc"- if [ `getconf KERNEL_BITMODE` -eq 64 ]; then- DIST_BITS="64"- else- DIST_BITS="32"- fi- fi- ;;- 'pa_risc' | 'pa-risc')- DIST_ARCH="parisc"- if [ `getconf KERNEL_BITS` -eq 64 ]; then- DIST_BITS="64"- else- DIST_BITS="32"- fi- ;;- 'sun4u' | 'sparcv9' | 'sparc')- DIST_ARCH="sparc"- DIST_BITS=`isainfo -b`- ;;- '9000/800' | '9000/785')- DIST_ARCH="parisc"- if [ `getconf KERNEL_BITS` -eq 64 ]; then- DIST_BITS="64"- else- DIST_BITS="32"- fi- ;;- s390* )- DIST_ARCH="390"- if [ `getconf LONG_BIT` -eq 64 ] ; then- DIST_BITS="64"- else- DIST_BITS="32"- fi- ;;- aarch64* | arm64*)- # 'aarch64_be', 'aarch64', 'arm64', etc.- DIST_ARCH="arm"- DIST_BITS="64"- ;;- armv*)- # 'armv8b', 'armv8l', 'armv7l', 'armv5tel', etc.- # => armv8 and above should be 64-bit, but it is more reliable to check the bits with getconf.- if [ `getconf LONG_BIT` -eq 64 ]; then- DIST_ARCH="arm"- DIST_BITS="64"- else- # Note: The following command returns nothing on SUSE for Raspberry Pi 3 (aarch64).- # An alternative command would be 'dpkg --print-architecture', but dpkg may not exist.- if [ -z "`readelf -A /proc/self/exe | grep Tag_ABI_VFP_args`" ] ; then- DIST_ARCH="armel"- else- DIST_ARCH="armhf"- fi- DIST_BITS="32"- fi- ;;- esac-fi--# OSX always places Java in the same location so we can reliably set JAVA_HOME-if [ "$DIST_OS" = "macosx" ]-then- if [ -z "$JAVA_HOME" ]; then- if [ -x /usr/libexec/java_home ]; then- JAVA_HOME=`/usr/libexec/java_home`; export JAVA_HOME- else- JAVA_HOME="/Library/Java/Home"; export JAVA_HOME- fi- fi-fi--# Test Echo-ECHOTEST=`echo -n "x"`-if [ "$ECHOTEST" = "x" ]-then- ECHOOPT="-n "- ECHOOPTC=""-else- ECHOOPT=""- ECHOOPTC="\c"-fi--outputFile() {- if [ -f "$1" ]- then- eval echo `gettext ' $1 Found but not executable.'`;- else- echo " $1"- fi-}--# Check if the first parameter is an existing executable file.-detectWrapperBinary() {- if [ -f "$1" ] ; then- WRAPPER_TEST_CMD="$1"- if [ ! -x "$WRAPPER_TEST_CMD" ] ; then- chmod +x "$WRAPPER_TEST_CMD" 2>/dev/null- fi- if [ -x "$WRAPPER_TEST_CMD" ] ; then- WRAPPER_CMD="$WRAPPER_TEST_CMD"- else- outputFile "$WRAPPER_TEST_CMD"- WRAPPER_TEST_CMD=""- fi- fi-}--# Decide on the wrapper binary to use.-# If the bits of the OS could be detected, we will try to look for the-# binary with the correct bits value. If it doesn't exist, fall back-# and look for the 32-bit binary. If that doesn't exist either then-# look for the default.-WRAPPER_TEST_CMD=""--BIN_BITS=$DIST_BITS-if [ ! "$BIN_BITS" = "32" ] ; then- # On a 64-bit platform, both Wrapper 32-Bit and 64-Bit can be used.- # Send a request to the Wrapper to know if the license has the 64-bit feature.- WRAPPER_CMD_ORIG=$WRAPPER_CMD- detectWrapperBinary "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-$BIN_BITS"- if [ ! -z "$WRAPPER_TEST_CMD" ] ; then- if [ "$COMMAND" = "console" -o "$COMMAND" = "start" -o "$COMMAND" = "restart" -o "$COMMAND" = "condrestart" -o "$COMMAND" = "installstart" ] ; then- "$WRAPPER_CMD" --request_delta_binary_bits "$WRAPPER_CONF" 2>/dev/null- if [ $? = 32 ] ; then- # License is 32-Bit. Reset and search for 32-Bit Wrapper binaries.- WRAPPER_TEST_CMD=""- WRAPPER_CMD=$WRAPPER_CMD_ORIG- BIN_BITS=32- fi- fi- fi-fi--if [ -z "$WRAPPER_TEST_CMD" ] ; then- detectWrapperBinary "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-32"-fi-if [ -z "$WRAPPER_TEST_CMD" ] ; then- detectWrapperBinary "$WRAPPER_CMD"-fi---if [ -z "$WRAPPER_TEST_CMD" ] ; then- eval echo `gettext 'Unable to locate any of the following binaries:'`- outputFile "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-$BIN_BITS"- if [ ! "$BIN_BITS" = "32" ] ; then- outputFile "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-32"- fi- outputFile "$WRAPPER_CMD"-- exit 1-fi---# Build the nice clause-if [ "X$PRIORITY" = "X" ]-then- CMDNICE=""-else- CMDNICE="nice -$PRIORITY"-fi--# Build the anchor file clause.-if [ "X$IGNORE_SIGNALS" = "X" ]-then- ANCHORPROP=- IGNOREPROP=-else- ANCHORPROP=wrapper.anchorfile=\"$ANCHORFILE\"- IGNOREPROP=wrapper.ignore_signals=TRUE-fi--# Build the status file clause.-if [ "X$DETAIL_STATUS$WAIT_FOR_STARTED_STATUS" = "X" ]-then- STATUSPROP=-else- STATUSPROP="wrapper.statusfile=\"$STATUSFILE\" wrapper.java.statusfile=\"$JAVASTATUSFILE\""-fi--# Build the command file clause.-if [ -n "$PAUSABLE" ]-then- if [ "$PAUSABLE_MODE" = "file" ] ; then- COMMANDPROP="wrapper.commandfile=\"$COMMANDFILE\" wrapper.pausable=TRUE"- else- COMMANDPROP="wrapper.signal.mode.usr1=PAUSE wrapper.signal.mode.usr2=RESUME wrapper.pausable=TRUE"- fi-else- COMMANDPROP=-fi--if [ ! -n "$WAIT_FOR_STARTED_STATUS" ]-then- WAIT_FOR_STARTED_STATUS=true-fi--if [ $WAIT_FOR_STARTED_STATUS = true ] ; then- DETAIL_STATUS=true-fi---# Build the lock file clause. Only create a lock file if the lock directory exists on this platform.-LOCKPROP=-if [ -d $LOCKDIR ]-then- if [ -w $LOCKDIR ]- then- LOCKPROP=wrapper.lockfile=\"$LOCKFILE\"- fi-fi--# Build app name clause-if [ ! -n "$APP_NAME_PASS_TO_WRAPPER" ]-then- APP_NAME_PASS_TO_WRAPPER=true-fi-if [ $APP_NAME_PASS_TO_WRAPPER = false ]-then- APPNAMEPROP=-else- APPNAMEPROP="wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\""-fi--# Decide on run levels.-RUN_LEVEL_S_DIST_OS_TMP=`eval "echo \$\{RUN_LEVEL_S_${DIST_OS}\}"`-RUN_LEVEL_S_DIST_OS=`eval "echo ${RUN_LEVEL_S_DIST_OS_TMP}"`-if [ "X${RUN_LEVEL_S_DIST_OS}" != "X" ] ; then- APP_RUN_LEVEL_S=${RUN_LEVEL_S_DIST_OS}-elif [ "X$RUN_LEVEL_S" != "X" ] ; then- APP_RUN_LEVEL_S=$RUN_LEVEL_S-else- APP_RUN_LEVEL_S=$RUN_LEVEL-fi-APP_RUN_LEVEL_S_CHECK=`echo "$APP_RUN_LEVEL_S" | sed "s/[(0-9)*]/0/g"`-if [ "X${APP_RUN_LEVEL_S_CHECK}" != "X00" ] ; then- eval echo `gettext 'Run level \"${APP_RUN_LEVEL_S}\" must be numeric and have a length of two \(00-99\).'`- exit 1;-fi-RUN_LEVEL_K_DIST_OS_TMP=`eval "echo \$\{RUN_LEVEL_K_${DIST_OS}\}"`-RUN_LEVEL_K_DIST_OS=`eval "echo ${RUN_LEVEL_K_DIST_OS_TMP}"`-if [ "X${RUN_LEVEL_K_DIST_OS}" != "X" ] ; then- APP_RUN_LEVEL_K=${RUN_LEVEL_K_DIST_OS}-elif [ "X$RUN_LEVEL_K" != "X" ] ; then- APP_RUN_LEVEL_K=$RUN_LEVEL_K-else- APP_RUN_LEVEL_K=$RUN_LEVEL-fi-APP_RUN_LEVEL_K_CHECK=`echo "$APP_RUN_LEVEL_K" | sed "s/[(0-9)*]/0/g"`-if [ "X${APP_RUN_LEVEL_K_CHECK}" != "X00" ] ; then- eval echo `gettext 'Run level \"${APP_RUN_LEVEL_K}\" must be numeric and have a length of two \(00-99\).'`- exit 1;-fi--prepAdditionalParams() {- ADDITIONAL_PARA=""- if [ "X${PASS_THROUGH}" = "Xapp_args" -o "X${PASS_THROUGH}" = "Xboth" ] ; then- if [ "X${PASS_THROUGH}" = "Xapp_args" ] ; then- ADDITIONAL_PARA="@properties_and_parameters@"- ARGS_ARE_APP_PARAMS=true- fi- while [ -n "$1" ] ; do- if [ ! -n "$ARGS_ARE_APP_PARAMS" ] ; then- if [ "$1" = "--" ] ; then- ARGS_ARE_APP_PARAMS=true- else- # Check that the arg matches the pattern of a property- case "$1" in- wrapper.*=*)- # Correct, nothing to do- ;;- *=*)- # The property name is not starting with 'wrapper.' so invalid.- COMMAND_PROP=${1%%=*}- eval echo `gettext 'WARNING: Encountered an unknown configuration property \"${COMMAND_PROP}\". When PASS_THROUGH is set to \"both\", any argument before \"--\" should target a valid Wrapper configuration property.'`- ;;- *)- # Not a valid assignment.- eval echo `gettext 'WARNING: Encountered an invalid configuration property assignment \"$1\". When PASS_THROUGH is set to \"both\", any argument before \"--\" should be in the format \"\<property_name\>=\<value\>\".'`- ;;- esac- fi- fi- ADDITIONAL_PARA="$ADDITIONAL_PARA \"$1\""- shift- done- fi-}--resolveSysLocale() {- # First try to get the system encoding from /etc/default/locale.- # Note: For some reason, the system encoding stored in /etc/default/locale and the value returned by localectl may differ.- # When using 'localectl set-local', /etc/default/locale is always updated accordingly, but when manually editing /etc/default/locale,- # the output of the command sometimes doesn't get updated. When the values differ, SU uses the same locale as /etc/default/locale,- # so that's why we start trying to get the locale using this method.- if [ -f "/etc/default/locale" ] ; then- PASS_SYS_LANG=`grep 'LANG=' /etc/default/locale`- case "$PASS_SYS_LANG" in- LANG=*)- PASS_SYS_LANG="$PASS_SYS_LANG "- ;;- *)- PASS_SYS_LANG=""- ;;- esac- fi- if [ "X$PASS_SYS_LANG" = "X" ] ; then- # Try to get the system encoding using localectl.- LOCALECTL_BIN="localectl"- result=`command -v $LOCALECTL_BIN 2>/dev/null`- if [ $? -ne 0 ] ; then- LOCALECTL_BIN="/usr/bin/localectl"- if [ ! -x "$LOCALECTL_BIN" ] ; then- # Keep the warning for debugging, but don't actually show it because it may be normal for some OS to not have the command.- # echo " WARNING: Could not locate localectl used to get the system locale. The encoding may not be correct when running as $RUN_AS_USER."- LOCALECTL_BIN=""- fi- fi- if [ "X$LOCALECTL_BIN" != "X" ] ; then- # The first line that localectl outputs should look like this: ' System Locale: n/a'- PASS_SYS_LANG=`$LOCALECTL_BIN | grep "System Locale" | awk '{print $3}' 2>/dev/null`- case "$PASS_SYS_LANG" in- *n/a*)- # No system locale set. Skip.- PASS_SYS_LANG=""- ;;- LANG=*)- PASS_SYS_LANG="$PASS_SYS_LANG "- ;;- *)- # echo " WARNING: Failed to parse the output of localectl. The encoding may not be correct when running as $RUN_AS_USER.'"- PASS_SYS_LANG=""- ;;- esac- fi- fi-}---checkRunUser() {- # $1 touchLock flag- # $2.. [command] args-- # Make sure the configuration is valid.- validateRunUser-- # Check the configured user. If necessary rerun this script as the desired user.- if [ "X$RUN_AS_USER" != "X" ]- then- # If LOCKPROP and $RUN_AS_USER are defined then the new user will most likely not be- # able to create the lock file. The Wrapper will be able to update this file once it- # is created but will not be able to delete it on shutdown. If $1 is set then- # the lock file should be created for the current command- if [ "X$LOCKPROP" != "X" ]- then- if [ "X$1" != "X" ]- then- # Resolve the primary group- RUN_AS_GROUP=`groups $RUN_AS_USER | awk '{print $3}' | tail -1`- if [ "X$RUN_AS_GROUP" = "X" ]- then- RUN_AS_GROUP=$RUN_AS_USER- fi- touch $LOCKFILE- chown $RUN_AS_USER:$RUN_AS_GROUP $LOCKFILE- fi- fi-- # Still want to change users, recurse. This means that the user will only be- # prompted for a password once. Variables shifted by 1- shift-- # Wrap the parameters so they can be passed.- ADDITIONAL_PARA=""- while [ -n "$1" ] ; do- if [ "$1" = 'installstart' ] ; then- # At this point the service is already installed. When we will fork the process we only need to start the service.- ADDITIONAL_PARA="$ADDITIONAL_PARA \"start\""- else- ADDITIONAL_PARA="$ADDITIONAL_PARA \"$1\""- fi- shift- done-- resolveSysLocale- RUNUSER_INTERRUPT_TRAPPED=false- $RUNUSER_BIN - $RUN_AS_USER -c "IS_SUBSTITUTE_USER=true $PASS_SYS_LANG\"$REALPATH\" $ADDITIONAL_PARA" $SU_OPTS- RUN_AS_USER_EXITCODE=$?-- if [ $RUN_AS_USER_EXITCODE -eq 126 ] ; then- reportRealDirNotAccessible $RUN_AS_USER- elif [ $RUN_AS_USER_EXITCODE -gt 128 -o "$RUNUSER_INTERRUPT_TRAPPED" = "true" ] ; then- # The range 128-255 is reserved for signals, but if the user presses CTRL+C (or sends a signal?) two consecutive times, runuser/su will be interrupted and may return 0.- # The RUNUSER_INTERRUPT_TRAPPED is set when trapping INT, TERM, QUIT or HUP, but there might be other signals causing interruption.- # We use the 2 above conditions to cover most cases.-- # Why can this happen: If a signal causing interruption is sent to the process group of the parent script, it will also be caught by the- # runuser process which belongs to the same group. The parent script can ignore it but the runuser process will be terminated.- # The Wrapper will take some time to exit cleanly or may not even exit depending on the signal, so we should wait for its PID.- # NOTES: - it is not possible to use the wait command because the Wrapper is a child of the login shell started by runuser.- # - it is possible that Wrapper returned a reserved exit code, but we wouldn't wait below because getpid should return an empty $pid.- getpid- if [ "X$pid" != "X" ] ; then- if [ $RUN_AS_USER_EXITCODE -eq 255 ] ; then- # On some system, su returns 255 if it has to kill the command (because it was asked to terminate, and the command did not terminate in time).- # Print a different message to make it clear that runuser/su did not force kill the Wrapper process.- eval echo `gettext 'Intermediate login shell was killed. Still waiting for the Wrapper process to stop...'`- else- eval echo `gettext 'Waiting for the Wrapper process to stop...'`- fi- fi- while [ "X$pid" != "X" ] ; do- sleep 1- testpid- done- elif [ $RUN_AS_USER_EXITCODE -eq 1 ] ; then- # 1 is a special case as it can either be a generic error before executing the Wrapper, or the Wrapper exit code returned on error.- checkForkCommand- fi-- # Now that we are the original user again, we may need to clean up the lock file.- if [ "X$LOCKPROP" != "X" ]- then- getpid- if [ "X$pid" = "X" ]- then- # Wrapper is not running so make sure the lock file is deleted.- if [ -f "$LOCKFILE" ]- then- rm "$LOCKFILE"- fi- fi- fi-- exit $RUN_AS_USER_EXITCODE- fi-}--# Try to fork by executing a simple command.-# With this function, we want to make sure we are able to fork.-checkForkCommand() {- $RUNUSER_BIN - $RUN_AS_USER -c "ls \"$REALPATH\"" $SU_OPTS > /dev/null 2>&1 &- CHECK_EXITCODE=$?-- if [ $CHECK_EXITCODE -ne 0 ]- then- # clearly a problem with forking- eval echo `gettext 'Error: unable to create fork process.'`- eval echo `gettext 'Advice:'`- eval echo `gettext 'One possible cause of failure is when the user \(\"$RUN_AS_USER\"\) has no shell.'`- eval echo `gettext 'In this case, two solutions are available by editing the script file:'`- eval echo `gettext '1. Use \"SU_OPTS\" to set the shell for the user.'`- eval echo `gettext '2. Use a OS service management tool \(only available on some platforms\).'`- echo ""- fi-}--getpid() {- pid=""- if [ -f "$PIDFILE" ]- then- if [ -r "$PIDFILE" ]- then- pid=`cat "$PIDFILE"`- if [ "X$pid" != "X" ]- then- if [ "X$PIDFILE_CHECK_PID" != "X" ]- then- # It is possible that 'a' process with the pid exists but that it is not the- # correct process. This can happen in a number of cases, but the most- # common is during system startup after an unclean shutdown.- # The ps statement below looks for the specific wrapper command running as- # the pid. If it is not found then the pid file is considered to be stale.- case "$DIST_OS" in- 'freebsd')- pidtest=`$PS_BIN -p $pid -o args | tail -1`- if [ "X$pidtest" = "XCOMMAND" ]- then- pidtest=""- fi- ;;- 'macosx')- pidtest=`$PS_BIN -ww -p $pid -o command | grep -F "$WRAPPER_CMD" | tail -1`- ;;- 'solaris')- if [ -f "/usr/bin/pargs" ]- then- pidtest=`pargs $pid | fgrep "$WRAPPER_CMD" | tail -1`- else- case "$PS_BIN" in- '/usr/ucb/ps')- pidtest=`$PS_BIN -auxww $pid | fgrep "$WRAPPER_CMD" | tail -1`- ;;- '/usr/bin/ps')- TRUNCATED_CMD=`$PS_BIN -o comm -p $pid | tail -1`- COUNT=`echo $TRUNCATED_CMD | wc -m`- COUNT=`echo ${COUNT}`- COUNT=`expr $COUNT - 1`- TRUNCATED_CMD=`echo $WRAPPER_CMD | cut -c1-$COUNT`- pidtest=`$PS_BIN -o comm -p $pid | fgrep "$TRUNCATED_CMD" | tail -1`- ;;- '/bin/ps')- TRUNCATED_CMD=`$PS_BIN -o comm -p $pid | tail -1`- COUNT=`echo $TRUNCATED_CMD | wc -m`- COUNT=`echo ${COUNT}`- COUNT=`expr $COUNT - 1`- TRUNCATED_CMD=`echo $WRAPPER_CMD | cut -c1-$COUNT`- pidtest=`$PS_BIN -o comm -p $pid | fgrep "$TRUNCATED_CMD" | tail -1`- ;;- *)- echo "Unsupported ps command $PS_BIN"- exit 1- ;;- esac- fi- ;;- 'hpux')- pidtest=`$PS_BIN -p $pid -x -o args | grep -F "$WRAPPER_CMD" | tail -1`- ;;- 'zos')- TRUNCATED_CMD=`$PS_BIN -p $pid -o args | tail -1`- COUNT=`echo $TRUNCATED_CMD | wc -m`- COUNT=`echo ${COUNT}`- COUNT=`expr $COUNT - 1`- TRUNCATED_CMD=`echo $WRAPPER_CMD | cut -c1-$COUNT`- pidtest=`$PS_BIN -p $pid -o args | grep -F "$TRUNCATED_CMD" | tail -1`- ;;- 'linux')- pidtest=`$PS_BIN -ww -p $pid -o args | grep -F "$WRAPPER_CMD" | tail -1`- ;;- *)- pidtest=`$PS_BIN -p $pid -o args | grep -F "$WRAPPER_CMD" | tail -1`- ;;- esac- else- # Check to see whether the pid exists as a running process, but in this mode, don't check what that pid is.- case "$DIST_OS" in- 'solaris')- case "$PS_BIN" in- '/usr/ucb/ps')- pidtest=`$PS_BIN $pid | grep "$pid" | awk '{print $1}' | tail -1`- ;;- '/usr/bin/ps')- pidtest=`$PS_BIN -p $pid -o pid | grep "$pid" | tail -1`- ;;- '/bin/ps')- pidtest=`$PS_BIN -p $pid -o pid | grep "$pid" | tail -1`- ;;- *)- echo "Unsupported ps command $PS_BIN"- exit 1- ;;- esac- ;;- *)- pidtest=`$PS_BIN -p $pid -o pid | grep "$pid" | tail -1`- ;;- esac- fi-- if [ "X$pidtest" = "X" ]- then- # This is a stale pid file.- rm -f "$PIDFILE"- eval echo `gettext 'Removed stale pid file: $PIDFILE'`- pid=""- fi- fi- else- eval echo `gettext 'Cannot read $PIDFILE.'`- exit 1- fi- fi-}--getstatus() {- STATUS=- if [ -f "$STATUSFILE" ]- then- if [ -r "$STATUSFILE" ]- then- STATUS=`cat "$STATUSFILE"`- fi- fi- if [ "X$STATUS" = "X" ]- then- STATUS="Unknown"- fi-- JAVASTATUS=- if [ -f "$JAVASTATUSFILE" ]- then- if [ -r "$JAVASTATUSFILE" ]- then- JAVASTATUS=`cat "$JAVASTATUSFILE"`- fi- fi- if [ "X$JAVASTATUS" = "X" ]- then- JAVASTATUS="Unknown"- fi-}--testpid() {- case "$DIST_OS" in- 'solaris')- case "$PS_BIN" in- '/usr/ucb/ps')- pid=`$PS_BIN $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1`- ;;- '/usr/bin/ps')- pid=`$PS_BIN -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1`- ;;- '/bin/ps')- pid=`$PS_BIN -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1`- ;;- *)- echo "Unsupported ps command $PS_BIN"- exit 1- ;;- esac- ;;- *)- pid=`$PS_BIN -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1` 2>/dev/null- ;;- esac- if [ "X$pid" = "X" ]- then- pid=""- fi-}--launchdtrap() {- stopit- exit-}--waitForWrapperStop() {- getpid- while [ "X$pid" != "X" ] ; do- sleep 1- getpid- done-}--launchinternal() {- getpid- trap launchdtrap TERM- if [ "X$pid" = "X" ]- then- # The string passed to eval must handles spaces in paths correctly.- COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.daemonize=TRUE $APPNAMEPROP $ANCHORPROP $IGNOREPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.51 $ADDITIONAL_PARA"- eval "$COMMAND_LINE"- else- eval echo `gettext '$APP_LONG_NAME is already running.'`- exit 1- fi- # launchd expects that this script stay up and running so we need to do our own monitoring of the Wrapper process.- if [ $WAIT_FOR_STARTED_STATUS = true ]- then- waitForWrapperStop- fi-}--consoleTrapInterrupt() {- # Set a flag to inform su/runuser that we caught an interrupt signal.- RUNUSER_INTERRUPT_TRAPPED=true-}--consoleTrap() {- if [ $2 = 1 ] ; then- # Set a flag to inform su/runuser that we caught an interrupt signal (do it as early as possible).- RUNUSER_INTERRUPT_TRAPPED=true- fi-- getpid- if [ "X$pid" != "X" ] ; then- # still alive- kill -$1 $pid- if [ $? -ne 0 ] ; then- # log a message but do not exit- eval echo `gettext 'Unable to forward $1 signal to $APP_LONG_NAME.'`- fi-- # Nothing else to do. Let the script complete normally after the Wrapper exits.- fi-}--consoleTrapSignals() {- if [ "$IS_SUBSTITUTE_USER" != "true" ] ; then- # Trap the following signals in order to forward them to the Wrapper.- if [ "X$RUN_AS_USER" != "X" ] ; then- trap "consoleTrap INT 1" INT- trap "consoleTrap TERM 1" TERM- else- trap "consoleTrap INT 0" INT- trap "consoleTrap TERM 0" TERM- fi-- # SIGQUIT is usually triggered with the keyboard (CTRL+\). Forward it when running as a user.- # When running normally, the Wrapper being member of the same process group will also get the signal, so no need to forward it.- if [ "X$RUN_AS_USER" != "X" ] ; then- trap "consoleTrap QUIT 1" QUIT- else- trap '' QUIT- fi-- # SIGHUP should be caught otherwise it would interrupt the script, but do not forward it.- if [ "X$RUN_AS_USER" != "X" ] ; then- # SIGHUP behaves differently than INT/TERM/QUIT and should not interrupt su/runuser when a custom handler is registered.- # But this might depend on the shell & platform. Be safe and set the RUNUSER_INTERRUPT_TRAPPED flag anyway.- trap 'consoleTrapInterrupt' HUP- else- trap '' HUP- fi- fi-}--console() {- eval echo `gettext 'Running $APP_LONG_NAME...'`- getpid- if [ "X$pid" = "X" ]- then- prepAdditionalParams "$@"-- # The string passed to eval must handles spaces in paths correctly.- COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" $APPNAMEPROP $ANCHORPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.51 $ADDITIONAL_PARA"- eval "$COMMAND_LINE"- COMMAND_EXIT_CODE=$?- if [ $COMMAND_EXIT_CODE -ne 0 ] ; then- exit $COMMAND_EXIT_CODE- fi- else- eval echo `gettext '$APP_LONG_NAME is already running.'`- exit 1- fi-}--waitforjavastartup() {- getstatus- eval echo $ECHOOPT `gettext 'Waiting for $APP_LONG_NAME...$ECHOOPTC'`-- # Wait until the timeout or we have something besides Unknown.- counter=15- while [ "$JAVASTATUS" = "Unknown" -a $counter -gt 0 -a -n "$JAVASTATUS" ] ; do- echo $ECHOOPT".$ECHOOPTC"- sleep 1- getstatus- counter=`expr $counter - 1`- done-- if [ -n "$WAIT_FOR_STARTED_TIMEOUT" ] ; then- counter=$WAIT_FOR_STARTED_TIMEOUT- else- counter=120- fi- while [ "$JAVASTATUS" != "STARTED" -a "$JAVASTATUS" != "Unknown" -a $counter -gt 0 -a -n "$JAVASTATUS" ] ; do- echo $ECHOOPT".$ECHOOPTC"- sleep 1- getstatus- counter=`expr $counter - 1`- done- echo ""-}--##-# Request the path to the log file to the Wrapper and print it-#-# $1 prefix-printlogfilepath() {- LOG_FILE1=`"$WRAPPER_CMD" --request_log_file "$WRAPPER_CONF" 2>/dev/null`- if [ $? = 0 -a "X$LOG_FILE1" != "X" ] ; then- # try to see if a default log file exists- LOG_FILE2=`"$WRAPPER_CMD" --request_default_log_file "$WRAPPER_CONF" 2>/dev/null`- if [ $? != 0 -o ! -f "$LOG_FILE2" ] ; then- LOG_FILE2=""- fi- else- # try to see if a default log file exists- LOG_FILE1=`"$WRAPPER_CMD" --request_default_log_file "$WRAPPER_CONF" 2>/dev/null`- if [ $? != 0 -o ! -f "$LOG_FILE1" ] ; then- LOG_FILE1=""- fi- fi- if [ "X$LOG_FILE2" != "X" ] ; then- LOG_FILE_MSG=`gettext 'The log files \"${LOG_FILE1}\" and \"${LOG_FILE2}\" may contain further information.'`- elif [ "X$LOG_FILE1" != "X" ] ; then- LOG_FILE_MSG=`gettext 'The log file \"${LOG_FILE1}\" may contain further information.'`- else- LOG_FILE_MSG=`gettext 'The syslog may contain further information.'`- fi- LOG_FILE_MSG=`eval echo "${LOG_FILE_MSG}"` # expand ${LOG_FILE}- echo "$1${LOG_FILE_MSG}" # print with indentation-}--startwait() {- if [ $WAIT_FOR_STARTED_STATUS = true ]- then- waitforjavastartup- fi- # Sleep for a few seconds to allow for intialization if required- # then test to make sure we're still running.- #- i=0- while [ $i -lt $WAIT_AFTER_STARTUP ]- do- sleep 1- echo $ECHOOPT".$ECHOOPTC"- i=`expr $i + 1`- done- if [ $WAIT_AFTER_STARTUP -gt 0 -o $WAIT_FOR_STARTED_STATUS = true ]- then- getpid- if [ "X$pid" = "X" ]- then- eval echo `gettext 'WARNING: $APP_LONG_NAME may have failed to start.'`- printlogfilepath " "- exit 1- else- eval echo `gettext ' running: PID:$pid'`- fi- else- echo ""- fi-}--mustBeStoppedOrExit() {- getpid- if [ "X$pid" != "X" ] ; then- eval echo `gettext '$APP_LONG_NAME is already running.'`- exit 1- fi-}--# Detect if the Wrapper is running-# Returns 0 if the process is running, otherwise returns 1.-checkRunning() {- getpid- if [ "X$pid" = "X" ] ; then- eval echo `gettext '$APP_LONG_NAME is not running.'`- if [ "X$1" = "X1" ] ; then- exit 1- fi- return 1- fi- return 0-}---macosxStart() {- mustBeRootOrExit- mustBeStoppedOrExit-- eval echo `gettext 'Starting $APP_LONG_NAME with launchd...'`-- # If the daemon was just installed, it may not be loaded.- LOADED_PLIST=`launchctl list | grep ${APP_PLIST_BASE}`- if [ "X${LOADED_PLIST}" = "X" ] ; then- launchctl load /Library/LaunchDaemons/${APP_PLIST}- fi- # If launchd is set to run the daemon already at Load, we don't need to call start- getpid- if [ "X$pid" = "X" ] ; then- launchctl start ${APP_PLIST_BASE}- fi-- startwait-}--macosxStop() {- mustBeRootOrExit- # The daemon must be running.- checkRunning "1"-- eval echo `gettext 'Stopping $APP_LONG_NAME...'`-- if [ "$MACOSX_KEEP_RUNNING" = "true" ] ; then- echo ""- eval echo `gettext 'Daemon is set to be kept continuously running and it will be automatically restarted.'`- eval echo `gettext 'To stop the daemon you need to uninstall it.'`- eval echo `gettext 'If you want to use the \"stop\" argument, you need to find MACOSX_KEEP_RUNNING'`- eval echo `gettext 'at the beginning of the script file and set it to \"false\".'`- echo ""- fi- launchctl stop ${APP_PLIST_BASE}-}--macosxRestart() {- mustBeRootOrExit- checkRunning $1-- eval echo `gettext 'Restarting $APP_LONG_NAME...'`-- if [ "$MACOSX_KEEP_RUNNING" = "true" ] ; then- # by stopping it, launchd will automatically restart it- launchctl stop ${APP_PLIST_BASE}- else- launchctl unload "/Library/LaunchDaemons/${APP_PLIST}"- sleep 1- launchctl load "/Library/LaunchDaemons/${APP_PLIST}"- fi-- startwait-}--upstartInstall() {- # Always verify that upstart exists.- upstartDetection- if [ $? -ne 0 ] ; then- eval echo `gettext 'Unable to install the $APP_LONG_NAME daemon because upstart does not exist.'`- return 1- fi-- eval echo `gettext ' Installing the $APP_LONG_NAME daemon with upstart...'`- if [ -f "${REALDIR}/${APP_NAME}.install" ] ; then- eval echo `gettext ' Custom upstart conf file ${APP_NAME}.install found.'`- cp "${REALDIR}/${APP_NAME}.install" "/etc/init/${APP_NAME}.conf"- else- eval echo `gettext ' Creating default upstart conf file...'`- echo "# ${APP_NAME} - ${APP_LONG_NAME}" > "/etc/init/${APP_NAME}.conf"- echo "description \"${APP_LONG_NAME}\"" >> "/etc/init/${APP_NAME}.conf"- echo "author \"Tanuki Software Ltd. <[email protected]>\"" >> "/etc/init/${APP_NAME}.conf"- echo "start on runlevel [2345]" >> "/etc/init/${APP_NAME}.conf"- echo "stop on runlevel [!2345]" >> "/etc/init/${APP_NAME}.conf"- echo "env LANG=${LANG}" >> "/etc/init/${APP_NAME}.conf"- echo "exec \"${REALPATH}\" upstartinternal" >> "/etc/init/${APP_NAME}.conf"- fi-}--upstartStart() {- mustBeRootOrExit- mustBeStoppedOrExit-- eval echo `gettext 'Starting $APP_LONG_NAME with upstart...'`-- /sbin/start ${APP_NAME}-- startwait-}--upstartStop() {- mustBeRootOrExit- # The daemon must be running.- checkRunning "1"-- eval echo `gettext 'Stopping $APP_LONG_NAME...'`-- /sbin/stop ${APP_NAME}-}--upstartRestart() {- mustBeRootOrExit- checkRunning $1-- if [ "X$pid" = "X" ] ; then- # Don't use /sbin/restart because it requires the daemon to be running.- # We want to match with other systems behaviour which is to restart the- # daemon even if it was not running.- upstartStart- else- # The daemon was running- eval echo `gettext 'Restarting $APP_LONG_NAME...'`-- /sbin/restart ${APP_NAME}-- startwait- fi-}--upstartRemove() {- stopit "0"- eval echo `gettext ' Removing the $APP_LONG_NAME daemon from upstart...'`- rm "/etc/init/${APP_NAME}.conf"-}--systemdInstall() {- # Always verify that systemd exists.- systemdDetection- if [ $? -ne 0 ] ; then- eval echo `gettext 'Unable to install the $APP_LONG_NAME daemon because systemd does not exist.'`- return 1- fi-- eval echo `gettext ' Installing the $APP_LONG_NAME daemon with systemd...'`- if [ -f "${REALDIR}/${APP_NAME}.service" ] ; then- eval echo `gettext ' Custom service file ${APP_NAME}.service found.'`- cp "${REALDIR}/${APP_NAME}.service" "${SYSTEMD_SERVICE_FILE}"- else- eval echo `gettext ' Creating default service file...'`- echo "[Unit]" > "${SYSTEMD_SERVICE_FILE}"- echo "Description=${APP_LONG_NAME}" >> "${SYSTEMD_SERVICE_FILE}"- echo "After=syslog.target" >> "${SYSTEMD_SERVICE_FILE}"- echo "" >> "${SYSTEMD_SERVICE_FILE}"- echo "[Service]" >> "${SYSTEMD_SERVICE_FILE}"- echo "Type=forking" >> "${SYSTEMD_SERVICE_FILE}"- case "${REALPATH}" in- *\ *)- # REALPATH contains spaces- LINE_HEAD='ExecStart=/usr/bin/env "'- LINE_TAIL='" start sysd'- echo "${LINE_HEAD}${REALPATH}${LINE_TAIL}" >> "${SYSTEMD_SERVICE_FILE}"- LINE_HEAD='ExecStop=/usr/bin/env "'- LINE_TAIL='" stop sysd'- echo "${LINE_HEAD}${REALPATH}${LINE_TAIL}" >> "${SYSTEMD_SERVICE_FILE}"- ;;- *)- echo "ExecStart=${REALPATH} start sysd" >> "${SYSTEMD_SERVICE_FILE}"- echo "ExecStop=${REALPATH} stop sysd" >> "${SYSTEMD_SERVICE_FILE}"- ;;- esac- if [ "X${RUN_AS_USER}" != "X" ] ; then- echo "User=${RUN_AS_USER}" >> "${SYSTEMD_SERVICE_FILE}"- fi- if [ "X${SYSTEMD_KILLMODE}" != "X" ] ; then- echo "KillMode=${SYSTEMD_KILLMODE}" >> "${SYSTEMD_SERVICE_FILE}"- fi- if [ $SYSTEMD_KILLMODE != "process" -a $SYSTEMD_KILLMODE != "none" ] ; then- # Set an environment variable to show a warning if a detached process is launched by the WrapperManager.- echo "Environment=SYSTEMD_KILLMODE_WARNING=true" >> "${SYSTEMD_SERVICE_FILE}"- fi- echo "" >> "${SYSTEMD_SERVICE_FILE}"- echo "[Install]" >> "${SYSTEMD_SERVICE_FILE}"- echo "WantedBy=multi-user.target" >> "${SYSTEMD_SERVICE_FILE}"- fi- systemctl daemon-reload- systemctl enable "${APP_NAME}"-}--systemdStart() {- # Don't do mustBeRootOrExit because systemd will ask for the password when not root- mustBeStoppedOrExit-- result=`systemctl -p KillMode show $APP_NAME`- if [ $result != "KillMode=$SYSTEMD_KILLMODE" ] ; then- eval echo `gettext 'SYSTEMD_KILLMODE is set to \"${SYSTEMD_KILLMODE}\" on the top of the script, but the daemon is running with $result.'`- eval echo `gettext 'The daemon must be reinstalled for the value of SYSTEMD_KILLMODE to take effect.'`- exit 1- fi-- eval echo `gettext 'Starting $APP_LONG_NAME with systemd...'`-- systemctl start $APP_NAME- if [ $? -ne 0 ] ; then- eval echo `gettext 'Failed to start $APP_LONG_NAME.'`- printlogfilepath- exit 1- fi-- startwait-}--systemdStop() {- # Don't do mustBeRootOrExit because systemd will ask for the password when not root- # The daemon must be running.- checkRunning "1"-- eval echo `gettext 'Stopping $APP_LONG_NAME...'`-- systemctl stop $APP_NAME- if [ $? -ne 0 ] ; then- eval echo `gettext 'Failed to stop $APP_LONG_NAME.'`- exit 1- fi-}--systemdRestart() {- # Don't do mustBeRootOrExit because systemd will ask for the password when not root- checkRunning $1-- eval echo `gettext 'Restarting $APP_LONG_NAME...'`-- systemctl restart $APP_NAME- if [ $? -ne 0 ] ; then- eval echo `gettext 'Failed to restart service $APP_NAME'`- printlogfilepath- exit 1- fi-- startwait-}--systemdRemove() {- stopit "0"- eval echo `gettext ' Removing the $APP_LONG_NAME daemon from systemd...'`- systemctl disable $APP_NAME- rm "/etc/systemd/system/${APP_NAME}.service"- systemctl daemon-reload-}--srcInstall() {- # Always verify that SRC exists.- srcDetection- if [ $? -ne 0 ] ; then- eval echo `gettext 'Unable to install the $APP_LONG_NAME daemon because SRC does not exist.'`- return 1- fi-- if [ "X$RUN_AS_USER" = "X" ] ; then- USERID="0"- else- resolveIdLocation- USERID=`$ID_BIN -u "$RUN_AS_USER"`- if [ $? -ne 0 ] ; then- eval echo `gettext 'Failed to get user id for $RUN_AS_USER'`- exit 1- fi- fi-- validateAppNameLength- /usr/bin/mkssys -s "$APP_NAME" -p "$REALPATH" -a "launchdinternal" -u "$USERID" -f 9 -n 15 -S- /usr/sbin/mkitab "$APP_NAME":2:once:"/usr/bin/startsrc -s \"${APP_NAME}\" >/dev/console 2>&1"-}--srcStart() {- mustBeRootOrExit- mustBeStoppedOrExit-- eval echo `gettext 'Starting $APP_LONG_NAME with SRC...'`-- startsrc -s "${APP_NAME}"- if [ $? -ne 0 ] ; then- eval echo `gettext 'Failed to start $APP_LONG_NAME.'`- printlogfilepath- exit 1- fi-- startwait-}--srcStop() {- mustBeRootOrExit- # The daemon must be running.- checkRunning "1"-- eval echo `gettext 'Stopping $APP_LONG_NAME...'`-- stopsrc -s "${APP_NAME}"- if [ $? -ne 0 ] ; then- eval echo `gettext 'Failed to stop $APP_LONG_NAME.'`- exit 1- fi-}--srcRestart() {- mustBeRootOrExit- checkRunning $1-- if [ "X$pid" != "X" ] ; then- # The daemon was running. Stop it first.- eval echo `gettext 'Restarting $APP_LONG_NAME...'`- srcStop- waitForWrapperStop- fi- srcStart-}--start() {- mustBeStoppedOrExit-- eval echo `gettext 'Starting $APP_LONG_NAME...'`-- prepAdditionalParams "$@"-- # The string passed to eval must handles spaces in paths correctly.- COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.daemonize=TRUE $APPNAMEPROP $ANCHORPROP $IGNOREPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.51 $ADDITIONAL_PARA"- eval "$COMMAND_LINE"-- startwait-}--stopit() {- # $1 exit if down flag- checkRunning $1- if [ $? -eq 0 ] ; then- # The daemon should be running.- eval echo `gettext 'Stopping $APP_LONG_NAME...'`-- if [ "X$IGNORE_SIGNALS" = "X" ]- then- # Running so try to stop it.- kill $pid- if [ $? -ne 0 ]- then- # An explanation for the failure should have been given- eval echo `gettext 'Unable to stop $APP_LONG_NAME.'`- exit 1- fi- else- rm -f "$ANCHORFILE"- if [ -f "$ANCHORFILE" ]- then- # An explanation for the failure should have been given- eval echo `gettext 'Unable to stop $APP_LONG_NAME.'`- exit 1- fi- fi-- # We cannot predict how long it will take for the wrapper to- # actually stop as it depends on settings in wrapper.conf.- # Loop until it does.- savepid=$pid- CNT=0- TOTCNT=0- while [ "X$pid" != "X" ]- do- # Show a waiting message every 5 seconds.- if [ "$CNT" -lt "5" ]- then- CNT=`expr $CNT + 1`- else- eval echo `gettext 'Waiting for $APP_LONG_NAME to exit...'`- CNT=0- fi- TOTCNT=`expr $TOTCNT + 1`-- sleep 1-- # Check if the process is still running.- testpid-- if [ "X$pid" = "X" ]- then- # The process is gone, but it is possible that another instance restarted while we waited...- SAVE_PIDFILE_CHECK_PID=$PIDFILE_CHECK_PID- PIDFILE_CHECK_PID=""- getpid- PIDFILE_CHECK_PID=$SAVE_PIDFILE_CHECK_PID-- if [ "X$pid" != "X" ]- then- # Another process is running.- if [ "$pid" = "$savepid" ]- then- # This should never happen, unless the PID was recycled?- eval echo `gettext 'Failed to stop $APP_LONG_NAME.'`- exit 1- else- eval echo `gettext 'The content of $PIDFILE has changed.'`- eval echo `gettext 'Another instance of the Wrapper might have started in the meantime.'`-- # Exit now. Any further actions might compromise the running instance.- exit 1- fi- fi- fi- done-- eval echo `gettext 'Stopped $APP_LONG_NAME.'`- fi-}--pause() {- getpid- if [ "X$pid" = "X" ] ; then- # The application is not running, print the status- status- else- if [ "$PAUSABLE_MODE" = "file" ] ; then- echo "PAUSE" >> $COMMANDFILE- if [ $? != 0 ] ; then- eval echo `gettext 'Failed to write in the command file to pause $APP_LONG_NAME.'`- exit 1- fi- else- # send a SIGUSR1 (use constants because numbers change depending on the platform)- kill -USR1 $pid 2>/dev/null- if [ $? != 0 ] ; then- kill -SIGUSR1 $pid- if [ $? != 0 ] ; then- eval echo `gettext 'Failed to send a signal to pause $APP_LONG_NAME.'`- exit 1- fi- fi- fi- eval echo `gettext 'Pausing $APP_LONG_NAME.'`- fi-}--resume() {- getpid- if [ "X$pid" = "X" ] ; then- # The application is not running, print the status- status- else- if [ "$PAUSABLE_MODE" = "file" ] ; then- echo "RESUME" >> $COMMANDFILE- if [ $? != 0 ] ; then- eval echo `gettext 'Failed to write in the command file to resume $APP_LONG_NAME.'`- exit 1- fi- else- # send a SIGUSR2 (use constants because numbers change depending on the platform)- kill -USR2 $pid 2>/dev/null- if [ $? != 0 ] ; then- kill -SIGUSR2 $pid- if [ $? != 0 ] ; then- eval echo `gettext 'Failed to send a signal to resume $APP_LONG_NAME.'`- exit 1- fi- fi- fi- eval echo `gettext 'Resuming $APP_LONG_NAME.'`- fi-}--# Get the status of SELinux and sets SELINUX_STATUS-# 0: Not present or unkown-# 1: Disabled-# 2: Permissive (unauthorized access attempts aren't denied but logs are written)-# 3: Enforcing-getSELinuxStatus() {- result=`getenforce 2>/dev/null`- if [ $? -ne 0 ] ; then- # Not present- SELINUX_STATUS=0- else- case "$result" in- 'Disabled')- SELINUX_STATUS=1- ;;- 'Permissive')- SELINUX_STATUS=2- ;;- 'Enforcing')- SELINUX_STATUS=3- ;;- *)- SELINUX_STATUS=0- ;;- esac- fi-}--status() {- checkInstalled- getpid- if [ "X$pid" = "X" ]- then- if [ $installedStatus -eq $SERVICE_NOT_INSTALLED ] ; then- eval echo `gettext '$APP_LONG_NAME \(not installed\) is not running.'`- elif [ "X$installedWith" = "X" ] ; then- eval echo `gettext '$APP_LONG_NAME \(installed\) is not running.'`- else- eval echo `gettext '$APP_LONG_NAME \(installed with $installedWith\) is not running.'`- fi- exit 1- else- if [ "X$DETAIL_STATUS" = "X" ]- then- if [ $installedStatus -eq $SERVICE_NOT_INSTALLED ] ; then- eval echo `gettext '$APP_LONG_NAME \(not installed\) is running: PID:$pid'`- elif [ "X$installedWith" = "X" ] ; then- eval echo `gettext '$APP_LONG_NAME \(installed\) is running: PID:$pid'`- else- eval echo `gettext '$APP_LONG_NAME \(installed with $installedWith\) is running: PID:$pid'`- fi- else- getstatus- if [ $installedStatus -eq $SERVICE_NOT_INSTALLED ] ; then- eval echo `gettext '$APP_LONG_NAME \(not installed\) is running: PID:$pid, Wrapper:$STATUS, Java:$JAVASTATUS'`- elif [ "X$installedWith" = "X" ] ; then- eval echo `gettext '$APP_LONG_NAME \(installed\) is running: PID:$pid, Wrapper:$STATUS, Java:$JAVASTATUS'`- else- eval echo `gettext '$APP_LONG_NAME \(installed with $installedWith\) is running: PID:$pid, Wrapper:$STATUS, Java:$JAVASTATUS'`- fi- fi- exit 0- fi-}--resolveInitdCommand() {- # NOTE: update-rc.d & chkconfig are the recommended interfaces for managing- # init scripts. insserv is a low level tool used by these interfaces.- # chkconfig was available on old versions Ubuntu, but update-rc.d is- # preferred. chkconfig is used on RHEL based Linux.-- # update-rc.d is used on distros such as Debian/Ubuntu- resolveLocation INITD_COMMAND "update-rc.d" ";/usr/sbin" 0- if [ $? -eq 0 ] ; then- USE_UPDATE_RC=1- else- # chkconfig is used on distros such as RHEL or Amazon Linux- resolveLocation INITD_COMMAND chkconfig ";/sbin" 0- if [ $? -eq 0 ] ; then- USE_CHKCONFIG=1- else- # if neither chkconfig nor update-rc.d are present, try insserv- resolveLocation INITD_COMMAND insserv ";/sbin" 0- if [ $? -eq 0 ] ; then- USE_INSSERV=1- else- INITD_COMMAND=""- fi- fi- fi-}--installdaemon() {- mustBeRootOrExit-- checkInstalled- APP_NAME_LOWER=`echo "$APP_NAME" | $TR_BIN "[A-Z]" "[a-z]"`- if [ "$DIST_OS" = "solaris" ] ; then- eval echo `gettext 'Detected Solaris:'`- if [ $installedStatus -ne $SERVICE_NOT_INSTALLED ] ; then- eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'`- else- eval echo `gettext ' Installing the $APP_LONG_NAME daemon...'`- ln -s "$REALPATH" "/etc/init.d/$APP_NAME"- for i in `ls "/etc/rc3.d/K"??"$APP_NAME_LOWER" "/etc/rc3.d/S"??"$APP_NAME_LOWER" 2>/dev/null` ; do- eval echo `gettext ' Removing unexpected file before proceeding: $i'`- rm -f $i- done- ln -s "/etc/init.d/$APP_NAME" "/etc/rc3.d/K${APP_RUN_LEVEL_K}$APP_NAME_LOWER"- ln -s "/etc/init.d/$APP_NAME" "/etc/rc3.d/S${APP_RUN_LEVEL_S}$APP_NAME_LOWER"- fi- elif [ "$DIST_OS" = "linux" ] ; then- eval echo `gettext 'Detected Linux:'`- if [ $installedStatus -ne $SERVICE_NOT_INSTALLED ] ; then- eval echo `gettext ' The $APP_LONG_NAME daemon is already installed with $installedWith.'`- elif [ -n "$USE_SYSTEMD" ] ; then- systemdInstall-- # If SELinux is present and enabled, then the context of the script needs to be updated for systemd to be allowed to execute it.- getSELinuxStatus- if [ $SELINUX_STATUS -ge 2 ] ; then- # Use chcon rather than semanage because it is present on more installations and also allows us to restore the default context more easily.- result=`chcon -t bin_t $REALPATH 2>/dev/null`- if [ $? -ne 0 ] ; then- # Print a warning, but the user can still configure SELinux manually.- SCRIPT_BASENAME=`basename "$REALDIR"`- eval echo `gettext ' WARNING: Could not update the SELinux context of $SCRIPT_BASENAME.'`- fi- fi- elif [ -n "$USE_UPSTART" ] ; then- upstartInstall- else- resolveInitdCommand- if [ -n "$USE_CHKCONFIG" ] ; then- eval echo `gettext ' Installing the $APP_LONG_NAME daemon with init.d \($INITD_COMMAND\)...'`- ln -s "$REALPATH" "/etc/init.d/$APP_NAME"- $INITD_COMMAND --add "$APP_NAME"- $INITD_COMMAND "$APP_NAME" on- elif [ "$USE_INSSERV" ] ; then- eval echo `gettext ' Installing the $APP_LONG_NAME daemon with init.d \($INITD_COMMAND\)...'`- ln -s "$REALPATH" "/etc/init.d/$APP_NAME"- $INITD_COMMAND "/etc/init.d/$APP_NAME"- elif [ "$USE_UPDATE_RC" ] ; then- eval echo `gettext ' Installing the $APP_LONG_NAME daemon with init.d \($INITD_COMMAND\)...'`- ln -s "$REALPATH" "/etc/init.d/$APP_NAME"- $INITD_COMMAND "$APP_NAME" defaults- else- eval echo `gettext ' Installing the $APP_LONG_NAME daemon with init.d...'`- ln -s "$REALPATH" /etc/init.d/$APP_NAME- for i in `ls "/etc/rc3.d/K"??"$APP_NAME_LOWER" "/etc/rc5.d/K"??"$APP_NAME_LOWER" "/etc/rc3.d/S"??"$APP_NAME_LOWER" "/etc/rc5.d/S"??"$APP_NAME_LOWER" 2>/dev/null` ; do- eval echo `gettext ' Removing unexpected file before proceeding: $i'`- rm -f $i- done- ln -s "/etc/init.d/$APP_NAME" "/etc/rc3.d/K${APP_RUN_LEVEL_K}$APP_NAME_LOWER"- ln -s "/etc/init.d/$APP_NAME" "/etc/rc3.d/S${APP_RUN_LEVEL_S}$APP_NAME_LOWER"- ln -s "/etc/init.d/$APP_NAME" "/etc/rc5.d/S${APP_RUN_LEVEL_S}$APP_NAME_LOWER"- ln -s "/etc/init.d/$APP_NAME" "/etc/rc5.d/K${APP_RUN_LEVEL_K}$APP_NAME_LOWER"- fi- fi- elif [ "$DIST_OS" = "hpux" ] ; then- eval echo `gettext 'Detected HP-UX:'`- if [ $installedStatus -ne $SERVICE_NOT_INSTALLED ] ; then- eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'`- else- eval echo `gettext ' Installing the $APP_LONG_NAME daemon...'`- ln -s "$REALPATH" "/sbin/init.d/$APP_NAME"- for i in `ls "/sbin/rc3.d/K"??"$APP_NAME_LOWER" "/sbin/rc3.d/S"??"$APP_NAME_LOWER" 2>/dev/null` ; do- eval echo `gettext ' Removing unexpected file before proceeding: $i'`- rm -f $i- done- ln -s "/sbin/init.d/$APP_NAME" "/sbin/rc3.d/K${APP_RUN_LEVEL_K}$APP_NAME_LOWER"- ln -s "/sbin/init.d/$APP_NAME" "/sbin/rc3.d/S${APP_RUN_LEVEL_S}$APP_NAME_LOWER"- fi- elif [ "$DIST_OS" = "aix" ] ; then- eval echo `gettext 'Detected AIX:'`- if [ $installedStatus -ne $SERVICE_NOT_INSTALLED -a $installedStatus -ne $SERVICE_INSTALLED_SRC_PARTIAL ] ; then- eval echo `gettext ' The $APP_LONG_NAME daemon is already installed with $installedWith.'`- else- eval echo `gettext ' Installing the $APP_LONG_NAME daemon...'`- if [ -n "`/usr/sbin/lsitab install_assist`" ] ; then- eval echo `gettext ' The task /usr/sbin/install_assist was found in the inittab, this might cause problems for all subsequent tasks to launch as this process is known to block the init task. Please make sure this task is not needed anymore and remove/deactivate it.'`- fi-- for i in `ls "/etc/rc.d/rc2.d/K"??"$APP_NAME_LOWER" "/etc/rc.d/rc2.d/S"??"$APP_NAME_LOWER" 2>/dev/null` ; do- eval echo `gettext ' Removing unexpected file before proceeding: $i'`- rm -f $i- done-- if [ -n "$USE_SRC" ] ; then- srcInstall- else- # install using initd- ln -s "$REALPATH" "/etc/rc.d/init.d/$APP_NAME"- ln -s "/etc/rc.d/init.d/$APP_NAME" "/etc/rc.d/rc2.d/K${APP_RUN_LEVEL_K}$APP_NAME_LOWER"- ln -s "/etc/rc.d/init.d/$APP_NAME" "/etc/rc.d/rc2.d/S${APP_RUN_LEVEL_S}$APP_NAME_LOWER"- fi- fi- elif [ "$DIST_OS" = "freebsd" ] ; then- eval echo `gettext 'Detected FreeBSD:'`- if [ $installedStatus -ne $SERVICE_NOT_INSTALLED ] ; then- eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'`- else- eval echo `gettext ' Installing the $APP_LONG_NAME daemon...'`- sed -i.bak "/${APP_NAME}_enable=\"YES\"/d" /etc/rc.conf- if [ -f "${REALDIR}/${APP_NAME}.install" ] ; then- ln -s "${REALDIR}/${APP_NAME}.install" "/etc/rc.d/$APP_NAME"- else- echo '#!/bin/sh' > "/etc/rc.d/$APP_NAME"- echo "#" >> "/etc/rc.d/$APP_NAME"- echo "# PROVIDE: $APP_NAME" >> "/etc/rc.d/$APP_NAME"- echo "# REQUIRE: NETWORKING" >> "/etc/rc.d/$APP_NAME"- echo "# KEYWORD: shutdown" >> "/etc/rc.d/$APP_NAME"- echo ". /etc/rc.subr" >> "/etc/rc.d/$APP_NAME"- echo "name=\"$APP_NAME\"" >> "/etc/rc.d/$APP_NAME"- echo "rcvar=\`set_rcvar\`" >> "/etc/rc.d/$APP_NAME"- echo "command=\"${REALPATH}\"" >> "/etc/rc.d/$APP_NAME"- echo 'start_cmd="${name}_start"' >> "/etc/rc.d/$APP_NAME"- echo 'load_rc_config $name' >> "/etc/rc.d/$APP_NAME"- echo 'status_cmd="${name}_status"' >> "/etc/rc.d/$APP_NAME"- echo 'stop_cmd="${name}_stop"' >> "/etc/rc.d/$APP_NAME"- echo "${APP_NAME}_status() {" >> "/etc/rc.d/$APP_NAME"- echo '${command} status' >> "/etc/rc.d/$APP_NAME"- echo '}' >> "/etc/rc.d/$APP_NAME"- echo "${APP_NAME}_stop() {" >> "/etc/rc.d/$APP_NAME"- echo '${command} stop' >> "/etc/rc.d/$APP_NAME"- echo '}' >> "/etc/rc.d/$APP_NAME"- echo "${APP_NAME}_start() {" >> "/etc/rc.d/$APP_NAME"- echo '${command} start' >> "/etc/rc.d/$APP_NAME"- echo '}' >> "/etc/rc.d/$APP_NAME"- echo 'run_rc_command "$1"' >> "/etc/rc.d/$APP_NAME"- fi- echo "${APP_NAME}_enable=\"YES\"" >> /etc/rc.conf- chmod 555 "/etc/rc.d/$APP_NAME"- fi- elif [ "$DIST_OS" = "macosx" ] ; then- eval echo `gettext 'Detected Mac OSX:'`- if [ $installedStatus -ne $SERVICE_NOT_INSTALLED ] ; then- eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'`- else- eval echo `gettext ' Installing the $APP_LONG_NAME daemon...'`- if [ -f "${REALDIR}/${APP_PLIST}" ] ; then- ln -s "${REALDIR}/${APP_PLIST}" "/Library/LaunchDaemons/${APP_PLIST}"- else- echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > "/Library/LaunchDaemons/${APP_PLIST}"- echo "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\"" >> "/Library/LaunchDaemons/${APP_PLIST}"- echo "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" >> "/Library/LaunchDaemons/${APP_PLIST}"- echo "<plist version=\"1.0\">" >> "/Library/LaunchDaemons/${APP_PLIST}"- echo " <dict>" >> "/Library/LaunchDaemons/${APP_PLIST}"- echo " <key>Label</key>" >> "/Library/LaunchDaemons/${APP_PLIST}"- echo " <string>${APP_PLIST_BASE}</string>" >> "/Library/LaunchDaemons/${APP_PLIST}"- echo " <key>ProgramArguments</key>" >> "/Library/LaunchDaemons/${APP_PLIST}"- echo " <array>" >> "/Library/LaunchDaemons/${APP_PLIST}"- echo " <string>${REALPATH}</string>" >> "/Library/LaunchDaemons/${APP_PLIST}"- echo " <string>launchdinternal</string>" >> "/Library/LaunchDaemons/${APP_PLIST}"- echo " </array>" >> "/Library/LaunchDaemons/${APP_PLIST}"- echo " <key>${KEY_KEEP_ALIVE}</key>" >> "/Library/LaunchDaemons/${APP_PLIST}"- echo " <${MACOSX_KEEP_RUNNING}/>" >> "/Library/LaunchDaemons/${APP_PLIST}"- echo " <key>RunAtLoad</key>" >> "/Library/LaunchDaemons/${APP_PLIST}"- echo " <true/>" >> "/Library/LaunchDaemons/${APP_PLIST}"- if [ "X$RUN_AS_USER" != "X" ] ; then- echo " <key>UserName</key>" >> "/Library/LaunchDaemons/${APP_PLIST}"- echo " <string>${RUN_AS_USER}</string>" >> "/Library/LaunchDaemons/${APP_PLIST}"- fi- echo " </dict>" >> "/Library/LaunchDaemons/${APP_PLIST}"- echo "</plist>" >> "/Library/LaunchDaemons/${APP_PLIST}"- fi- chmod 555 "/Library/LaunchDaemons/${APP_PLIST}"- fi- elif [ "$DIST_OS" = "zos" ] ; then- eval echo `gettext 'Detected z/OS:'`- if [ $installedStatus -ne $SERVICE_NOT_INSTALLED ] ; then- eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'`- else- eval echo `gettext ' Installing the $APP_LONG_NAME daemon...'`- cp /etc/rc /etc/rc.bak- sed "s:echo /etc/rc script executed, \`date\`::g" /etc/rc.bak > /etc/rc- echo "_BPX_JOBNAME='${APP_NAME}' \"${REALDIR}/${APP_NAME}\" start" >>/etc/rc- echo '/etc/rc script executed, `date`' >>/etc/rc- fi- else- eval echo `gettext 'Install not currently supported for $DIST_OS.'`- exit 1- fi-- # Exit with 1 if the daemon was already installed when calling installdaemon().- # The test below requires $installedStatus to be unchanged since the call to- # checkInstalled() at the beginning of the function. If the script was launched- # with 'installstart' we want to start normally, so don't exit here.- if [ $installedStatus -ne $SERVICE_NOT_INSTALLED -a "$COMMAND" != 'installstart' ] ; then- exit 1- fi-- # Check again the installation status. The script should exit with 1 if the service- # could not be installed (even if it was launched with 'installstart').- checkInstalled- if [ $installedStatus -eq $SERVICE_NOT_INSTALLED ] ; then- eval echo `gettext 'Service not installed.'`- exit 1- fi-}--startdaemon() {- getServiceControlMethod- if [ "$CTRL_WITH_LAUNCHD" = "true" ] ; then- macosxStart- elif [ "$CTRL_WITH_UPSTART" = "true" ] ; then- upstartStart- elif [ "$CTRL_WITH_SYSTEMD" = "true" ] ; then- systemdStart- elif [ "$CTRL_WITH_SRC" = "true" ] ; then- srcStart- else- if [ -n "$SYSD" ] ; then- shift- fi-- checkRunUser touchlock "$@"- if [ ! -n "$FIXED_COMMAND" ] ; then- shift- fi-- if [ "$SERVICE_MANAGEMENT_TOOL" != "auto" -a "$SERVICE_MANAGEMENT_TOOL" != "initd" ] ; then- eval echo `gettext 'Starting without using the configured service management tool \"$SERVICE_MANAGEMENT_TOOL\" because the service $APP_NAME is not installed.'`- fi-- start "$@"- fi-}--restartdaemon() {- getServiceControlMethod- if [ "$CTRL_WITH_LAUNCHD" = "true" ] ; then- macosxRestart $1- elif [ "$CTRL_WITH_UPSTART" = "true" ] ; then- upstartRestart $1- elif [ "$CTRL_WITH_SYSTEMD" = "true" ] ; then- systemdRestart $1- elif [ "$CTRL_WITH_SRC" = "true" ] ; then- srcRestart $1- else- checkRunUser touchlock "$COMMAND"-- checkRunning $1- if [ "X$pid" != "X" ] ; then- # The daemon was running. Stop it first.- eval echo `gettext 'Restarting $APP_LONG_NAME...'`- stopit $1- fi- shift- if [ ! -n "$FIXED_COMMAND" ] ; then- shift- fi- start "$@"- fi-}--isBitSet() {- if [ `expr \( $1 / $2 \) % 2` -eq 1 ]; then- return 1- else- return 0- fi-}--removedaemon() {- mustBeRootOrExit-- checkInstalled- APP_NAME_LOWER=`echo "$APP_NAME" | $TR_BIN "[A-Z]" "[a-z]"`- if [ "$DIST_OS" = "solaris" ] ; then- eval echo `gettext 'Detected Solaris:'`- isBitSet $installedStatus $SERVICE_INSTALLED_DEFAULT- if [ $? -eq 1 ] ; then- stopit "0"- eval echo `gettext ' Removing the $APP_LONG_NAME daemon...'`- for i in `ls "/etc/rc3.d/K"??"$APP_NAME_LOWER" "/etc/rc3.d/S"??"$APP_NAME_LOWER" "/etc/init.d/$APP_NAME" 2>/dev/null` ; do- rm -f $i- done- else- eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'`- exit 1- fi- elif [ "$DIST_OS" = "linux" ] ; then- eval echo `gettext 'Detected Linux:'`- isBitSet $installedStatus $SERVICE_INSTALLED_SYSTEMD- if [ $? -eq 1 ] ; then- systemdRemove-- # Always try to restore the SELinux context.- result=`restorecon $REALPATH 2>/dev/null`- if [ $? -ne 0 ] ; then- # Only print a warning if 'restorecon' exists or if SELinux is present.- getSELinuxStatus- result=`command -v restorecon 2>/dev/null`- if [ $? -eq 0 -o $SELINUX_STATUS -gt 0 ] ; then- SCRIPT_BASENAME=`basename "$REALDIR"`- eval echo `gettext ' WARNING: Could not restore the SELinux context of $SCRIPT_BASENAME.'`- fi- fi- fi- isBitSet $installedStatus $SERVICE_INSTALLED_UPSTART- if [ $? -eq 1 ] ; then- upstartRemove- fi- isBitSet $installedStatus $SERVICE_INSTALLED_DEFAULT- if [ $? -eq 1 ] ; then- stopit "0"- eval echo `gettext ' Removing the $APP_LONG_NAME daemon from init.d...'`- resolveInitdCommand- if [ -n "$USE_CHKCONFIG" ] ; then- $INITD_COMMAND "$APP_NAME" off- $INITD_COMMAND --del "$APP_NAME"- rm -f "/etc/init.d/$APP_NAME"- elif [ "$USE_INSSERV" ] ; then- $INITD_COMMAND -r "/etc/init.d/$APP_NAME"- rm -f "/etc/init.d/$APP_NAME"- elif [ "$USE_UPDATE_RC" ] ; then- $INITD_COMMAND -f "$APP_NAME" remove- rm -f "/etc/init.d/$APP_NAME"- else- for i in `ls "/etc/rc3.d/K"??"$APP_NAME_LOWER" "/etc/rc5.d/K"??"$APP_NAME_LOWER" "/etc/rc3.d/S"??"$APP_NAME_LOWER" "/etc/rc5.d/S"??"$APP_NAME_LOWER" "/etc/init.d/$APP_NAME" 2>/dev/null` ; do- rm -f $i- done- fi- fi- if [ $installedStatus -eq $SERVICE_NOT_INSTALLED ] ; then- eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'`- exit 1- fi- elif [ "$DIST_OS" = "hpux" ] ; then- eval echo `gettext 'Detected HP-UX:'`- isBitSet $installedStatus $SERVICE_INSTALLED_DEFAULT- if [ $? -eq 1 ] ; then- stopit "0"- eval echo `gettext ' Removing the $APP_LONG_NAME daemon...'`- for i in `ls "/sbin/rc3.d/K"??"$APP_NAME_LOWER" "/sbin/rc3.d/S"??"$APP_NAME_LOWER" "/sbin/init.d/$APP_NAME" 2>/dev/null` ; do- rm -f $i- done- else- eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'`- exit 1- fi- elif [ "$DIST_OS" = "aix" ] ; then- eval echo `gettext 'Detected AIX:'`- if [ $installedStatus -ne $SERVICE_NOT_INSTALLED ] ; then- stopit "0"- eval echo `gettext ' Removing the $APP_LONG_NAME daemon...'`- isBitSet $installedStatus $SERVICE_INSTALLED_DEFAULT- if [ $? -eq 1 ] ; then- for i in `ls "/etc/rc.d/rc2.d/K"??"$APP_NAME_LOWER" "/etc/rc.d/rc2.d/S"??"$APP_NAME_LOWER" "/etc/rc.d/init.d/$APP_NAME" 2>/dev/null` ; do- rm -f $i- done- fi- isBitSet $installedStatus $SERVICE_INSTALLED_SRC- isSrcSet=$?- isBitSet $installedStatus $SERVICE_INSTALLED_SRC_PARTIAL- isSrcPartialSet=$?- if [ $isSrcSet -eq 1 -o $isSrcPartialSet -eq 1 ] ; then- validateAppNameLength- /usr/sbin/rmitab $APP_NAME- /usr/bin/rmssys -s $APP_NAME- fi- else- eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'`- exit 1- fi- elif [ "$DIST_OS" = "freebsd" ] ; then- eval echo `gettext 'Detected FreeBSD:'`- if [ -f "/etc/rc.d/$APP_NAME" -o -L "/etc/rc.d/$APP_NAME" ] ; then- stopit "0"- eval echo `gettext ' Removing the $APP_LONG_NAME daemon...'`- for i in "/etc/rc.d/$APP_NAME"- do- rm -f $i- done- sed -i.bak "/${APP_NAME}_enable=\"YES\"/d" /etc/rc.conf- else- eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'`- exit 1- fi- elif [ "$DIST_OS" = "macosx" ] ; then- eval echo `gettext 'Detected Mac OSX:'`- if [ -f "/Library/LaunchDaemons/${APP_PLIST}" -o -L "/Library/LaunchDaemons/${APP_PLIST}" ] ; then- stopit "0"- eval echo `gettext ' Removing the $APP_LONG_NAME daemon...'`- # Make sure the plist is installed- LOADED_PLIST=`launchctl list | grep ${APP_PLIST_BASE}`- if [ "X${LOADED_PLIST}" != "X" ] ; then- launchctl unload "/Library/LaunchDaemons/${APP_PLIST}"- fi- rm -f "/Library/LaunchDaemons/${APP_PLIST}"- else- eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'`- exit 1- fi- elif [ "$DIST_OS" = "zos" ] ; then- eval echo `gettext 'Detected z/OS:'`- if [ -f /etc/rc.bak ] ; then- stopit "0"- eval echo `gettext ' Removing the $APP_LONG_NAME daemon...'`- cp /etc/rc /etc/rc.bak- sed "s/_BPX_JOBNAME=\'APP_NAME\'.*//g" /etc/rc.bak > /etc/rc- rm /etc/rc.bak- else- eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'`- exit 1- fi- else- eval echo `gettext 'Remove not currently supported for $DIST_OS.'`- exit 1- fi-}--dump() {- eval echo `gettext 'Dumping $APP_LONG_NAME...'`- getpid- if [ "X$pid" = "X" ]- then- eval echo `gettext '$APP_LONG_NAME was not running.'`- else- kill -3 $pid-- if [ $? -ne 0 ]- then- eval echo `gettext 'Failed to dump $APP_LONG_NAME.'`- exit 1- else- eval echo `gettext 'Dumped $APP_LONG_NAME.'`- fi- fi-}--# Used by HP-UX init scripts.-startmsg() {- getpid- if [ "X$pid" = "X" ]- then- eval echo `gettext 'Starting $APP_LONG_NAME... Wrapper:Stopped'`- else- if [ "X$DETAIL_STATUS" = "X" ]- then- eval echo `gettext 'Starting $APP_LONG_NAME... Wrapper:Running'`- else- getstatus- eval echo `gettext 'Starting $APP_LONG_NAME... Wrapper:$STATUS, Java:$JAVASTATUS'`- fi- fi-}--# Used by HP-UX init scripts.-stopmsg() {- getpid- if [ "X$pid" = "X" ]- then- eval echo `gettext 'Stopping $APP_LONG_NAME... Wrapper:Stopped'`- else- if [ "X$DETAIL_STATUS" = "X" ]- then- eval echo `gettext 'Stopping $APP_LONG_NAME... Wrapper:Running'`- else- getstatus- eval echo `gettext 'Stopping $APP_LONG_NAME... Wrapper:$STATUS, Java:$JAVASTATUS'`- fi- fi-}--# 'source' files-sourceFiles() {- if [ -n "$FILES_TO_SOURCE" ] ; then- OIFS=$IFS- IFS=';'- files=$FILES_TO_SOURCE- for file in $files- do- . $file- done-- IFS=$OIFS- fi-}--# Check if arguments are correct. This needs to be done after knowing the-# command, the application name and OS (to check the installation status).-# NOTE: When the validity of the arguments depends on the daemon installation,-# make sure to call setServiceManagementTool() before this function.-#-# $1 0: no parameter allowed-# -1: parameter allowed if not installed-# 1: parameter allowed-checkArguments() {- # If this is a systemd call (from the systemd service file), we don't want- # to check arguments ('sysd' itself should not be blocking and the user- # may also have edited the file and added additional args in it).- if [ -n "$SYSD" ] ; then- return- fi-- if [ -n "$FIRST_ARG" ] ; then- if [ $1 = -1 ] ; then- checkInstalled "strict"- if [ $installedStatus -eq $SERVICE_NOT_INSTALLED ] ; then- PASS_THROUGH_ALLOWED=true- fi- elif [ $1 = 1 ] ; then- PASS_THROUGH_ALLOWED=true- fi-- if [ "X${PASS_THROUGH_ALLOWED}" != "Xtrue" ] ; then- eval echo `gettext 'Additional arguments are not allowed with the ${COMMAND} command.'`-- if [ -n "$FIXED_COMMAND" ] ; then- # The command can't be used with PASS_THROUGH, so disable it to show appropriate usage.- PASS_THROUGH=false- fi- showUsage- exit 2 # LSB - invalid or excess argument(s)- elif [ "X${PASS_THROUGH}" = "Xfalse" ] ; then- eval echo `gettext 'Additional arguments are not allowed when PASS_THROUGH is set to false.'`- showUsage- exit 2 # LSB - invalid or excess argument(s)- fi- fi-}--docommand() {-- case "$COMMAND" in- 'console')- checkArguments 1- # trap signals (this must be done before changing the user)- consoleTrapSignals- checkRunUser touchlock "$@"- if [ ! -n "$FIXED_COMMAND" ] ; then- shift- fi- console "$@"- ;;-- 'start')- setServiceManagementTool- checkArguments -1- startdaemon "$@"- ;;-- 'stop')- checkArguments 0- setServiceManagementTool- getServiceControlMethod- if [ "$CTRL_WITH_LAUNCHD" = "true" ] ; then- macosxStop- elif [ "$CTRL_WITH_UPSTART" = "true" ] ; then- upstartStop- elif [ "$CTRL_WITH_SYSTEMD" = "true" ] ; then- systemdStop- elif [ "$CTRL_WITH_SRC" = "true" ] ; then- srcStop- else- checkRunUser "" "$COMMAND"- stopit "0"- fi- ;;-- 'restart')- setServiceManagementTool- checkArguments -1- restartdaemon "0" "$@"- ;;-- 'condrestart')- setServiceManagementTool- checkArguments -1- restartdaemon "1" "$@"- ;;-- 'pause')- checkArguments 0- setServiceManagementTool- if [ -n "$PAUSABLE" ]- then- pause- else- showUsage "$COMMAND"- fi- ;;-- 'resume')- checkArguments 0- setServiceManagementTool- if [ -n "$PAUSABLE" ]- then- resume- else- showUsage "$COMMAND"- fi- ;;-- 'status')- checkArguments 0- setServiceManagementTool- status- ;;-- 'install')- checkArguments 0- setServiceManagementTool- installdaemon "$@"- ;;-- 'installstart')- checkArguments 0- setServiceManagementTool- installdaemon "$@"- startdaemon "$@"- ;;-- 'remove')- checkArguments 0- setServiceManagementTool- removedaemon- ;;-- 'dump')- checkArguments 0- checkRunUser "" "$COMMAND"- dump- ;;-- 'start_msg')- # Internal command called by launchd on HP-UX.- checkRunUser "" "$COMMAND"- startmsg- ;;-- 'stop_msg')- # Internal command called by launchd on HP-UX.- checkRunUser "" "$COMMAND"- stopmsg- ;;-- 'launchdinternal' | 'upstartinternal')- if [ ! "$DIST_OS" = "macosx" -o ! -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then- checkRunUser touchlock "$@"- fi- # Internal command called by launchd on Max OSX.- # We do not want to call checkRunUser here as it is handled in the launchd plist file. Doing it here would confuse launchd.- if [ ! -n "$FIXED_COMMAND" ] ; then- shift- fi- launchinternal "$@"- ;;-- *)- showUsage "$COMMAND"- ;;- esac-}--sourceFiles-docommand "$@"--exit 0diff --git a/server-product/jsw/AppCommand.bat.in b/server-product/jsw/AppCommand.bat.indeleted file mode 100644index 29ad9efed4..0000000000--- a/server-product/jsw/AppCommand.bat.in+++ /dev/null@@ -1,326 +0,0 @@-@echo off-setlocal--rem-rem Copyright (c) 1999, 2022 Tanuki Software, Ltd.-rem http://www.tanukisoftware.com-rem All rights reserved.-rem-rem This software is the proprietary information of Tanuki Software.-rem You shall use it only in accordance with the terms of the-rem license agreement you entered into with Tanuki Software.-rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html-rem-rem Java Service Wrapper command based script.-rem--rem ------------------------------------------------------------------------------rem These settings can be modified to fit the needs of your application-rem Optimized for use with version 3.5.51-st of the Wrapper.--rem The base name for the Wrapper binary.-set _WRAPPER_BASE=wrapper--rem The directory where the Wrapper binary (.exe) file is located. It can be-rem either an absolute or a relative path. If the path contains any special-rem characters, please make sure to quote the variable.-set _WRAPPER_DIR=../boot--rem The name and location of the Wrapper configuration file. This will be used-rem if the user does not specify a configuration file as the first parameter to-rem this script.-set _WRAPPER_CONF="../conf/%_WRAPPER_BASE%.conf"--rem _FIXED_COMMAND tells the script to use a hard coded command rather than-rem expecting the first parameter of the command line to be the command.-rem By default the command will will be expected to be the first parameter.-@set_fixed_command@--rem _PASS_THROUGH controls how the script arguments should be passed to the-rem Wrapper. Possible values are:-rem - commented or 'false': the arguments will be ignored (not passed).-rem - 'app_args' or 'true': the arguments will be passed through the Wrapper as-rem arguments for the Java Application.-rem - 'both': both Wrapper properties and Application arguments can be passed to-rem the Wrapper. The Wrapper properties come in first position. The-rem user can optionally add a '--' separator followed by application-rem arguments.-rem NOTE - If _FIXED_COMMAND is set to true the above applies to all arguments,-rem otherwise it applies to arguments starting with the second.-rem NOTE - Passing arguments is only valid with the 'console', 'install',-rem 'installstart' and 'update' commands.-@set_pass_through@--rem If there are any errors, the script will pause for a specific number of seconds-rem or until the user presses a key. (0 not to wait, negative to wait forever).-set _WRAPPER_TIMEOUT=-1--rem Do not modify anything beyond this point-rem -------------------------------------------------------------------------------if "%OS%"=="Windows_NT" goto nt-echo This script only works with NT-based versions of Windows.-goto :eof--:nt-rem Find the application home.-rem if no path path specified do the default action-IF not DEFINED _WRAPPER_DIR goto dir_undefined-set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%"-if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\"-rem check if absolute path-if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path-if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path-rem everythig else means relative path-set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%"-goto pathfound--:dir_undefined-rem Use a relative path to the wrapper %~dp0 is location of current script under NT-set _REALPATH="%~dp0"-goto pathfound-:absolute_path-rem Use an absolute path to the wrapper-set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%"--:pathfound-rem-rem Decide on the specific Wrapper binary to use (See delta-pack)-rem-if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64-if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64-if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64-:x86_32-set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe"-set _BIN_BITS="32"-goto search-:amd64-set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe"-set _BIN_BITS="64"-goto search-:ia64-set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe"-set _BIN_BITS="64"-goto search-:search-set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%"-if exist %_WRAPPER_EXE% goto check_lic_bits-set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe"-if exist %_WRAPPER_EXE% goto conf-if %_BIN_BITS%=="64" goto x86_32-echo Unable to locate a Wrapper executable using any of the following names:-echo %_WRAPPER_L_EXE%-echo %_WRAPPER_EXE%-goto preexitpause--:check_lic_bits-rem The command should not be called inside a IF, else errorlevel would be 0-if not %_BIN_BITS%=="64" goto conf-%_WRAPPER_EXE% --request_delta_binary_bits %_WRAPPER_CONF% > nul 2>&1-if %errorlevel% equ 32 (- set _LIC32_OS64=true- goto x86_32-)--:conf-if [%_PASS_THROUGH%]==[true] (- set _PASS_THROUGH=app_args-)-if [%_PASS_THROUGH%]==[app_args] (- @passthrough_parameters@- set ARGS_ARE_APP_PARAMS=true- set _PASS_THROUGH_ON=true-)-if [%_PASS_THROUGH%]==[both] (- set _PASS_THROUGH_ON=true-)-if not [%_PASS_THROUGH_ON%]==[true] (- set _PASS_THROUGH=false-)--set _SCRIPT_NAME=%~n0--if not [%_FIXED_COMMAND%]==[] (- set _COMMAND=%_FIXED_COMMAND%-) else (- set _COMMAND=%1- shift-)--rem Check the command-if [%_COMMAND%]==[console] goto args_allowed-if [%_COMMAND%]==[setup] goto args_not_allowed-if [%_COMMAND%]==[teardown] goto args_not_allowed-if [%_COMMAND%]==[start] goto args_not_allowed-if [%_COMMAND%]==[stop] goto args_not_allowed-if [%_COMMAND%]==[install] goto args_allowed-if [%_COMMAND%]==[installstart] goto args_allowed-if [%_COMMAND%]==[update] goto args_allowed-if [%_COMMAND%]==[pause] goto args_not_allowed-if [%_COMMAND%]==[resume] goto args_not_allowed-if [%_COMMAND%]==[status] goto args_not_allowed-if [%_COMMAND%]==[remove] goto args_not_allowed-if [%_COMMAND%]==[restart] goto args_not_allowed--rem The command is invalid-if [%_FIXED_COMMAND%]==[] (- echo Unexpected command: %_COMMAND%- echo.- goto showusage-) else (- echo Invalid value '%_COMMAND%' for _FIXED_COMMAND.- goto preexitpause-)--:args_not_allowed-if not [%1]==[] (- echo Additional arguments are not allowed with the %_COMMAND% command.- if not [%_FIXED_COMMAND%]==[] (- rem The command can't be used with PASS_THROUGH, so disable it to show appropriate usage.- set _PASS_THROUGH=false- )- goto showusage-)--:args_allowed-if not [%1]==[] (- if [%_PASS_THROUGH%]==[false] (- echo Additional arguments are not allowed when _PASS_THROUGH is set to false.- goto preexitpause- )-)--rem Collect all parameters-:parameters-if [%1]==[] goto callcommand-if [%ARGS_ARE_APP_PARAMS%]==[true] goto append-if [%1]==[--] (- set ARGS_ARE_APP_PARAMS=true- goto append-)-rem So we are appending a wrapper property.-rem 1) Check it is wrapped inside double quotes.-if not ["%~1"]==[%1] (- if not [%_MISSING_QUOTES_REPORTED%]==[true] (- set _MISSING_QUOTES_REPORTED=true- echo WARNING: Any property assignment before '--' should be wrapped inside double quotes on Windows. In a powershell prompt command, double quotes should be escaped with backquote characters ^(^`^).- )- rem If not wrapped inside quotes, the following tests are not relevant, so skip them. Should we stop? We always used to continue.. but the Wrapper will probably fail.- goto append-)-rem 2) Check that the arg matches the pattern of a property (the command should be outside of a IF block for errorlevel to be correct)-echo %1 | findstr ^wrapper\..*\=.*$ > nul 2>&1-if %errorlevel% equ 0 goto append-echo %1 | findstr ^.*\=.*$ > nul 2>&1-if %errorlevel% equ 0 goto unkown_property-rem Not a valid assignment.-echo WARNING: Encountered an invalid configuration property assignment '%~1'. When PASS_THROUGH is set to 'both', any argument before '--' should be in the format '^<property_name^>=^<value^>'.-goto append-:unkown_property-rem The property name is not starting with 'wrapper.' so invalid.-rem Extract the property name (this should be outside of a IF-ELSE block)-for /f "tokens=1* delims==" %%a in ("%~1") do set _COMMAND_PROP=%%a-echo WARNING: Encountered an unknown configuration property '%_COMMAND_PROP%'. When PASS_THROUGH is set to 'both', any argument before '--' should target a valid Wrapper configuration property.-:append-set _PARAMETERS=%_PARAMETERS% %1-shift-goto parameters--rem-rem Run the Wrapper-rem-:callcommand-if [%_COMMAND%]==[console] (- %_WRAPPER_EXE% -c "%_WRAPPER_CONF%" @properties_and_parameters@ %_PARAMETERS%-) else if [%_COMMAND%]==[setup] (- %_WRAPPER_EXE% -su "%_WRAPPER_CONF%"-) else if [%_COMMAND%]==[teardown] (- %_WRAPPER_EXE% -td "%_WRAPPER_CONF%"-) else if [%_COMMAND%]==[start] (- call :start-) else if [%_COMMAND%]==[stop] (- call :stop-) else if [%_COMMAND%]==[install] (- %_WRAPPER_EXE% -i "%_WRAPPER_CONF%" %_PARAMETERS%-) else if [%_COMMAND%]==[installstart] (- %_WRAPPER_EXE% -it "%_WRAPPER_CONF%" %_PARAMETERS%-) else if [%_COMMAND%]==[update] (- %_WRAPPER_EXE% -u "%_WRAPPER_CONF%" %_PARAMETERS%-) else if [%_COMMAND%]==[pause] (- %_WRAPPER_EXE% -a "%_WRAPPER_CONF%"-) else if [%_COMMAND%]==[resume] (- %_WRAPPER_EXE% -e "%_WRAPPER_CONF%"-) else if [%_COMMAND%]==[status] (- %_WRAPPER_EXE% -q "%_WRAPPER_CONF%"-) else if [%_COMMAND%]==[remove] (- %_WRAPPER_EXE% -r "%_WRAPPER_CONF%"-) else if [%_COMMAND%]==[restart] (- call :stop- call :start-)-if not errorlevel 1 goto :eof-goto preexitpause--:start- %_WRAPPER_EXE% -t "%_WRAPPER_CONF%"- goto :eof-:stop- %_WRAPPER_EXE% -p "%_WRAPPER_CONF%"- goto :eof--:showusage-if [%_PASS_THROUGH%]==[app_args] (- set ARGS= {JavaAppArgs}-) else if [%_PASS_THROUGH%]==[both] (- set ARGS= {WrapperProperties} [-- {JavaAppArgs}]-) else (- set ARGS=-)--if [%_FIXED_COMMAND%]==[] (- echo Usage: %_SCRIPT_NAME% [ console%ARGS% : start : stop : restart : pause : resume : status : install%ARGS% : installstart%ARGS% : update%ARGS% : remove : setup : teardown ]- echo.- echo Commands:- echo console Launch in the current console.- echo start Start the Service.- echo stop Stop the Service.- echo restart Stop the Service if running and then start.- echo pause Pause the Service if running.- echo resume Resume the Service if paused.- echo status Query the current status of the Service.- echo install Install the Service.- echo installstart Install the Service and then start running it.- echo update Update an installed Service.- echo remove Uninstall the Service.- echo setup Setup the Wrapper ^(for registration to the Windows Event Log^).- echo teardown Teardown the Wrapper ^(unregister from the Windows Event Log^).- echo.-) else (- echo Usage: %_SCRIPT_NAME%%ARGS%-)-if not [%_PASS_THROUGH%]==[false] (- if [%_PASS_THROUGH%]==[both] (- echo WrapperProperties:- echo Optional configuration properties which will be passed to the Wrapper.- echo.- )- echo JavaAppArgs:- echo Optional arguments which will be passed to the Java application.- echo.-)--rem Exit when there is a problem-:preexitpause-if %errorlevel% equ 0 (- set EXIT_CODE=1-) else (- set EXIT_CODE=%errorlevel%-)-if %_WRAPPER_TIMEOUT% gtr 0 (- timeout /t %_WRAPPER_TIMEOUT%-) else (- if %_WRAPPER_TIMEOUT% lss 0 (- pause- )-)-EXIT /B %EXIT_CODE%diff --git a/server-product/jsw/agent-license.conf b/server-product/jsw/agent-license.confdeleted file mode 100644index 4f1d391377..0000000000--- a/server-product/jsw/agent-license.conf+++ /dev/null@@ -1,13 +0,0 @@-#encoding=UTF-8-wrapper.license.type=DEV-wrapper.license.id=202301070000002-wrapper.license.licensee=OneDev-wrapper.license.group=service wrapping-wrapper.license.dev_application=Service Wrapping-wrapper.license.features=64bit-wrapper.license.upgrade_term.begin_date=2020-11-09-wrapper.license.upgrade_term.end_date=2023-04-26-wrapper.license.key.1=738d-5fef-1202-50e7-wrapper.license.key.2=83dc-f00f-75b5-ec96-wrapper.license.key.3=6cbf-9de8-6d47-3f89-wrapper.license.key.4=a169-5d98-4bf8-e647\ No newline at end of filediff --git a/server-product/jsw/server-license.conf b/server-product/jsw/server-license.confdeleted file mode 100644index d0f622787e..0000000000--- a/server-product/jsw/server-license.conf+++ /dev/null@@ -1,13 +0,0 @@-#encoding=UTF-8-wrapper.license.type=DEV-wrapper.license.id=202301070000001-wrapper.license.licensee=OneDev-wrapper.license.group=service wrapping-wrapper.license.dev_application=Service Wrapping-wrapper.license.features=64bit-wrapper.license.upgrade_term.begin_date=2020-11-09-wrapper.license.upgrade_term.end_date=2023-04-26-wrapper.license.key.1=1c59-d3d6-2ada-026a-wrapper.license.key.2=7eb6-f935-f3e7-29df-wrapper.license.key.3=a1ad-a6bd-ea47-fc5c-wrapper.license.key.4=9e9f-ec38-6890-d1ab\ No newline at end of filediff --git a/server-product/jsw/wrapper-delta-pack-3.5.51-st.zip b/server-product/jsw/wrapper-delta-pack-3.5.51-st.zipdeleted file mode 100644index 5b9a82bb61..0000000000Binary files a/server-product/jsw/wrapper-delta-pack-3.5.51-st.zip and /dev/null differdiff --git a/server-product/jsw/wrapper.conf b/server-product/jsw/wrapper.confdeleted file mode 100644index e3ca85a073..0000000000--- a/server-product/jsw/wrapper.conf+++ /dev/null@@ -1,195 +0,0 @@-#encoding=UTF-8-# Configuration files must begin with a line specifying the encoding-# of the the file.--#********************************************************************-# Wrapper License Properties (Ignored by Community Edition)-#********************************************************************-# Professional and Standard Editions of the Wrapper require a valid-# License Key to start. Licenses can be purchased or a trial license-# requested on the following pages:-# http://wrapper.tanukisoftware.com/purchase-# http://wrapper.tanukisoftware.com/trial--# Include file problems can be debugged by leaving only one '#'-# at the beginning of the following line:-##include.debug--# The Wrapper will look for either of the following optional files for a-# valid License Key. License Key properties can optionally be included-# directly in this configuration file.-#include ../conf/wrapper-license.conf-#include ../conf/wrapper-license-%WRAPPER_HOST_NAME%.conf--# The following property will output information about which License Key(s)-# are being found, and can aid in resolving any licensing problems.-#wrapper.license.debug=TRUE--#********************************************************************-# Wrapper Localization-#********************************************************************-# Specify the language and locale which the Wrapper should use.-#wrapper.lang=en_US # en_US or ja_JP--# Specify the location of the language resource files (*.mo).-wrapper.lang.folder=../lang--wrapper.restart.reload_configuration=TRUE-wrapper.single_invocation=TRUE--#********************************************************************-# Wrapper Java Properties. OneDev requires at least Java version 17-#********************************************************************-# Specify Java 17 or higher executable to be used. You may simply specify it-# as "java" if the one in system path is appropriate, or specify the full path-to desired java executable-wrapper.java.command=java--wrapper.java.version.min=17--# Tell the Wrapper to log the full generated Java command line.-#wrapper.java.command.loglevel=INFO--# Java Main class. This class must implement the WrapperListener interface-# or guarantee that the WrapperManager class is initialized. Helper-# classes are provided to do this for you.-# See the following page for details:-# http://wrapper.tanukisoftware.com/doc/english/integrate.html-wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp--# Java Classpath (include wrapper.jar) Add class path elements as-# needed starting from 1-wrapper.java.classpath.1=*.jar-@classpath2@---# Java Library Path (location of Wrapper.DLL or libwrapper.so)-wrapper.java.library.path.1=.-wrapper.java.library.path.append_system_path=TRUE--# Java Bits. On applicable platforms, tells the JVM to run in 32 or 64-bit mode.-wrapper.java.additional.auto_bits=TRUE--# Java Additional Parameters-wrapper.java.additional.1=-Djava.awt.headless=true-wrapper.java.additional.2=-Djdk.io.File.allowDeleteReadOnlyFiles=true--wrapper.java.additional.10=--add-opens=java.base/sun.nio.ch=ALL-UNNAMED-wrapper.java.additional.11=--add-opens=java.base/java.lang=ALL-UNNAMED-wrapper.java.additional.12=--add-opens=java.base/java.lang.reflect=ALL-UNNAMED-wrapper.java.additional.13=--add-opens=java.base/java.lang.invoke=ALL-UNNAMED-wrapper.java.additional.14=--add-opens=java.base/java.util=ALL-UNNAMED-wrapper.java.additional.15=--add-opens=java.base/java.text=ALL-UNNAMED-wrapper.java.additional.16=--add-opens=java.desktop/java.awt.font=ALL-UNNAMED-wrapper.java.additional.30=--add-modules=java.se-wrapper.java.additional.31=--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED-wrapper.java.additional.32=--add-opens=java.management/sun.management=ALL-UNNAMED-wrapper.java.additional.33=--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED-wrapper.java.additional.50=--add-opens=java.base/sun.nio.fs=ALL-UNNAMED--wrapper.java.additional.100=-XX:MaxRAMPercentage=%max_memory_percent%-wrapper.java.additional.101=-Xss%thread_stack_size%--set.default.max_memory_percent=50-set.default.thread_stack_size=1024k--# Application parameters. Add parameters as needed starting from 1--#********************************************************************-# Wrapper Logging Properties-#********************************************************************-# Enables Debug output from the Wrapper.-# wrapper.debug=TRUE--# Format of output for the console. (See docs for formats)-wrapper.console.format=M--# Flush after each line so logs appear when stdout is a pipe (e.g. docker logs)-wrapper.console.flush=TRUE--# Log Level for console output. (See docs for log levels)-wrapper.console.loglevel=INFO--# Log file to use for wrapper output logging.-wrapper.logfile=../logs/console.log--# Format of output for the log file. (See docs for formats)-wrapper.logfile.format=M--# Log Level for log file output. (See docs for log levels)-wrapper.logfile.loglevel=INFO--# Maximum size that the log file will be allowed to grow to before-# the log is rolled. Size is specified in bytes. The default value-# of 0, disables log rolling. May abbreviate with the 'k' (kb) or-# 'm' (mb) suffix. For example: 10m = 10 megabytes.-wrapper.logfile.maxsize=250k--# Maximum number of rolled log files which will be allowed before old-# files are deleted. The default value of 0 implies no limit.-wrapper.logfile.maxfiles=3--# Log Level for sys/event log output. (See docs for log levels)-wrapper.syslog.loglevel=NONE--#********************************************************************-# Wrapper General Properties-#********************************************************************-# Allow for the use of non-contiguous numbered properties-wrapper.ignore_sequence_gaps=TRUE--# Title to use when running as a console--wrapper.disable_console_input=TRUE--#********************************************************************-# Wrapper Windows NT/2000/XP Service Properties-#********************************************************************-# WARNING - Do not modify any of these properties when an application-# using this configuration file has been installed as a service.-# Please uninstall the service before modifying this section. The-# service can then be reinstalled.--# Name of the service--# Display name of the service--# Description of the service--# Service dependencies. Add dependencies as needed starting from 1-wrapper.ntservice.dependency.1=--# Mode in which the service is installed. AUTO_START, DELAY_START or DEMAND_START-wrapper.ntservice.starttype=AUTO_START--# Allow the service to interact with the desktop.-wrapper.ntservice.interactive=false--# Specify NT service account. Leave empty to use local system account.-wrapper.ntservice.account=-wrapper.ntservice.password=--# Optionally mount NT network shares-#wrapper.share.1.location=\\server\share-#wrapper.share.1.target=Z:-#wrapper.share.1.account=domain\user-#wrapper.share.1.password=userpass-#wrapper.share.1.startup.premapped=CONTINUE-#wrapper.share.1.startup.failure=SHUTDOWN-#wrapper.share.1.startup.max_retries=5-#wrapper.share.1.startup.retry_interval=10-#wrapper.share.1.shutdown.unmap=TRUE-#wrapper.share.1.shutdown.unmap.force=TRUE--# Various timeouts-wrapper.jvm_exit.timeout=0-wrapper.startup.timeout=0-wrapper.shutdown.timeout=0-wrapper.ping.timeout=0-wrapper.cpu.timeout=3600-wrapper.ping.interval=3600diff --git a/server-product/pom.xml b/server-product/pom.xmlindex a21ac32aae..b48181f0ad 100644--- a/server-product/pom.xml+++ b/server-product/pom.xml@@ -321,8 +321,22 @@<version>${project.version}</version></dependency></dependencies>+ <build>+ <plugins>+ <plugin>+ <groupId>io.onedev</groupId>+ <artifactId>plugin-maven</artifactId>+ <configuration>+ <distributionDirectory>${project.basedir}/wrapper/distribution</distributionDirectory>+ <!-- These generated files are replaced on every package, including incremental builds. -->+ <distributionCleanupIncludes>boot/**, bin/**, agent/**, conf/wrapper*.conf</distributionCleanupIncludes>+ <agentConfigurationIncludes>conf/wrapper.conf</agentConfigurationIncludes>+ </configuration>+ </plugin>+ </plugins>+ </build><properties>- <executables>bin/*.sh, boot/wrapper-*</executables>+ <executables>bin/*.sh, boot/wrapper-*, agent/bin/*.sh, agent/boot/wrapper-*</executables><moduleClass>io.onedev.server.product.ProductModule</moduleClass></properties></project>diff --git a/server-product/wrapper/README.md b/server-product/wrapper/README.mdnew file mode 100644index 0000000000..0b98dbb758--- /dev/null+++ b/server-product/wrapper/README.md@@ -0,0 +1,137 @@+# OneDev packaging integration++The wrapper source now lives in the separate+[wrapper project](https://code.onedev.io/onedev/wrapper).+This directory contains OneDev's JVM defaults, prepared distribution files, and+`update.sh` for downloading and importing releases and verifying packaging. The generic+wrapper project has no OneDev application code or packaging profile.+To update to the latest release from the+[public download site](https://code.onedev.io/onedev/wrapper/~sites/public/),+run from this repository (requires Bash, curl, tar, a SHA-256 utility, and network access):++```sh+./server-product/wrapper/update.sh+```++The command downloads the release archive and its SHA-256 checksum and imports+them using the same verification and adaptation described below. The site contains+the latest successful publication. Downloads are removed after the update.+Review and commit the updated files in this directory with the server changes.++For local testing, build in the sibling wrapper checkout and import its+output directly, without creating or downloading a release archive:++```sh+(cd ../wrapper && ./build.sh)+./server-product/wrapper/update.sh ../wrapper+```++Pass `/path/to/wrapper` for a checkout elsewhere. This copies the+available binaries and `wrapper.jar` from `dist/boot`, adapts the checkout's+launcher templates, and refreshes both server and agent files and checksums.+Platforms absent from the local build retain their bundled binaries, so a+host-only `./build.sh` is sufficient. All binaries already in `dist/boot` are+imported, including those from previous builds. `VERSION` is marked with a+`-local` suffix. Refresh the development sandbox as described below, or repackage+OneDev to update a release archive; `./dev.sh build` alone does not refresh wrapper+files in an existing sandbox. Local imports are for development;+run the updater without arguments to restore a published release before committing+distribution files.++To also refresh wrapper binaries and scripts in an existing development sandbox,+stop its server and add `--sandbox` to the update command:++```sh+./server-product/wrapper/update.sh --sandbox+# Or import a local build and then refresh the sandbox:+./server-product/wrapper/update.sh ../wrapper --sandbox+```++After successfully updating the prepared distribution, this copies the server and+embedded agent launchers, native executables, and `wrapper.jar` into+`server-product/target/sandbox`. It preserves configuration, application JARs,+logs, and site data. If the sandbox does not exist, the command prints an error+and exits before downloading or importing anything. Create it with `./dev.sh build`+first. The flag also works with `import`; when using `--destination`, the sandbox+is located at `../target/sandbox` relative to that destination. Distribution+archives still need to be repackaged separately.++To import an archive downloaded separately, place `wrapper-VERSION.tar.gz`+and its `.sha256` together, then run:++```sh+./server-product/wrapper/update.sh import /path/to/wrapper-VERSION.tar.gz+```++The importer verifies the archive and file checksums, copies all upstream boot+files, adapts generic launchers for server/agent and one-shot utilities, and creates+the legacy macOS executable alias. It renders server and agent configurations from+`wrapper.conf` and regenerates `SHA256SUMS`. These integration rules live in the+server project. The agent configuration retains the `agentVersion` placeholder,+which is resolved when assembling a standalone agent or downloading one.++`distribution/` contains the exact installation-relative files Maven will copy:++- `boot/`, `bin/`, and `conf/` contain the server's wrapper files.+- `agent/boot/`, `agent/bin/`, and `agent/conf/` contain the agent's wrapper files.++The service names are `onedev.server` and `onedev.agent` on all platforms.+Windows uses these SCM names, Linux uses `onedev.server.service` and+`onedev.agent.service` (or the same names without `.service` for SysV), and+macOS uses these names as launchd labels and plist filenames.++Keep this prepared tree in version control. The maintenance script uses Bash 3.2++and standard Unix tools (`sha256sum` on Linux or `shasum` on macOS); no Python or+Node.js runtime is needed. Ordinary Maven builds consume the checked-in files. Importing recreates+the tree, so removed upstream files cannot survive into a new release. To change+JVM defaults or the adaptation rules, edit `wrapper.conf` or the importer and+reimport the pinned release archive.++The Maven plugin has no wrapper Maven dependency, does not download its+releases, and does not require its source checkout. It copies these prepared files+into the server and agent distributions. Rust is not needed to package OneDev.++The companion maven-plugin 2.9.1 consumes a generic prepared distribution instead+of interpreting JSW/native layouts, launcher templates, platform names, or wrapper+configuration keys. Publish that plugin change before the server change.+`server-product/pom.xml` configures the prepared directory, generated paths to+replace on incremental builds, agent files needing version substitution, and+executable permissions. Future wrapper changes belong in this repository's+importer, inputs, or POM and do not require a Maven plugin release as long as this+prepared-file contract remains the same.++Validate the resulting release with (the package checker requires `unzip`, and+the tests also use `zip` to create package fixtures):++```sh+./server-product/wrapper/update.sh test+./server-product/wrapper/update.sh check-package server-product/target/onedev-VERSION.zip+```++Run `./server-product/wrapper/update.sh help` for all commands and import options.+Running the script with no arguments is equivalent to the `update` command.++Existing `server.sh` / `agent.sh` commands and `conf/wrapper.conf` remain supported.+The Java lifecycle API is `io.onedev.wrapper.WrapperManager`, with+`restartAndReturn()` and `stopAndReturn(int)`. The launcher class is+`io.onedev.wrapper.WrapperSimpleApp`. Update the wrapper and application jars+together when migrating from an earlier Java API package.+Stop and remove an existing service with its old launcher and configuration before+replacing wrapper files or changing service names. Set `wrapper.name` to+`onedev.server` or `onedev.agent`, and `wrapper.java.mainclass` to+`io.onedev.wrapper.WrapperSimpleApp`, then install and start the service again.+Server upgrades replace boot files and scripts while retaining `wrapper.conf`+and updating its lifecycle bridge class.+Existing agents update only application jars: migrating their wrapper requires+stopping them and replacing `boot` and `bin` from a new agent distribution while+retaining configuration. Newly downloaded agents use Wrapper.++Review the standalone project's configuration compatibility list before migrating+custom JSW features. Native SCM, launchd, and systemd acceptance testing is still+required before the initial production release.++The Docker upgrade invocation explicitly disables crash retries for its one-shot+operation. Generic Wrapper does not inspect the application's class name.+Launchers supply their own paths when installing services. When invoking a native+binary directly to install a service, specify `wrapper.script=../bin/server.sh`+or `wrapper.script=../bin/agent.sh` for the corresponding distribution.diff --git a/server-product/wrapper/SHA256SUMS b/server-product/wrapper/SHA256SUMSnew file mode 100644index 0000000000..5da613e803--- /dev/null+++ b/server-product/wrapper/SHA256SUMS@@ -0,0 +1,36 @@+0224c7f0fffc23012d32529affa53b7ae58837b852ad800435e9f97b87c11e54 README.md+0f8fee02328a33ee30e1ecf2b9029eb41ae72f34bbc1ae451ddb74a581190e06 VERSION+c6903c9ebecb69dc27eaa89ce133bd6e17db178dc2d88b62c323c06a3ed761d5 distribution/agent/bin/agent.bat+70d482d8b4f323a92ebe9e94c1cfcfd90a3acc9a6dc405bbf642f9ce84aad003 distribution/agent/bin/agent.sh+1102c500067c908f941a6a105c9563a89a760664cbfdc2519befa8645b5c381c distribution/agent/boot/wrapper-linux-arm-64+ac78e3982c0558116a5f3d112a315af63695ebc21562c542c30a08a54d7d6e0a distribution/agent/boot/wrapper-linux-x86-64+ec378dbd20a8da8cda8cf117439f9745052bd65138ab8dad1a060405d94c13b4 distribution/agent/boot/wrapper-macosx-arm-64+ec378dbd20a8da8cda8cf117439f9745052bd65138ab8dad1a060405d94c13b4 distribution/agent/boot/wrapper-macosx-universal-64+bb04575c2447d5ddf55ec557aa7b0abc1fc043ef78d907e240a4e7865ff624e9 distribution/agent/boot/wrapper-windows-arm-64.exe+44f97fc340909a9ed2e424376c75fc45bfc57d6f7acee5f0d7f919935116aa40 distribution/agent/boot/wrapper-windows-x86-64.exe+69d7163492f1f8f8423d1eb3ab32a7843dfd8cc88213b3bfa1f09141b0704a08 distribution/agent/boot/wrapper.jar+352573657d80732962d39c6cad497edab54d28a653697b90c34402809d3324e8 distribution/agent/conf/wrapper.conf+3c91c3364f8707f51375fc2503259f79ff7d005431d614a47a62ab7214f49ddd distribution/bin/apply-db-constraints.bat+3959a5af7303f80fbd3b83b4859846c117072d1468762924970b0d4bb5717bfa distribution/bin/apply-db-constraints.sh+3c91c3364f8707f51375fc2503259f79ff7d005431d614a47a62ab7214f49ddd distribution/bin/backup-db.bat+3959a5af7303f80fbd3b83b4859846c117072d1468762924970b0d4bb5717bfa distribution/bin/backup-db.sh+3c91c3364f8707f51375fc2503259f79ff7d005431d614a47a62ab7214f49ddd distribution/bin/enable-internal-login.bat+3959a5af7303f80fbd3b83b4859846c117072d1468762924970b0d4bb5717bfa distribution/bin/enable-internal-login.sh+3c91c3364f8707f51375fc2503259f79ff7d005431d614a47a62ab7214f49ddd distribution/bin/reset-admin-password.bat+3959a5af7303f80fbd3b83b4859846c117072d1468762924970b0d4bb5717bfa distribution/bin/reset-admin-password.sh+3c91c3364f8707f51375fc2503259f79ff7d005431d614a47a62ab7214f49ddd distribution/bin/restore-db.bat+3959a5af7303f80fbd3b83b4859846c117072d1468762924970b0d4bb5717bfa distribution/bin/restore-db.sh+c6903c9ebecb69dc27eaa89ce133bd6e17db178dc2d88b62c323c06a3ed761d5 distribution/bin/server.bat+70d482d8b4f323a92ebe9e94c1cfcfd90a3acc9a6dc405bbf642f9ce84aad003 distribution/bin/server.sh+3c91c3364f8707f51375fc2503259f79ff7d005431d614a47a62ab7214f49ddd distribution/bin/upgrade.bat+3959a5af7303f80fbd3b83b4859846c117072d1468762924970b0d4bb5717bfa distribution/bin/upgrade.sh+1102c500067c908f941a6a105c9563a89a760664cbfdc2519befa8645b5c381c distribution/boot/wrapper-linux-arm-64+ac78e3982c0558116a5f3d112a315af63695ebc21562c542c30a08a54d7d6e0a distribution/boot/wrapper-linux-x86-64+ec378dbd20a8da8cda8cf117439f9745052bd65138ab8dad1a060405d94c13b4 distribution/boot/wrapper-macosx-arm-64+ec378dbd20a8da8cda8cf117439f9745052bd65138ab8dad1a060405d94c13b4 distribution/boot/wrapper-macosx-universal-64+bb04575c2447d5ddf55ec557aa7b0abc1fc043ef78d907e240a4e7865ff624e9 distribution/boot/wrapper-windows-arm-64.exe+44f97fc340909a9ed2e424376c75fc45bfc57d6f7acee5f0d7f919935116aa40 distribution/boot/wrapper-windows-x86-64.exe+69d7163492f1f8f8423d1eb3ab32a7843dfd8cc88213b3bfa1f09141b0704a08 distribution/boot/wrapper.jar+6681dd61fd63979af05ff6fffc36be43f50d61b7bc89edafb9614d6fa3440998 distribution/conf/wrapper.conf+669c35b4e855b957ec4b712330e9b3f253863ef6463a890148b765482dd65997 update.sh+71cce4154ef69e1e0630f751ec16ff18096f3f174685811f33246aa8d73bbce9 wrapper.confdiff --git a/server-product/wrapper/VERSION b/server-product/wrapper/VERSIONnew file mode 100644index 0000000000..2721169e76--- /dev/null+++ b/server-product/wrapper/VERSION@@ -0,0 +1 @@+1.0.0-localdiff --git a/server-product/wrapper/distribution/agent/bin/agent.bat b/server-product/wrapper/distribution/agent/bin/agent.batnew file mode 100644index 0000000000..aa42e25b13--- /dev/null+++ b/server-product/wrapper/distribution/agent/bin/agent.bat@@ -0,0 +1,13 @@+@echo off+setlocal+rem Java service launcher. Use an elevated prompt to install/remove services.+set "_ARCH=%PROCESSOR_ARCHITECTURE%"+if defined PROCESSOR_ARCHITEW6432 set "_ARCH=%PROCESSOR_ARCHITEW6432%"+if /i "%_ARCH%"=="AMD64" set "_BINARY=wrapper-windows-x86-64.exe"+if /i "%_ARCH%"=="ARM64" set "_BINARY=wrapper-windows-arm-64.exe"+if not defined _BINARY (+ echo Wrapper requires Windows amd64 or arm64. 1>&2+ exit /b 1+)+"%~dp0..\boot\%_BINARY%" --script "%~n0" "%~dp0..\conf\wrapper.conf" %*+exit /b %ERRORLEVEL%diff --git a/server-product/wrapper/distribution/agent/bin/agent.sh b/server-product/wrapper/distribution/agent/bin/agent.shnew file mode 100755index 0000000000..239f662803--- /dev/null+++ b/server-product/wrapper/distribution/agent/bin/agent.sh@@ -0,0 +1,50 @@+#!/bin/bash+# Java service launcher. JVM and service settings belong in conf/wrapper.conf.+set -e++#RUN_AS_USER=+FILES_TO_SOURCE=++# Resolve installed init-script symlinks before locating the distribution.+SCRIPT=${BASH_SOURCE[0]}+while [ -L "$SCRIPT" ]; do+ DIRECTORY=$(cd -P "$(dirname "$SCRIPT")" && pwd)+ SCRIPT=$(readlink "$SCRIPT")+ [[ "$SCRIPT" = /* ]] || SCRIPT=$DIRECTORY/$SCRIPT+done+DIRECTORY=$(cd -P "$(dirname "$SCRIPT")" && pwd)+SCRIPT=$DIRECTORY/$(basename "$SCRIPT")+cd "$DIRECTORY"+WRAPPER_CONF=../conf/wrapper.conf++if [ -f "${SCRIPT%.sh}.shconf" ]; then+ source "${SCRIPT%.sh}.shconf"+fi+if [ -n "$FILES_TO_SOURCE" ]; then+ IFS=';' read -r -a SOURCE_FILES <<< "$FILES_TO_SOURCE"+ for SOURCE_FILE in "${SOURCE_FILES[@]}"; do+ source "$SOURCE_FILE"+ done+fi+export RUN_AS_USER=${RUN_AS_USER:-}+export WRAPPER_SCRIPT=$SCRIPT++case "$(uname -s):$(uname -m)" in+ Linux:x86_64) BINARY=wrapper-linux-x86-64 ;;+ Linux:aarch64|Linux:arm64) BINARY=wrapper-linux-arm-64 ;;+ Darwin:arm64) BINARY=wrapper-macosx-arm-64 ;;+ Darwin:x86_64)+ if [ "$(sysctl -in sysctl.proc_translated 2>/dev/null || true)" = 1 ]; then+ BINARY=wrapper-macosx-arm-64+ else+ echo 'Wrapper requires Apple Silicon on macOS.' >&2; exit 1+ fi ;;+ MINGW*:*|MSYS*:*|CYGWIN*:*)+ case "${PROCESSOR_ARCHITEW6432:-${PROCESSOR_ARCHITECTURE:-}}" in+ ARM64|arm64) BINARY=wrapper-windows-arm-64.exe ;;+ AMD64|amd64) BINARY=wrapper-windows-x86-64.exe ;;+ *) echo 'Wrapper requires Windows amd64 or arm64.' >&2; exit 1 ;;+ esac ;;+ *) echo "Unsupported platform: $(uname -s) $(uname -m)" >&2; exit 1 ;;+esac+exec "$DIRECTORY/../boot/$BINARY" --script "$(basename "$SCRIPT" .sh)" "$WRAPPER_CONF" "$@"diff --git a/server-product/wrapper/distribution/agent/boot/wrapper-linux-arm-64 b/server-product/wrapper/distribution/agent/boot/wrapper-linux-arm-64new file mode 100755index 0000000000..8b228c8a80Binary files /dev/null and b/server-product/wrapper/distribution/agent/boot/wrapper-linux-arm-64 differdiff --git a/server-product/wrapper/distribution/agent/boot/wrapper-linux-x86-64 b/server-product/wrapper/distribution/agent/boot/wrapper-linux-x86-64new file mode 100755index 0000000000..59fa31187eBinary files /dev/null and b/server-product/wrapper/distribution/agent/boot/wrapper-linux-x86-64 differdiff --git a/server-product/wrapper/distribution/agent/boot/wrapper-macosx-arm-64 b/server-product/wrapper/distribution/agent/boot/wrapper-macosx-arm-64new file mode 100755index 0000000000..fe3bea5e60Binary files /dev/null and b/server-product/wrapper/distribution/agent/boot/wrapper-macosx-arm-64 differdiff --git a/server-product/wrapper/distribution/agent/boot/wrapper-macosx-universal-64 b/server-product/wrapper/distribution/agent/boot/wrapper-macosx-universal-64new file mode 100755index 0000000000..fe3bea5e60Binary files /dev/null and b/server-product/wrapper/distribution/agent/boot/wrapper-macosx-universal-64 differdiff --git a/server-product/wrapper/distribution/agent/boot/wrapper-windows-arm-64.exe b/server-product/wrapper/distribution/agent/boot/wrapper-windows-arm-64.exenew file mode 100755index 0000000000..2312263c3bBinary files /dev/null and b/server-product/wrapper/distribution/agent/boot/wrapper-windows-arm-64.exe differdiff --git a/server-product/wrapper/distribution/agent/boot/wrapper-windows-x86-64.exe b/server-product/wrapper/distribution/agent/boot/wrapper-windows-x86-64.exenew file mode 100755index 0000000000..9b17627c76Binary files /dev/null and b/server-product/wrapper/distribution/agent/boot/wrapper-windows-x86-64.exe differdiff --git a/server-product/wrapper/distribution/agent/boot/wrapper.jar b/server-product/wrapper/distribution/agent/boot/wrapper.jarnew file mode 100644index 0000000000..9dbaa7701fBinary files /dev/null and b/server-product/wrapper/distribution/agent/boot/wrapper.jar differdiff --git a/server-product/wrapper/distribution/agent/conf/wrapper.conf b/server-product/wrapper/distribution/agent/conf/wrapper.confnew file mode 100644index 0000000000..1a81fcf878--- /dev/null+++ b/server-product/wrapper/distribution/agent/conf/wrapper.conf@@ -0,0 +1,66 @@+#encoding=UTF-8+# OneDev service wrapper configuration. Paths are relative to the boot directory.+# Existing JSW property names are retained. Restart the service after editing JVM+# settings. Remove/install the service after changing service registration settings.+# Optional extra configuration: #include ../conf/extra.conf+# Required extra configuration: #include.required ../conf/extra.conf++# Java 17 or higher. Quote paths containing spaces.+wrapper.java.command=java+wrapper.java.version.min=17+wrapper.java.mainclass=io.onedev.wrapper.WrapperSimpleApp+wrapper.java.classpath.1=*.jar+wrapper.java.classpath.2=../lib/agentVersion/*.jar+wrapper.java.library.path.1=.+wrapper.java.library.path.append_system_path=TRUE++# Numbered properties may have gaps. Each additional property is one JVM argument.+wrapper.java.additional.1=-Djava.awt.headless=true+wrapper.java.additional.2=-Djdk.io.File.allowDeleteReadOnlyFiles=true+wrapper.java.additional.10=--add-opens=java.base/sun.nio.ch=ALL-UNNAMED+wrapper.java.additional.11=--add-opens=java.base/java.lang=ALL-UNNAMED+wrapper.java.additional.12=--add-opens=java.base/java.lang.reflect=ALL-UNNAMED+wrapper.java.additional.13=--add-opens=java.base/java.lang.invoke=ALL-UNNAMED+wrapper.java.additional.14=--add-opens=java.base/java.util=ALL-UNNAMED+wrapper.java.additional.15=--add-opens=java.base/java.text=ALL-UNNAMED+wrapper.java.additional.16=--add-opens=java.desktop/java.awt.font=ALL-UNNAMED+wrapper.java.additional.30=--add-modules=java.se+wrapper.java.additional.31=--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED+wrapper.java.additional.32=--add-opens=java.management/sun.management=ALL-UNNAMED+wrapper.java.additional.33=--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED+wrapper.java.additional.50=--add-opens=java.base/sun.nio.fs=ALL-UNNAMED+wrapper.java.additional.100=-XX:MaxRAMPercentage=%max_memory_percent%+wrapper.java.additional.101=-Xss%thread_stack_size%+set.default.max_memory_percent=50+set.default.thread_stack_size=1024k+# Alternatively set wrapper.java.initmemory and wrapper.java.maxmemory in MB.++wrapper.app.parameter.1=io.onedev.agent.Agent++# JVM stdout/stderr go to console and this rotating log. NONE disables a destination.+wrapper.console.loglevel=INFO+wrapper.logfile=../logs/console.log+wrapper.logfile.loglevel=INFO+wrapper.logfile.maxsize=250k+wrapper.logfile.maxfiles=3++wrapper.name=onedev.agent+wrapper.displayname=OneDev Agent+wrapper.description=OneDev Agent++# Optional Unix service account (also accepts RUN_AS_USER in bin/*.shconf).+#wrapper.daemon.user=onedev++# Windows service registration. Empty account uses LocalSystem.+wrapper.ntservice.dependency.1=+wrapper.ntservice.starttype=AUTO_START+wrapper.ntservice.account=+wrapper.ntservice.password=++# Zero allows unlimited startup/shutdown time. Java shutdown hooks run on stop.+wrapper.startup.timeout=0+wrapper.shutdown.timeout=0+# Consecutive unexpected JVM failures are bounded to prevent a restart loop.+wrapper.restart.delay=5+wrapper.max_failed_invocations=5+wrapper.successful_invocation_time=300diff --git a/server-product/wrapper/distribution/bin/apply-db-constraints.bat b/server-product/wrapper/distribution/bin/apply-db-constraints.batnew file mode 100644index 0000000000..dd5fe27d46--- /dev/null+++ b/server-product/wrapper/distribution/bin/apply-db-constraints.bat@@ -0,0 +1,13 @@+@echo off+setlocal+rem Java service launcher. Use an elevated prompt to install/remove services.+set "_ARCH=%PROCESSOR_ARCHITECTURE%"+if defined PROCESSOR_ARCHITEW6432 set "_ARCH=%PROCESSOR_ARCHITEW6432%"+if /i "%_ARCH%"=="AMD64" set "_BINARY=wrapper-windows-x86-64.exe"+if /i "%_ARCH%"=="ARM64" set "_BINARY=wrapper-windows-arm-64.exe"+if not defined _BINARY (+ echo Wrapper requires Windows amd64 or arm64. 1>&2+ exit /b 1+)+"%~dp0..\boot\%_BINARY%" --command "%~n0" "%~dp0..\conf\wrapper.conf" %*+exit /b %ERRORLEVEL%diff --git a/server-product/wrapper/distribution/bin/apply-db-constraints.sh b/server-product/wrapper/distribution/bin/apply-db-constraints.shnew file mode 100755index 0000000000..13feeabc46--- /dev/null+++ b/server-product/wrapper/distribution/bin/apply-db-constraints.sh@@ -0,0 +1,50 @@+#!/bin/bash+# Java service launcher. JVM and service settings belong in conf/wrapper.conf.+set -e++#RUN_AS_USER=+FILES_TO_SOURCE=++# Resolve installed init-script symlinks before locating the distribution.+SCRIPT=${BASH_SOURCE[0]}+while [ -L "$SCRIPT" ]; do+ DIRECTORY=$(cd -P "$(dirname "$SCRIPT")" && pwd)+ SCRIPT=$(readlink "$SCRIPT")+ [[ "$SCRIPT" = /* ]] || SCRIPT=$DIRECTORY/$SCRIPT+done+DIRECTORY=$(cd -P "$(dirname "$SCRIPT")" && pwd)+SCRIPT=$DIRECTORY/$(basename "$SCRIPT")+cd "$DIRECTORY"+WRAPPER_CONF=../conf/wrapper.conf++if [ -f "${SCRIPT%.sh}.shconf" ]; then+ source "${SCRIPT%.sh}.shconf"+fi+if [ -n "$FILES_TO_SOURCE" ]; then+ IFS=';' read -r -a SOURCE_FILES <<< "$FILES_TO_SOURCE"+ for SOURCE_FILE in "${SOURCE_FILES[@]}"; do+ source "$SOURCE_FILE"+ done+fi+export RUN_AS_USER=${RUN_AS_USER:-}+export WRAPPER_SCRIPT=$SCRIPT++case "$(uname -s):$(uname -m)" in+ Linux:x86_64) BINARY=wrapper-linux-x86-64 ;;+ Linux:aarch64|Linux:arm64) BINARY=wrapper-linux-arm-64 ;;+ Darwin:arm64) BINARY=wrapper-macosx-arm-64 ;;+ Darwin:x86_64)+ if [ "$(sysctl -in sysctl.proc_translated 2>/dev/null || true)" = 1 ]; then+ BINARY=wrapper-macosx-arm-64+ else+ echo 'Wrapper requires Apple Silicon on macOS.' >&2; exit 1+ fi ;;+ MINGW*:*|MSYS*:*|CYGWIN*:*)+ case "${PROCESSOR_ARCHITEW6432:-${PROCESSOR_ARCHITECTURE:-}}" in+ ARM64|arm64) BINARY=wrapper-windows-arm-64.exe ;;+ AMD64|amd64) BINARY=wrapper-windows-x86-64.exe ;;+ *) echo 'Wrapper requires Windows amd64 or arm64.' >&2; exit 1 ;;+ esac ;;+ *) echo "Unsupported platform: $(uname -s) $(uname -m)" >&2; exit 1 ;;+esac+exec "$DIRECTORY/../boot/$BINARY" --command "$(basename "$SCRIPT" .sh)" "$WRAPPER_CONF" "$@"diff --git a/server-product/wrapper/distribution/bin/backup-db.bat b/server-product/wrapper/distribution/bin/backup-db.batnew file mode 100644index 0000000000..dd5fe27d46--- /dev/null+++ b/server-product/wrapper/distribution/bin/backup-db.bat@@ -0,0 +1,13 @@+@echo off+setlocal+rem Java service launcher. Use an elevated prompt to install/remove services.+set "_ARCH=%PROCESSOR_ARCHITECTURE%"+if defined PROCESSOR_ARCHITEW6432 set "_ARCH=%PROCESSOR_ARCHITEW6432%"+if /i "%_ARCH%"=="AMD64" set "_BINARY=wrapper-windows-x86-64.exe"+if /i "%_ARCH%"=="ARM64" set "_BINARY=wrapper-windows-arm-64.exe"+if not defined _BINARY (+ echo Wrapper requires Windows amd64 or arm64. 1>&2+ exit /b 1+)+"%~dp0..\boot\%_BINARY%" --command "%~n0" "%~dp0..\conf\wrapper.conf" %*+exit /b %ERRORLEVEL%diff --git a/server-product/wrapper/distribution/bin/backup-db.sh b/server-product/wrapper/distribution/bin/backup-db.shnew file mode 100755index 0000000000..13feeabc46--- /dev/null+++ b/server-product/wrapper/distribution/bin/backup-db.sh@@ -0,0 +1,50 @@+#!/bin/bash+# Java service launcher. JVM and service settings belong in conf/wrapper.conf.+set -e++#RUN_AS_USER=+FILES_TO_SOURCE=++# Resolve installed init-script symlinks before locating the distribution.+SCRIPT=${BASH_SOURCE[0]}+while [ -L "$SCRIPT" ]; do+ DIRECTORY=$(cd -P "$(dirname "$SCRIPT")" && pwd)+ SCRIPT=$(readlink "$SCRIPT")+ [[ "$SCRIPT" = /* ]] || SCRIPT=$DIRECTORY/$SCRIPT+done+DIRECTORY=$(cd -P "$(dirname "$SCRIPT")" && pwd)+SCRIPT=$DIRECTORY/$(basename "$SCRIPT")+cd "$DIRECTORY"+WRAPPER_CONF=../conf/wrapper.conf++if [ -f "${SCRIPT%.sh}.shconf" ]; then+ source "${SCRIPT%.sh}.shconf"+fi+if [ -n "$FILES_TO_SOURCE" ]; then+ IFS=';' read -r -a SOURCE_FILES <<< "$FILES_TO_SOURCE"+ for SOURCE_FILE in "${SOURCE_FILES[@]}"; do+ source "$SOURCE_FILE"+ done+fi+export RUN_AS_USER=${RUN_AS_USER:-}+export WRAPPER_SCRIPT=$SCRIPT++case "$(uname -s):$(uname -m)" in+ Linux:x86_64) BINARY=wrapper-linux-x86-64 ;;+ Linux:aarch64|Linux:arm64) BINARY=wrapper-linux-arm-64 ;;+ Darwin:arm64) BINARY=wrapper-macosx-arm-64 ;;+ Darwin:x86_64)+ if [ "$(sysctl -in sysctl.proc_translated 2>/dev/null || true)" = 1 ]; then+ BINARY=wrapper-macosx-arm-64+ else+ echo 'Wrapper requires Apple Silicon on macOS.' >&2; exit 1+ fi ;;+ MINGW*:*|MSYS*:*|CYGWIN*:*)+ case "${PROCESSOR_ARCHITEW6432:-${PROCESSOR_ARCHITECTURE:-}}" in+ ARM64|arm64) BINARY=wrapper-windows-arm-64.exe ;;+ AMD64|amd64) BINARY=wrapper-windows-x86-64.exe ;;+ *) echo 'Wrapper requires Windows amd64 or arm64.' >&2; exit 1 ;;+ esac ;;+ *) echo "Unsupported platform: $(uname -s) $(uname -m)" >&2; exit 1 ;;+esac+exec "$DIRECTORY/../boot/$BINARY" --command "$(basename "$SCRIPT" .sh)" "$WRAPPER_CONF" "$@"diff --git a/server-product/wrapper/distribution/bin/enable-internal-login.bat b/server-product/wrapper/distribution/bin/enable-internal-login.batnew file mode 100644index 0000000000..dd5fe27d46--- /dev/null+++ b/server-product/wrapper/distribution/bin/enable-internal-login.bat@@ -0,0 +1,13 @@+@echo off+setlocal+rem Java service launcher. Use an elevated prompt to install/remove services.+set "_ARCH=%PROCESSOR_ARCHITECTURE%"+if defined PROCESSOR_ARCHITEW6432 set "_ARCH=%PROCESSOR_ARCHITEW6432%"+if /i "%_ARCH%"=="AMD64" set "_BINARY=wrapper-windows-x86-64.exe"+if /i "%_ARCH%"=="ARM64" set "_BINARY=wrapper-windows-arm-64.exe"+if not defined _BINARY (+ echo Wrapper requires Windows amd64 or arm64. 1>&2+ exit /b 1+)+"%~dp0..\boot\%_BINARY%" --command "%~n0" "%~dp0..\conf\wrapper.conf" %*+exit /b %ERRORLEVEL%diff --git a/server-product/wrapper/distribution/bin/enable-internal-login.sh b/server-product/wrapper/distribution/bin/enable-internal-login.shnew file mode 100755index 0000000000..13feeabc46--- /dev/null+++ b/server-product/wrapper/distribution/bin/enable-internal-login.sh@@ -0,0 +1,50 @@+#!/bin/bash+# Java service launcher. JVM and service settings belong in conf/wrapper.conf.+set -e++#RUN_AS_USER=+FILES_TO_SOURCE=++# Resolve installed init-script symlinks before locating the distribution.+SCRIPT=${BASH_SOURCE[0]}+while [ -L "$SCRIPT" ]; do+ DIRECTORY=$(cd -P "$(dirname "$SCRIPT")" && pwd)+ SCRIPT=$(readlink "$SCRIPT")+ [[ "$SCRIPT" = /* ]] || SCRIPT=$DIRECTORY/$SCRIPT+done+DIRECTORY=$(cd -P "$(dirname "$SCRIPT")" && pwd)+SCRIPT=$DIRECTORY/$(basename "$SCRIPT")+cd "$DIRECTORY"+WRAPPER_CONF=../conf/wrapper.conf++if [ -f "${SCRIPT%.sh}.shconf" ]; then+ source "${SCRIPT%.sh}.shconf"+fi+if [ -n "$FILES_TO_SOURCE" ]; then+ IFS=';' read -r -a SOURCE_FILES <<< "$FILES_TO_SOURCE"+ for SOURCE_FILE in "${SOURCE_FILES[@]}"; do+ source "$SOURCE_FILE"+ done+fi+export RUN_AS_USER=${RUN_AS_USER:-}+export WRAPPER_SCRIPT=$SCRIPT++case "$(uname -s):$(uname -m)" in+ Linux:x86_64) BINARY=wrapper-linux-x86-64 ;;+ Linux:aarch64|Linux:arm64) BINARY=wrapper-linux-arm-64 ;;+ Darwin:arm64) BINARY=wrapper-macosx-arm-64 ;;+ Darwin:x86_64)+ if [ "$(sysctl -in sysctl.proc_translated 2>/dev/null || true)" = 1 ]; then+ BINARY=wrapper-macosx-arm-64+ else+ echo 'Wrapper requires Apple Silicon on macOS.' >&2; exit 1+ fi ;;+ MINGW*:*|MSYS*:*|CYGWIN*:*)+ case "${PROCESSOR_ARCHITEW6432:-${PROCESSOR_ARCHITECTURE:-}}" in+ ARM64|arm64) BINARY=wrapper-windows-arm-64.exe ;;+ AMD64|amd64) BINARY=wrapper-windows-x86-64.exe ;;+ *) echo 'Wrapper requires Windows amd64 or arm64.' >&2; exit 1 ;;+ esac ;;+ *) echo "Unsupported platform: $(uname -s) $(uname -m)" >&2; exit 1 ;;+esac+exec "$DIRECTORY/../boot/$BINARY" --command "$(basename "$SCRIPT" .sh)" "$WRAPPER_CONF" "$@"diff --git a/server-product/wrapper/distribution/bin/reset-admin-password.bat b/server-product/wrapper/distribution/bin/reset-admin-password.batnew file mode 100644index 0000000000..dd5fe27d46--- /dev/null+++ b/server-product/wrapper/distribution/bin/reset-admin-password.bat@@ -0,0 +1,13 @@+@echo off+setlocal+rem Java service launcher. Use an elevated prompt to install/remove services.+set "_ARCH=%PROCESSOR_ARCHITECTURE%"+if defined PROCESSOR_ARCHITEW6432 set "_ARCH=%PROCESSOR_ARCHITEW6432%"+if /i "%_ARCH%"=="AMD64" set "_BINARY=wrapper-windows-x86-64.exe"+if /i "%_ARCH%"=="ARM64" set "_BINARY=wrapper-windows-arm-64.exe"+if not defined _BINARY (+ echo Wrapper requires Windows amd64 or arm64. 1>&2+ exit /b 1+)+"%~dp0..\boot\%_BINARY%" --command "%~n0" "%~dp0..\conf\wrapper.conf" %*+exit /b %ERRORLEVEL%diff --git a/server-product/wrapper/distribution/bin/reset-admin-password.sh b/server-product/wrapper/distribution/bin/reset-admin-password.shnew file mode 100755index 0000000000..13feeabc46--- /dev/null+++ b/server-product/wrapper/distribution/bin/reset-admin-password.sh@@ -0,0 +1,50 @@+#!/bin/bash+# Java service launcher. JVM and service settings belong in conf/wrapper.conf.+set -e++#RUN_AS_USER=+FILES_TO_SOURCE=++# Resolve installed init-script symlinks before locating the distribution.+SCRIPT=${BASH_SOURCE[0]}+while [ -L "$SCRIPT" ]; do+ DIRECTORY=$(cd -P "$(dirname "$SCRIPT")" && pwd)+ SCRIPT=$(readlink "$SCRIPT")+ [[ "$SCRIPT" = /* ]] || SCRIPT=$DIRECTORY/$SCRIPT+done+DIRECTORY=$(cd -P "$(dirname "$SCRIPT")" && pwd)+SCRIPT=$DIRECTORY/$(basename "$SCRIPT")+cd "$DIRECTORY"+WRAPPER_CONF=../conf/wrapper.conf++if [ -f "${SCRIPT%.sh}.shconf" ]; then+ source "${SCRIPT%.sh}.shconf"+fi+if [ -n "$FILES_TO_SOURCE" ]; then+ IFS=';' read -r -a SOURCE_FILES <<< "$FILES_TO_SOURCE"+ for SOURCE_FILE in "${SOURCE_FILES[@]}"; do+ source "$SOURCE_FILE"+ done+fi+export RUN_AS_USER=${RUN_AS_USER:-}+export WRAPPER_SCRIPT=$SCRIPT++case "$(uname -s):$(uname -m)" in+ Linux:x86_64) BINARY=wrapper-linux-x86-64 ;;+ Linux:aarch64|Linux:arm64) BINARY=wrapper-linux-arm-64 ;;+ Darwin:arm64) BINARY=wrapper-macosx-arm-64 ;;+ Darwin:x86_64)+ if [ "$(sysctl -in sysctl.proc_translated 2>/dev/null || true)" = 1 ]; then+ BINARY=wrapper-macosx-arm-64+ else+ echo 'Wrapper requires Apple Silicon on macOS.' >&2; exit 1+ fi ;;+ MINGW*:*|MSYS*:*|CYGWIN*:*)+ case "${PROCESSOR_ARCHITEW6432:-${PROCESSOR_ARCHITECTURE:-}}" in+ ARM64|arm64) BINARY=wrapper-windows-arm-64.exe ;;+ AMD64|amd64) BINARY=wrapper-windows-x86-64.exe ;;+ *) echo 'Wrapper requires Windows amd64 or arm64.' >&2; exit 1 ;;+ esac ;;+ *) echo "Unsupported platform: $(uname -s) $(uname -m)" >&2; exit 1 ;;+esac+exec "$DIRECTORY/../boot/$BINARY" --command "$(basename "$SCRIPT" .sh)" "$WRAPPER_CONF" "$@"diff --git a/server-product/wrapper/distribution/bin/restore-db.bat b/server-product/wrapper/distribution/bin/restore-db.batnew file mode 100644index 0000000000..dd5fe27d46--- /dev/null+++ b/server-product/wrapper/distribution/bin/restore-db.bat@@ -0,0 +1,13 @@+@echo off+setlocal+rem Java service launcher. Use an elevated prompt to install/remove services.+set "_ARCH=%PROCESSOR_ARCHITECTURE%"+if defined PROCESSOR_ARCHITEW6432 set "_ARCH=%PROCESSOR_ARCHITEW6432%"+if /i "%_ARCH%"=="AMD64" set "_BINARY=wrapper-windows-x86-64.exe"+if /i "%_ARCH%"=="ARM64" set "_BINARY=wrapper-windows-arm-64.exe"+if not defined _BINARY (+ echo Wrapper requires Windows amd64 or arm64. 1>&2+ exit /b 1+)+"%~dp0..\boot\%_BINARY%" --command "%~n0" "%~dp0..\conf\wrapper.conf" %*+exit /b %ERRORLEVEL%diff --git a/server-product/wrapper/distribution/bin/restore-db.sh b/server-product/wrapper/distribution/bin/restore-db.shnew file mode 100755index 0000000000..13feeabc46--- /dev/null+++ b/server-product/wrapper/distribution/bin/restore-db.sh@@ -0,0 +1,50 @@+#!/bin/bash+# Java service launcher. JVM and service settings belong in conf/wrapper.conf.+set -e++#RUN_AS_USER=+FILES_TO_SOURCE=++# Resolve installed init-script symlinks before locating the distribution.+SCRIPT=${BASH_SOURCE[0]}+while [ -L "$SCRIPT" ]; do+ DIRECTORY=$(cd -P "$(dirname "$SCRIPT")" && pwd)+ SCRIPT=$(readlink "$SCRIPT")+ [[ "$SCRIPT" = /* ]] || SCRIPT=$DIRECTORY/$SCRIPT+done+DIRECTORY=$(cd -P "$(dirname "$SCRIPT")" && pwd)+SCRIPT=$DIRECTORY/$(basename "$SCRIPT")+cd "$DIRECTORY"+WRAPPER_CONF=../conf/wrapper.conf++if [ -f "${SCRIPT%.sh}.shconf" ]; then+ source "${SCRIPT%.sh}.shconf"+fi+if [ -n "$FILES_TO_SOURCE" ]; then+ IFS=';' read -r -a SOURCE_FILES <<< "$FILES_TO_SOURCE"+ for SOURCE_FILE in "${SOURCE_FILES[@]}"; do+ source "$SOURCE_FILE"+ done+fi+export RUN_AS_USER=${RUN_AS_USER:-}+export WRAPPER_SCRIPT=$SCRIPT++case "$(uname -s):$(uname -m)" in+ Linux:x86_64) BINARY=wrapper-linux-x86-64 ;;+ Linux:aarch64|Linux:arm64) BINARY=wrapper-linux-arm-64 ;;+ Darwin:arm64) BINARY=wrapper-macosx-arm-64 ;;+ Darwin:x86_64)+ if [ "$(sysctl -in sysctl.proc_translated 2>/dev/null || true)" = 1 ]; then+ BINARY=wrapper-macosx-arm-64+ else+ echo 'Wrapper requires Apple Silicon on macOS.' >&2; exit 1+ fi ;;+ MINGW*:*|MSYS*:*|CYGWIN*:*)+ case "${PROCESSOR_ARCHITEW6432:-${PROCESSOR_ARCHITECTURE:-}}" in+ ARM64|arm64) BINARY=wrapper-windows-arm-64.exe ;;+ AMD64|amd64) BINARY=wrapper-windows-x86-64.exe ;;+ *) echo 'Wrapper requires Windows amd64 or arm64.' >&2; exit 1 ;;+ esac ;;+ *) echo "Unsupported platform: $(uname -s) $(uname -m)" >&2; exit 1 ;;+esac+exec "$DIRECTORY/../boot/$BINARY" --command "$(basename "$SCRIPT" .sh)" "$WRAPPER_CONF" "$@"diff --git a/server-product/wrapper/distribution/bin/server.bat b/server-product/wrapper/distribution/bin/server.batnew file mode 100644index 0000000000..aa42e25b13--- /dev/null+++ b/server-product/wrapper/distribution/bin/server.bat@@ -0,0 +1,13 @@+@echo off+setlocal+rem Java service launcher. Use an elevated prompt to install/remove services.+set "_ARCH=%PROCESSOR_ARCHITECTURE%"+if defined PROCESSOR_ARCHITEW6432 set "_ARCH=%PROCESSOR_ARCHITEW6432%"+if /i "%_ARCH%"=="AMD64" set "_BINARY=wrapper-windows-x86-64.exe"+if /i "%_ARCH%"=="ARM64" set "_BINARY=wrapper-windows-arm-64.exe"+if not defined _BINARY (+ echo Wrapper requires Windows amd64 or arm64. 1>&2+ exit /b 1+)+"%~dp0..\boot\%_BINARY%" --script "%~n0" "%~dp0..\conf\wrapper.conf" %*+exit /b %ERRORLEVEL%diff --git a/server-product/wrapper/distribution/bin/server.sh b/server-product/wrapper/distribution/bin/server.shnew file mode 100755index 0000000000..239f662803--- /dev/null+++ b/server-product/wrapper/distribution/bin/server.sh@@ -0,0 +1,50 @@+#!/bin/bash+# Java service launcher. JVM and service settings belong in conf/wrapper.conf.+set -e++#RUN_AS_USER=+FILES_TO_SOURCE=++# Resolve installed init-script symlinks before locating the distribution.+SCRIPT=${BASH_SOURCE[0]}+while [ -L "$SCRIPT" ]; do+ DIRECTORY=$(cd -P "$(dirname "$SCRIPT")" && pwd)+ SCRIPT=$(readlink "$SCRIPT")+ [[ "$SCRIPT" = /* ]] || SCRIPT=$DIRECTORY/$SCRIPT+done+DIRECTORY=$(cd -P "$(dirname "$SCRIPT")" && pwd)+SCRIPT=$DIRECTORY/$(basename "$SCRIPT")+cd "$DIRECTORY"+WRAPPER_CONF=../conf/wrapper.conf++if [ -f "${SCRIPT%.sh}.shconf" ]; then+ source "${SCRIPT%.sh}.shconf"+fi+if [ -n "$FILES_TO_SOURCE" ]; then+ IFS=';' read -r -a SOURCE_FILES <<< "$FILES_TO_SOURCE"+ for SOURCE_FILE in "${SOURCE_FILES[@]}"; do+ source "$SOURCE_FILE"+ done+fi+export RUN_AS_USER=${RUN_AS_USER:-}+export WRAPPER_SCRIPT=$SCRIPT++case "$(uname -s):$(uname -m)" in+ Linux:x86_64) BINARY=wrapper-linux-x86-64 ;;+ Linux:aarch64|Linux:arm64) BINARY=wrapper-linux-arm-64 ;;+ Darwin:arm64) BINARY=wrapper-macosx-arm-64 ;;+ Darwin:x86_64)+ if [ "$(sysctl -in sysctl.proc_translated 2>/dev/null || true)" = 1 ]; then+ BINARY=wrapper-macosx-arm-64+ else+ echo 'Wrapper requires Apple Silicon on macOS.' >&2; exit 1+ fi ;;+ MINGW*:*|MSYS*:*|CYGWIN*:*)+ case "${PROCESSOR_ARCHITEW6432:-${PROCESSOR_ARCHITECTURE:-}}" in+ ARM64|arm64) BINARY=wrapper-windows-arm-64.exe ;;+ AMD64|amd64) BINARY=wrapper-windows-x86-64.exe ;;+ *) echo 'Wrapper requires Windows amd64 or arm64.' >&2; exit 1 ;;+ esac ;;+ *) echo "Unsupported platform: $(uname -s) $(uname -m)" >&2; exit 1 ;;+esac+exec "$DIRECTORY/../boot/$BINARY" --script "$(basename "$SCRIPT" .sh)" "$WRAPPER_CONF" "$@"diff --git a/server-product/wrapper/distribution/bin/upgrade.bat b/server-product/wrapper/distribution/bin/upgrade.batnew file mode 100644index 0000000000..dd5fe27d46--- /dev/null+++ b/server-product/wrapper/distribution/bin/upgrade.bat@@ -0,0 +1,13 @@+@echo off+setlocal+rem Java service launcher. Use an elevated prompt to install/remove services.+set "_ARCH=%PROCESSOR_ARCHITECTURE%"+if defined PROCESSOR_ARCHITEW6432 set "_ARCH=%PROCESSOR_ARCHITEW6432%"+if /i "%_ARCH%"=="AMD64" set "_BINARY=wrapper-windows-x86-64.exe"+if /i "%_ARCH%"=="ARM64" set "_BINARY=wrapper-windows-arm-64.exe"+if not defined _BINARY (+ echo Wrapper requires Windows amd64 or arm64. 1>&2+ exit /b 1+)+"%~dp0..\boot\%_BINARY%" --command "%~n0" "%~dp0..\conf\wrapper.conf" %*+exit /b %ERRORLEVEL%diff --git a/server-product/wrapper/distribution/bin/upgrade.sh b/server-product/wrapper/distribution/bin/upgrade.shnew file mode 100755index 0000000000..13feeabc46--- /dev/null+++ b/server-product/wrapper/distribution/bin/upgrade.sh@@ -0,0 +1,50 @@+#!/bin/bash+# Java service launcher. JVM and service settings belong in conf/wrapper.conf.+set -e++#RUN_AS_USER=+FILES_TO_SOURCE=++# Resolve installed init-script symlinks before locating the distribution.+SCRIPT=${BASH_SOURCE[0]}+while [ -L "$SCRIPT" ]; do+ DIRECTORY=$(cd -P "$(dirname "$SCRIPT")" && pwd)+ SCRIPT=$(readlink "$SCRIPT")+ [[ "$SCRIPT" = /* ]] || SCRIPT=$DIRECTORY/$SCRIPT+done+DIRECTORY=$(cd -P "$(dirname "$SCRIPT")" && pwd)+SCRIPT=$DIRECTORY/$(basename "$SCRIPT")+cd "$DIRECTORY"+WRAPPER_CONF=../conf/wrapper.conf++if [ -f "${SCRIPT%.sh}.shconf" ]; then+ source "${SCRIPT%.sh}.shconf"+fi+if [ -n "$FILES_TO_SOURCE" ]; then+ IFS=';' read -r -a SOURCE_FILES <<< "$FILES_TO_SOURCE"+ for SOURCE_FILE in "${SOURCE_FILES[@]}"; do+ source "$SOURCE_FILE"+ done+fi+export RUN_AS_USER=${RUN_AS_USER:-}+export WRAPPER_SCRIPT=$SCRIPT++case "$(uname -s):$(uname -m)" in+ Linux:x86_64) BINARY=wrapper-linux-x86-64 ;;+ Linux:aarch64|Linux:arm64) BINARY=wrapper-linux-arm-64 ;;+ Darwin:arm64) BINARY=wrapper-macosx-arm-64 ;;+ Darwin:x86_64)+ if [ "$(sysctl -in sysctl.proc_translated 2>/dev/null || true)" = 1 ]; then+ BINARY=wrapper-macosx-arm-64+ else+ echo 'Wrapper requires Apple Silicon on macOS.' >&2; exit 1+ fi ;;+ MINGW*:*|MSYS*:*|CYGWIN*:*)+ case "${PROCESSOR_ARCHITEW6432:-${PROCESSOR_ARCHITECTURE:-}}" in+ ARM64|arm64) BINARY=wrapper-windows-arm-64.exe ;;+ AMD64|amd64) BINARY=wrapper-windows-x86-64.exe ;;+ *) echo 'Wrapper requires Windows amd64 or arm64.' >&2; exit 1 ;;+ esac ;;+ *) echo "Unsupported platform: $(uname -s) $(uname -m)" >&2; exit 1 ;;+esac+exec "$DIRECTORY/../boot/$BINARY" --command "$(basename "$SCRIPT" .sh)" "$WRAPPER_CONF" "$@"diff --git a/server-product/wrapper/distribution/boot/wrapper-linux-arm-64 b/server-product/wrapper/distribution/boot/wrapper-linux-arm-64new file mode 100755index 0000000000..8b228c8a80Binary files /dev/null and b/server-product/wrapper/distribution/boot/wrapper-linux-arm-64 differdiff --git a/server-product/wrapper/distribution/boot/wrapper-linux-x86-64 b/server-product/wrapper/distribution/boot/wrapper-linux-x86-64new file mode 100755index 0000000000..59fa31187eBinary files /dev/null and b/server-product/wrapper/distribution/boot/wrapper-linux-x86-64 differdiff --git a/server-product/wrapper/distribution/boot/wrapper-macosx-arm-64 b/server-product/wrapper/distribution/boot/wrapper-macosx-arm-64new file mode 100755index 0000000000..fe3bea5e60Binary files /dev/null and b/server-product/wrapper/distribution/boot/wrapper-macosx-arm-64 differdiff --git a/server-product/wrapper/distribution/boot/wrapper-macosx-universal-64 b/server-product/wrapper/distribution/boot/wrapper-macosx-universal-64new file mode 100755index 0000000000..fe3bea5e60Binary files /dev/null and b/server-product/wrapper/distribution/boot/wrapper-macosx-universal-64 differdiff --git a/server-product/wrapper/distribution/boot/wrapper-windows-arm-64.exe b/server-product/wrapper/distribution/boot/wrapper-windows-arm-64.exenew file mode 100755index 0000000000..2312263c3bBinary files /dev/null and b/server-product/wrapper/distribution/boot/wrapper-windows-arm-64.exe differdiff --git a/server-product/wrapper/distribution/boot/wrapper-windows-x86-64.exe b/server-product/wrapper/distribution/boot/wrapper-windows-x86-64.exenew file mode 100755index 0000000000..9b17627c76Binary files /dev/null and b/server-product/wrapper/distribution/boot/wrapper-windows-x86-64.exe differdiff --git a/server-product/wrapper/distribution/boot/wrapper.jar b/server-product/wrapper/distribution/boot/wrapper.jarnew file mode 100644index 0000000000..9dbaa7701fBinary files /dev/null and b/server-product/wrapper/distribution/boot/wrapper.jar differdiff --git a/server-product/wrapper/distribution/conf/wrapper.conf b/server-product/wrapper/distribution/conf/wrapper.confnew file mode 100644index 0000000000..0ff28a2e5e--- /dev/null+++ b/server-product/wrapper/distribution/conf/wrapper.conf@@ -0,0 +1,66 @@+#encoding=UTF-8+# OneDev service wrapper configuration. Paths are relative to the boot directory.+# Existing JSW property names are retained. Restart the service after editing JVM+# settings. Remove/install the service after changing service registration settings.+# Optional extra configuration: #include ../conf/extra.conf+# Required extra configuration: #include.required ../conf/extra.conf++# Java 17 or higher. Quote paths containing spaces.+wrapper.java.command=java+wrapper.java.version.min=17+wrapper.java.mainclass=io.onedev.wrapper.WrapperSimpleApp+wrapper.java.classpath.1=*.jar++wrapper.java.library.path.1=.+wrapper.java.library.path.append_system_path=TRUE++# Numbered properties may have gaps. Each additional property is one JVM argument.+wrapper.java.additional.1=-Djava.awt.headless=true+wrapper.java.additional.2=-Djdk.io.File.allowDeleteReadOnlyFiles=true+wrapper.java.additional.10=--add-opens=java.base/sun.nio.ch=ALL-UNNAMED+wrapper.java.additional.11=--add-opens=java.base/java.lang=ALL-UNNAMED+wrapper.java.additional.12=--add-opens=java.base/java.lang.reflect=ALL-UNNAMED+wrapper.java.additional.13=--add-opens=java.base/java.lang.invoke=ALL-UNNAMED+wrapper.java.additional.14=--add-opens=java.base/java.util=ALL-UNNAMED+wrapper.java.additional.15=--add-opens=java.base/java.text=ALL-UNNAMED+wrapper.java.additional.16=--add-opens=java.desktop/java.awt.font=ALL-UNNAMED+wrapper.java.additional.30=--add-modules=java.se+wrapper.java.additional.31=--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED+wrapper.java.additional.32=--add-opens=java.management/sun.management=ALL-UNNAMED+wrapper.java.additional.33=--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED+wrapper.java.additional.50=--add-opens=java.base/sun.nio.fs=ALL-UNNAMED+wrapper.java.additional.100=-XX:MaxRAMPercentage=%max_memory_percent%+wrapper.java.additional.101=-Xss%thread_stack_size%+set.default.max_memory_percent=50+set.default.thread_stack_size=1024k+# Alternatively set wrapper.java.initmemory and wrapper.java.maxmemory in MB.++wrapper.app.parameter.1=io.onedev.commons.bootstrap.Bootstrap++# JVM stdout/stderr go to console and this rotating log. NONE disables a destination.+wrapper.console.loglevel=INFO+wrapper.logfile=../logs/console.log+wrapper.logfile.loglevel=INFO+wrapper.logfile.maxsize=250k+wrapper.logfile.maxfiles=3++wrapper.name=onedev.server+wrapper.displayname=OneDev+wrapper.description=OneDev++# Optional Unix service account (also accepts RUN_AS_USER in bin/*.shconf).+#wrapper.daemon.user=onedev++# Windows service registration. Empty account uses LocalSystem.+wrapper.ntservice.dependency.1=+wrapper.ntservice.starttype=AUTO_START+wrapper.ntservice.account=+wrapper.ntservice.password=++# Zero allows unlimited startup/shutdown time. Java shutdown hooks run on stop.+wrapper.startup.timeout=0+wrapper.shutdown.timeout=0+# Consecutive unexpected JVM failures are bounded to prevent a restart loop.+wrapper.restart.delay=5+wrapper.max_failed_invocations=5+wrapper.successful_invocation_time=300diff --git a/server-product/wrapper/update.sh b/server-product/wrapper/update.shnew file mode 100755index 0000000000..42e92095a6--- /dev/null+++ b/server-product/wrapper/update.sh@@ -0,0 +1,582 @@+#!/bin/bash+# Maintain OneDev's bundled Wrapper release (compatible with Bash 3.2).+set -euo pipefail+export LC_ALL=C+WRAPPER_DIR=$(cd "$(dirname "$0")" && pwd)+SCRIPT="$WRAPPER_DIR/$(basename "$0")"++usage() {+ cat <<EOF+Usage: $0 [COMMAND]+ $0 [WRAPPER_DIRECTORY] [--sandbox]++Commands:+ update [DIRECTORY] [--sandbox] Download and import the latest release (default)+ or copy build.sh output from the specified checkout+ import ARCHIVE [OPTIONS] Import a local release archive+ --checksum FILE Use this checksum file instead of ARCHIVE.sha256+ --destination DIRECTORY Import into this directory instead of the script directory+ --sandbox After updating, refresh wrapper binaries and scripts+ in ../target/sandbox relative to the import directory+ check-package SERVER.zip [DIR] Verify server and agent packaging against DIR+ (defaults to the script directory)+ test Run offline importer, updater, and package checks+ help Show this help+EOF+}++fail() {+ echo "$*" >&2+ exit 1+}++require_sandbox() {+ [ -d "$1/../target/sandbox" ] \+ || fail "Error: Development sandbox not found: $1/../target/sandbox. Run ./dev.sh build first."+}++sha256() {+ if command -v sha256sum >/dev/null 2>&1; then+ sha256sum "$1" | cut -d ' ' -f 1+ else+ shasum -a 256 "$1" | cut -d ' ' -f 1+ fi+}++valid_path() {+ # Release paths are deliberately restricted before passing them to tar or unzip.+ [[ "$1" =~ ^[A-Za-z0-9._+/-]+$ ]] || return 1+ case "/$1/" in+ *//*|*/./*|*/../*) return 1 ;;+ esac+}++parse_checksum() {+ [[ "$1" =~ ^[0-9a-f]{64}' '.+$ ]] || fail "Invalid checksum entry: $1"+ checksum_digest=${1%% *}+ checksum_name=${1#* }+ valid_path "$checksum_name" || fail "Invalid checksum path: $checksum_name"+}++file_list() {+ (cd "$1" && find . -type f | sed 's|^./||' | sort)+}++write_manifest() {+ local directory=$1 name digest+ while IFS= read -r name; do+ [ "$name" = SHA256SUMS ] && continue+ valid_path "$name" || fail "Invalid release path: $name"+ digest=$(sha256 "$directory/$name")+ printf '%s %s\n' "$digest" "$name"+ done < <(file_list "$directory")+}++verify_manifest() {+ local directory=$1 line+ local names=()+ [ -f "$directory/SHA256SUMS" ] || fail "Missing SHA256SUMS in $directory"+ while IFS= read -r line || [ -n "$line" ]; do+ parse_checksum "$line"+ [ -f "$directory/$checksum_name" ] || fail "Missing release file: $checksum_name"+ [ "$(sha256 "$directory/$checksum_name")" = "$checksum_digest" ] \+ || fail "Release file checksum does not match: $checksum_name"+ names+=("$checksum_name")+ done < "$directory/SHA256SUMS"+ cmp -s <(printf '%s\n' "${names[@]}" | sort) \+ <(file_list "$directory" | sed '/^SHA256SUMS$/d') \+ || fail "Release manifest must cover every file exactly once"+}++# Verify and adapt a release before replacing the prepared distribution.+import_release() (+ import_usage() {+ echo "Usage: $0 import ARCHIVE [--checksum FILE] [--destination DIRECTORY] [--sandbox]"+ }++ archive=+ checksum=+ destination="$WRAPPER_DIR"+ sandbox=false+ while [ "$#" -gt 0 ]; do+ case "$1" in+ --sandbox) sandbox=true; shift ;;+ --checksum|--destination)+ [ "$#" -ge 2 ] || fail "Missing value for $1"+ if [ "$1" = --checksum ]; then checksum=$2; else destination=$2; fi+ shift 2 ;;+ -h|--help) import_usage; exit 0 ;;+ -*) fail "Unknown option: $1" ;;+ *) [ -z "$archive" ] || fail "Only one archive may be imported"; archive=$1; shift ;;+ esac+ done+ [ -n "$archive" ] || { import_usage >&2; exit 1; }+ if [ "$sandbox" = true ]; then require_sandbox "$destination"; fi+ archive=$(cd "$(dirname "$archive")" && pwd)/$(basename "$archive")+ checksum=${checksum:-$archive.sha256}+ parse_checksum "$(cat "$checksum")"+ [ "$checksum_name" = "$(basename "$archive")" ] \+ && [ "$(sha256 "$archive")" = "$checksum_digest" ] \+ || fail "Release archive checksum does not match"+ [ -f "$destination/wrapper.conf" ] || fail "Missing $destination/wrapper.conf"+ destination=$(cd "$destination" && pwd)++ temporary=$(mktemp -d "${TMPDIR:-/tmp}/onedev-wrapper-import.XXXXXX")+ trap 'rm -rf "$temporary"' EXIT+ tar -tzf "$archive" > "$temporary/entries"+ root=+ while IFS= read -r entry; do+ name=${entry%/}+ valid_path "$name" || fail "Invalid archive path: $entry"+ [ -n "$root" ] || root=${name%%/*}+ [ "${name%%/*}" = "$root" ] || fail "Expected one release directory"+ done < "$temporary/entries"+ [ -n "$root" ] || fail "Empty release archive"+ [ -z "$(sort "$temporary/entries" | uniq -d)" ] || fail "Duplicate archive entry"+ # Reject symlinks, hard links, and special files before extracting anything.+ tar -tvzf "$archive" | awk 'substr($0, 1, 1) != "-" && substr($0, 1, 1) != "d" {exit 1}' \+ || fail "Archive may contain only regular files and directories"+ mkdir "$temporary/extracted"+ tar -xzf "$archive" -C "$temporary/extracted"+ release="$temporary/extracted/$root"+ verify_manifest "$release"++ prepare_distribution "$release" "$destination" "$sandbox"+)++# Share OneDev adaptations between verified releases and local development builds.+prepare_distribution() (+ release=$1+ destination=$2+ [ -f "$destination/wrapper.conf" ] || fail "Missing $destination/wrapper.conf"+ sandbox=+ if [ "$3" = true ]; then+ require_sandbox "$destination"+ sandbox=$(cd "$destination/../target/sandbox" && pwd)+ fi+ temporary=$(mktemp -d "${TMPDIR:-/tmp}/onedev-wrapper-prepare.XXXXXX")+ trap 'rm -rf "$temporary"' EXIT+ for name in wrapper-linux-x86-64 wrapper-linux-arm-64 wrapper-macosx-arm-64 \+ wrapper-windows-x86-64.exe wrapper-windows-arm-64.exe wrapper.jar; do+ [ -f "$release/boot/$name" ] || fail "Missing release artifact: $name"+ done+ [ -f "$release/VERSION" ] || fail "Missing release VERSION"++ # Prepare all adaptations and checksums before replacing any checked-in files.+ prepared="$temporary/prepared"+ mkdir "$prepared"+ cp -R "$destination/." "$prepared/"+ distribution="$prepared/distribution"+ rm -rf "$distribution"+ mkdir -p "$distribution/bin" "$distribution/conf" "$distribution/agent/bin" "$distribution/agent/conf"+ cp -R "$release/boot" "$distribution/boot"+ cp "$distribution/boot/wrapper-macosx-arm-64" "$distribution/boot/wrapper-macosx-universal-64"+ cp -R "$distribution/boot" "$distribution/agent/boot"+ for extension in sh bat; do+ launcher="$release/bin/service.$extension"+ [ -f "$launcher" ] || fail "Missing release launcher: $launcher"+ [ "$(awk '{count += gsub(/ --script /, "&")} END {print count+0}' "$launcher")" = 1 ] \+ || fail "Unrecognized launcher format: $launcher"+ cp "$launcher" "$distribution/bin/server.$extension"+ cp "$launcher" "$distribution/agent/bin/agent.$extension"+ for command in restore-db backup-db upgrade apply-db-constraints reset-admin-password enable-internal-login; do+ sed 's/ --script / --command /' "$launcher" > "$distribution/bin/$command.$extension"+ done+ done+ for kind in server agent; do+ if [ "$kind" = server ]; then+ prefix= main_class=io.onedev.commons.bootstrap.Bootstrap app_name=onedev.server display_name=OneDev classpath=+ else+ prefix=agent/ main_class=io.onedev.agent.Agent app_name=onedev.agent display_name='OneDev Agent'+ classpath='wrapper.java.classpath.2=../lib/agentVersion/*.jar'+ fi+ configuration="$distribution/${prefix}conf/wrapper.conf"+ sed -e "s|@bootstrap\.class@|$main_class|g" -e "s|@app\.name@|$app_name|g" \+ -e "s|@app\.long\.name@|$display_name|g" -e "s|@app\.description@|$display_name|g" \+ -e "s|@classpath2@|$classpath|g" "$destination/wrapper.conf" > "$configuration"+ if grep -Eq '@[A-Za-z0-9_.]+@' "$configuration"; then+ fail "Unresolved placeholder in OneDev wrapper configuration"+ fi+ done+ while IFS= read -r name; do+ case "$name" in+ *.sh|*/wrapper-*) chmod 755 "$distribution/$name" ;;+ *) chmod 644 "$distribution/$name" ;;+ esac+ done < <(file_list "$distribution")+ cp "$release/VERSION" "$prepared/VERSION"+ write_manifest "$prepared" > "$prepared/SHA256SUMS"+ rm -rf "$destination/distribution"+ mv "$distribution" "$destination/distribution"+ cp "$prepared/VERSION" "$prepared/SHA256SUMS" "$destination/"+ echo "Imported Wrapper $(cat "$destination/VERSION") into $destination"+ if [ -n "$sandbox" ]; then+ refresh_sandbox "$destination/distribution" "$sandbox"+ fi+)++# Replace file entries instead of overwriting native executables in place.+refresh_sandbox() (+ distribution=$1+ sandbox=$2+ temporary=$(mktemp -d "$sandbox/.wrapper-update.XXXXXX")+ trap 'rm -rf "$temporary"' EXIT+ while IFS= read -r name; do+ case "$name" in+ boot/wrapper*|bin/*.sh|bin/*.bat|agent/boot/wrapper*|agent/bin/*.sh|agent/bin/*.bat)+ mkdir -p "$temporary/$(dirname "$name")"+ cp -p "$distribution/$name" "$temporary/$name"+ ;;+ esac+ done < <(file_list "$distribution")+ while IFS= read -r name; do+ mkdir -p "$sandbox/$(dirname "$name")"+ mv -f "$temporary/$name" "$sandbox/$name"+ done < <(file_list "$temporary")+ echo "Updated wrapper binaries and scripts in $sandbox"+)++update_wrapper() (+ source=+ sandbox=false+ while [ "$#" -gt 0 ]; do+ case "$1" in+ --sandbox) sandbox=true ;;+ -h|--help) usage; exit 0 ;;+ -*) fail "Unknown option: $1" ;;+ *) [ -z "$source" ] || fail "Only one wrapper checkout may be imported"; source=$1 ;;+ esac+ shift+ done+ if [ "$sandbox" = true ]; then require_sandbox "$WRAPPER_DIR"; fi+ if [ -n "$source" ]; then+ update_local "$source" "$sandbox"+ else+ update_release "$sandbox"+ fi+)++# Overlay available local targets, retaining bundled binaries for unbuilt platforms.+update_local() (+ source=$1+ [ -d "$source" ] || fail "Wrapper checkout not found: $source"+ source=$(cd "$source" && pwd)+ [ -f "$source/dist/boot/wrapper.jar" ] \+ || fail "Missing $source/dist/boot/wrapper.jar; run ./build.sh in $source first"+ built=false+ for name in wrapper-linux-x86-64 wrapper-linux-arm-64 wrapper-macosx-arm-64 \+ wrapper-windows-x86-64.exe wrapper-windows-arm-64.exe; do+ if [ -f "$source/dist/boot/$name" ]; then built=true; fi+ done+ [ "$built" = true ] || fail "No locally built wrapper binaries; run ./build.sh in $source first"+ version=$(awk '+ /^\[package\][[:space:]]*$/ {package=1; next}+ /^\[/ {package=0}+ package && /^[[:space:]]*version[[:space:]]*=/ {+ sub(/^[^"]*"/, ""); sub(/".*$/, ""); print; exit+ }' "$source/Cargo.toml")+ [ -n "$version" ] || fail "Missing package version in $source/Cargo.toml"++ temporary=$(mktemp -d "${TMPDIR:-/tmp}/onedev-wrapper-local.XXXXXX")+ trap 'rm -rf "$temporary"' EXIT+ release="$temporary/release"+ mkdir -p "$release/boot" "$release/bin"+ if [ -d "$WRAPPER_DIR/distribution/boot" ]; then+ cp -R "$WRAPPER_DIR/distribution/boot/." "$release/boot/"+ fi+ cp -R "$source/dist/boot/." "$release/boot/"+ cp "$source/resources/App.sh.in" "$release/bin/service.sh"+ cp "$source/resources/AppCommand.bat.in" "$release/bin/service.bat"+ printf '%s-local\n' "$version" > "$release/VERSION"+ echo "Importing local Wrapper build from $source"+ prepare_distribution "$release" "$WRAPPER_DIR" "$2"+)++# Download the latest published release, then reuse the local importer.+update_release() (+ site=https://code.onedev.io/onedev/wrapper/~sites/public/+ curl_options=(--fail --silent --show-error --location --connect-timeout 30)+ temporary=$(mktemp -d "${TMPDIR:-/tmp}/onedev-wrapper-download.XXXXXX")+ trap 'rm -rf "$temporary"' EXIT+ echo "Checking Wrapper releases at $site"+ curl "${curl_options[@]}" "$site" > "$temporary/index.html"+ # Each publication replaces the site with one release and its checksum.+ awk 'BEGIN {RS="<"}+ tolower($0) ~ /^a[[:space:]]/ {+ if (match($0, /[Hh][Rr][Ee][Ff][[:space:]]*=[[:space:]]*["\047]wrapper-[0-9][A-Za-z0-9.+-]*\.tar\.gz["\047]/)) {+ name = substr($0, RSTART, RLENGTH)+ sub(/^[^=]*=[[:space:]]*["\047]/, "", name)+ sub(/["\047]$/, "", name)+ print name+ }+ }' "$temporary/index.html" | sort -u > "$temporary/releases"+ [ "$(wc -l < "$temporary/releases" | tr -d ' ')" = 1 ] \+ || fail "Expected exactly one Wrapper release on the public download site"+ name=$(cat "$temporary/releases")+ for filename in "$name" "$name.sha256"; do+ echo "Downloading $filename..."+ curl "${curl_options[@]}" --output "$temporary/$filename" "$site$filename"+ done+ if [ "$1" = true ]; then+ import_release "$temporary/$name" --sandbox+ else+ import_release "$temporary/$name"+ fi+)++# Verify Maven outputs, executable permissions, and incremental JSW cleanup.+check_package() (+ [ "$#" -ge 1 ] && [ "$#" -le 2 ] \+ || fail "Usage: $0 check-package SERVER.zip [WRAPPER_INPUTS]"+ archive=$1+ inputs=${2:-$WRAPPER_DIR}+ agent=$(dirname "$archive")/agent+ distribution="$inputs/distribution"+ temporary=$(mktemp -d "${TMPDIR:-/tmp}/onedev-wrapper-check.XXXXXX")+ trap 'rm -rf "$temporary"' EXIT+ unzip -Z1 "$archive" > "$temporary/entries"+ prefix=+ while IFS= read -r name; do+ valid_path "${name%/}" || fail "Invalid package path: $name"+ [ -n "$prefix" ] || prefix=${name%%/*}/+ [ "${name%%/*}/" = "$prefix" ] || fail "Expected one package directory"+ case "$name" in *libwrapper-*) fail "Obsolete JSW file in package: $name" ;; esac+ done < "$temporary/entries"+ [ -n "$prefix" ] || fail "Empty server package"+ # Only extract the files being checked, preserving their executable permissions.+ unzip -q "$archive" "${prefix}boot/*" "${prefix}bin/*" "${prefix}conf/wrapper.conf" \+ "${prefix}agent/*" "${prefix}lib/io.onedev.server-product-*.jar" -d "$temporary/package"+ package="$temporary/package/${prefix%/}"+ while IFS= read -r name; do+ cmp -s "$distribution/$name" "$package/$name" || fail "Packaged file differs: $name"+ if [ -x "$distribution/$name" ]; then+ [ -x "$package/$name" ] || fail "Missing executable permission: $name"+ fi+ done < <(file_list "$distribution")+ while IFS= read -r name; do+ cmp -s "$distribution/boot/$name" "$agent/boot/$name" || fail "Agent boot file differs: $name"+ if [ -x "$distribution/boot/$name" ]; then+ [ -x "$agent/boot/$name" ] || fail "Missing agent executable permission: $name"+ fi+ done < <(file_list "$distribution/boot")+ for name in server upgrade backup-db restore-db reset-admin-password apply-db-constraints enable-internal-login; do+ if [ "$name" = server ]; then mode=--script; else mode=--command; fi+ for extension in sh bat; do+ grep -q -- "$mode" "$package/bin/$name.$extension" || fail "Wrong launcher mode: $name.$extension"+ done+ done+ for name in conf/wrapper.conf agent/conf/wrapper.conf; do+ if grep -Eq '@bootstrap.class@|@app.name@' "$package/$name"; then+ fail "Unresolved configuration placeholder: $name"+ fi+ done+ [ -f "$agent/conf/wrapper.conf" ] || fail "Missing agent configuration"+ if grep -q agentVersion "$agent/conf/wrapper.conf"; then fail "Unresolved agent version"; fi+ for name in "$agent"/boot/libwrapper-*; do+ [ ! -e "$name" ] || fail "Obsolete JSW file in agent: $name"+ done+ # The product jar must not accidentally embed a populated development sandbox.+ for product in "$package"/lib/io.onedev.server-product-*.jar; do+ unzip -Z1 "$product" > "$temporary/product-entries"+ if grep -Eq '^sandbox/(lib/|boot/wrapper|boot/libwrapper|bin/)' "$temporary/product-entries"; then+ fail "Product jar contains development sandbox files"+ fi+ grep -qx sandbox/release.properties "$temporary/product-entries" || fail "Missing sandbox/release.properties"+ done+ verify_manifest "$inputs"+ echo "Server archive, agent distribution, embedded product jar, permissions, and checksums verified"+)++# Exercise the maintenance commands without native builds or network access.+test_wrapper() (+ temporary=$(mktemp -d "${TMPDIR:-/tmp}/onedev-wrapper-test.XXXXXX")+ trap 'rm -rf "$temporary"' EXIT+ export COPYFILE_DISABLE=1+ fixture="$temporary/release/wrapper-1.0.0"+ destination="$temporary/wrapper inputs"+ archive="$temporary/wrapper-1.0.0.tar.gz"+ mkdir -p "$fixture/boot" "$fixture/bin" "$destination"+ cp "$WRAPPER_DIR/wrapper.conf" "$destination/wrapper.conf"+ for name in wrapper-linux-x86-64 wrapper-linux-arm-64 wrapper-macosx-arm-64 \+ wrapper-windows-x86-64.exe wrapper-windows-arm-64.exe wrapper.jar; do+ printf 'binary\000\377' > "$fixture/boot/$name"+ done+ printf '#!/bin/bash\nexec binary --script "$0" "$@"\n' > "$fixture/bin/service.sh"+ printf '@echo off\r\nbinary --script "%%~n0" %%*\r\n' > "$fixture/bin/service.bat"+ printf '1.0.0\n' > "$fixture/VERSION"++ pack_release() {+ write_manifest "$fixture" > "$fixture/SHA256SUMS"+ tar -czf "$archive" -C "$temporary/release" wrapper-1.0.0+ printf '%s %s\n' "$(sha256 "$archive")" "$(basename "$archive")" > "$archive.sha256"+ }++ run_import() {+ "$BASH" "$SCRIPT" import "$archive" --destination "$destination"+ }++ expect_rejection() {+ if run_import > "$temporary/error" 2>&1; then fail "Invalid release was accepted"; fi+ diff -r "$temporary/before" "$destination" || fail "Invalid release modified prepared files"+ }++ # New boot artifacts must reach both distributions; retired files must disappear.+ printf 'future format\000\377' > "$fixture/boot/new-runtime.dat"+ pack_release+ run_import+ for prefix in '' agent/; do+ cmp "$fixture/boot/new-runtime.dat" "$destination/distribution/${prefix}boot/new-runtime.dat"+ done+ touch "$destination/distribution/bin/retired-command.sh"+ rm "$fixture/boot/new-runtime.dat"+ pack_release+ run_import+ for name in bin/retired-command.sh boot/new-runtime.dat agent/boot/new-runtime.dat; do+ [ ! -e "$destination/distribution/$name" ] || fail "Retired file survived: $name"+ done+ cmp "$WRAPPER_DIR/wrapper.conf" "$destination/wrapper.conf"++ # Preserve binary bytes, CRLF launchers, substitutions, modes, and manifest coverage.+ distribution="$destination/distribution"+ cmp "$fixture/bin/service.sh" "$distribution/bin/server.sh"+ cmp "$fixture/bin/service.bat" "$distribution/agent/bin/agent.bat"+ sed 's/ --script / --command /' "$fixture/bin/service.bat" > "$temporary/command.bat"+ cmp "$temporary/command.bat" "$distribution/bin/backup-db.bat"+ grep -q ' --command ' "$distribution/bin/backup-db.sh"+ [ -x "$distribution/bin/backup-db.sh" ]+ [ -x "$distribution/boot/wrapper-linux-x86-64" ]+ [ ! -x "$distribution/boot/wrapper.jar" ]+ cmp "$distribution/boot/wrapper-macosx-arm-64" "$distribution/boot/wrapper-macosx-universal-64"+ grep -q io.onedev.commons.bootstrap.Bootstrap "$distribution/conf/wrapper.conf"+ grep -q io.onedev.agent.Agent "$distribution/agent/conf/wrapper.conf"+ grep -Fq '../lib/agentVersion/*.jar' "$distribution/agent/conf/wrapper.conf"+ if grep -Eq '@[A-Za-z0-9_.]+@' "$distribution/conf/wrapper.conf" "$distribution/agent/conf/wrapper.conf"; then+ fail "Unresolved placeholder"+ fi+ verify_manifest "$destination"+ cp -R "$destination" "$temporary/before"++ # Bad downloads and invalid release contents must leave the previous import intact.+ printf '%064d %s\n' 0 "$(basename "$archive")" > "$archive.sha256"+ expect_rejection+ cp "$fixture/bin/service.sh" "$temporary/launcher"+ printf 'unknown launcher format\n' > "$fixture/bin/service.sh"+ pack_release+ expect_rejection+ cp "$temporary/launcher" "$fixture/bin/service.sh"+ mv "$fixture/boot/wrapper-linux-x86-64" "$temporary/binary"+ pack_release+ expect_rejection+ mv "$temporary/binary" "$fixture/boot/wrapper-linux-x86-64"+ pack_release+ printf 'tampered\n' >> "$fixture/boot/wrapper.jar"+ tar -czf "$archive" -C "$temporary/release" wrapper-1.0.0+ printf '%s %s\n' "$(sha256 "$archive")" "$(basename "$archive")" > "$archive.sha256"+ expect_rejection+ printf 'binary\000\377' > "$fixture/boot/wrapper.jar"+ ln -s "$temporary/binary" "$fixture/boot/link"+ pack_release+ expect_rejection+ rm "$fixture/boot/link"+ pack_release+ sed '/ VERSION$/d' "$fixture/SHA256SUMS" > "$temporary/incomplete-manifest"+ cp "$temporary/incomplete-manifest" "$fixture/SHA256SUMS"+ tar -czf "$archive" -C "$temporary/release" wrapper-1.0.0+ printf '%s %s\n' "$(sha256 "$archive")" "$(basename "$archive")" > "$archive.sha256"+ expect_rejection+ echo "Wrapper importer tests passed"++ # Exercise the downloader offline, including multiple links on the same HTML line.+ pack_release+ mkdir -p "$temporary/wrapper" "$temporary/mock-bin" "$temporary/downloads"+ cp "$SCRIPT" "$WRAPPER_DIR/wrapper.conf" "$temporary/wrapper/"+ cat > "$temporary/mock-bin/curl" <<-'MOCK'+ #!/bin/bash+ set -euo pipefail+ output=+ while [ "$#" -gt 1 ]; do+ case "$1" in+ --output) output=$2; shift 2 ;;+ --connect-timeout) shift 2 ;;+ *) shift ;;+ esac+ done+ if [ -n "$output" ]; then+ cp "$WRAPPER_TEST_FIXTURE/${1##*/}" "$output"+ else+ cat "$WRAPPER_TEST_FIXTURE/index.html"+ fi+ MOCK+ chmod +x "$temporary/mock-bin/curl"+ export WRAPPER_TEST_FIXTURE="$temporary"+ printf '<a href="wrapper-1.0.0.tar.gz">release</a><a HREF=\047wrapper-1.0.0.tar.gz\047>duplicate</a>\n' \+ > "$temporary/index.html"+ PATH="$temporary/mock-bin:$PATH" TMPDIR="$temporary/downloads" "$temporary/wrapper/update.sh"+ verify_manifest "$temporary/wrapper"+ [ -z "$(ls -A "$temporary/downloads")" ] || fail "Downloads were not cleaned up"+ printf '<a href="wrapper-2.0.0.tar.gz">another release</a>\n' >> "$temporary/index.html"+ if PATH="$temporary/mock-bin:$PATH" TMPDIR="$temporary/downloads" "$temporary/wrapper/update.sh" \+ > "$temporary/error" 2>&1; then+ fail "Ambiguous download site was accepted"+ fi+ [ -z "$(ls -A "$temporary/downloads")" ] || fail "Failed download was not cleaned up"+ echo "Wrapper updater tests passed"++ # Build a small Maven-shaped package and check that content/mode regressions fail.+ mkdir -p "$temporary/package/onedev-test" "$temporary/product/sandbox"+ package="$temporary/package/onedev-test"+ cp -R "$distribution/." "$package/"+ cp -R "$distribution/agent" "$temporary/agent"+ sed 's/agentVersion/1.0.0/g' "$distribution/agent/conf/wrapper.conf" > "$temporary/agent/conf/wrapper.conf"+ mkdir "$package/lib"+ printf 'version=1.0.0\n' > "$temporary/product/sandbox/release.properties"+ (cd "$temporary/product" && zip -qr "$package/lib/io.onedev.server-product-1.0.0.jar" sandbox)+ pack_server() {+ rm -f "$temporary/server.zip"+ (cd "$temporary/package" && zip -qr "$temporary/server.zip" onedev-test)+ }+ check_server() {+ "$BASH" "$SCRIPT" check-package "$temporary/server.zip" "$destination"+ }+ expect_bad_package() {+ if check_server > "$temporary/error" 2>&1; then fail "Invalid package was accepted"; fi+ }+ pack_server+ check_server+ printf 'corrupt\n' >> "$package/boot/wrapper.jar"+ pack_server+ expect_bad_package+ cp "$distribution/boot/wrapper.jar" "$package/boot/wrapper.jar"+ chmod 644 "$package/bin/server.sh"+ pack_server+ expect_bad_package+ chmod 755 "$package/bin/server.sh"+ touch "$package/boot/libwrapper-obsolete.so"+ pack_server+ expect_bad_package+ rm "$package/boot/libwrapper-obsolete.so"+ pack_server+ chmod 644 "$temporary/agent/boot/wrapper-linux-x86-64"+ expect_bad_package+ chmod 755 "$temporary/agent/boot/wrapper-linux-x86-64"+ mkdir -p "$temporary/product/sandbox/lib"+ touch "$temporary/product/sandbox/lib/old.jar"+ (cd "$temporary/product" && zip -qr "$package/lib/io.onedev.server-product-1.0.0.jar" sandbox)+ pack_server+ expect_bad_package+ echo "Wrapper package checker tests passed"+)++command=${1:-update}+[ "$#" -eq 0 ] || shift+case "$command" in+ update) update_wrapper "$@" ;;+ import) import_release "$@" ;;+ check-package) check_package "$@" ;;+ test)+ [ "$#" -eq 0 ] || fail "Usage: $0 test"+ test_wrapper+ ;;+ help|-h|--help) usage ;;+ *) update_wrapper "$command" "$@" ;;+esacdiff --git a/server-product/wrapper/wrapper.conf b/server-product/wrapper/wrapper.confnew file mode 100644index 0000000000..24e458c1cb--- /dev/null+++ b/server-product/wrapper/wrapper.conf@@ -0,0 +1,66 @@+#encoding=UTF-8+# OneDev service wrapper configuration. Paths are relative to the boot directory.+# Existing JSW property names are retained. Restart the service after editing JVM+# settings. Remove/install the service after changing service registration settings.+# Optional extra configuration: #include ../conf/extra.conf+# Required extra configuration: #include.required ../conf/extra.conf++# Java 17 or higher. Quote paths containing spaces.+wrapper.java.command=java+wrapper.java.version.min=17+wrapper.java.mainclass=io.onedev.wrapper.WrapperSimpleApp+wrapper.java.classpath.1=*.jar+@classpath2@+wrapper.java.library.path.1=.+wrapper.java.library.path.append_system_path=TRUE++# Numbered properties may have gaps. Each additional property is one JVM argument.+wrapper.java.additional.1=-Djava.awt.headless=true+wrapper.java.additional.2=-Djdk.io.File.allowDeleteReadOnlyFiles=true+wrapper.java.additional.10=--add-opens=java.base/sun.nio.ch=ALL-UNNAMED+wrapper.java.additional.11=--add-opens=java.base/java.lang=ALL-UNNAMED+wrapper.java.additional.12=--add-opens=java.base/java.lang.reflect=ALL-UNNAMED+wrapper.java.additional.13=--add-opens=java.base/java.lang.invoke=ALL-UNNAMED+wrapper.java.additional.14=--add-opens=java.base/java.util=ALL-UNNAMED+wrapper.java.additional.15=--add-opens=java.base/java.text=ALL-UNNAMED+wrapper.java.additional.16=--add-opens=java.desktop/java.awt.font=ALL-UNNAMED+wrapper.java.additional.30=--add-modules=java.se+wrapper.java.additional.31=--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED+wrapper.java.additional.32=--add-opens=java.management/sun.management=ALL-UNNAMED+wrapper.java.additional.33=--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED+wrapper.java.additional.50=--add-opens=java.base/sun.nio.fs=ALL-UNNAMED+wrapper.java.additional.100=-XX:MaxRAMPercentage=%max_memory_percent%+wrapper.java.additional.101=-Xss%thread_stack_size%+set.default.max_memory_percent=50+set.default.thread_stack_size=1024k+# Alternatively set wrapper.java.initmemory and wrapper.java.maxmemory in MB.+++# JVM stdout/stderr go to console and this rotating log. NONE disables a destination.+wrapper.console.loglevel=INFO+wrapper.logfile=../logs/console.log+wrapper.logfile.loglevel=INFO+wrapper.logfile.maxsize=250k+wrapper.logfile.maxfiles=3+++# Optional Unix service account (also accepts RUN_AS_USER in bin/*.shconf).+#wrapper.daemon.user=onedev++# Windows service registration. Empty account uses LocalSystem.+wrapper.ntservice.dependency.1=+wrapper.ntservice.starttype=AUTO_START+wrapper.ntservice.account=+wrapper.ntservice.password=++# Zero allows unlimited startup/shutdown time. Java shutdown hooks run on stop.+wrapper.startup.timeout=0+wrapper.shutdown.timeout=0+# Consecutive unexpected JVM failures are bounded to prevent a restart loop.+wrapper.restart.delay=5+wrapper.max_failed_invocations=5+wrapper.successful_invocation_time=300