The Unified and Autonomous Development Platform
Fix issue #463 - Upgrade JSW to make running as service on systems with SELinux simpler
Robin Shen80d987e816c3
diff --git a/pom.xml b/pom.xmlindex 6b0b85a0c3..dab4848d30 100644--- a/pom.xml+++ b/pom.xml@@ -9,7 +9,7 @@<version>1.0.5</version></parent><artifactId>server</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version><packaging>pom</packaging><build><finalName>${project.groupId}.${project.artifactId}-${project.version}</finalName>@@ -52,7 +52,7 @@<plugin><groupId>io.onedev</groupId><artifactId>plugin-maven</artifactId>- <version>2.0.7</version>+ <version>2.0.8</version><executions><execution><?m2e execute onConfiguration,onIncremental?>@@ -563,8 +563,8 @@</repository></repositories><properties>- <commons.version>2.0.18</commons.version>- <agent.version>1.1.6</agent.version>+ <commons.version>2.0.19</commons.version>+ <agent.version>1.1.7</agent.version><slf4j.version>1.7.30</slf4j.version><logback.version>1.2.0</logback.version><antlr.version>4.7.2</antlr.version>diff --git a/server-core/pom.xml b/server-core/pom.xmlindex 1507349298..62207667b0 100644--- a/server-core/pom.xml+++ b/server-core/pom.xml@@ -7,7 +7,7 @@<parent><groupId>io.onedev</groupId><artifactId>server</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><build><plugins>diff --git a/server-plugin/pom.xml b/server-plugin/pom.xmlindex 69246ac117..5f747af591 100644--- a/server-plugin/pom.xml+++ b/server-plugin/pom.xml@@ -6,7 +6,7 @@<parent><groupId>io.onedev</groupId><artifactId>server</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><dependencies><dependency>diff --git a/server-plugin/server-plugin-archetype/pom.xml b/server-plugin/server-plugin-archetype/pom.xmlindex 938464b333..6f67df4591 100644--- a/server-plugin/server-plugin-archetype/pom.xml+++ b/server-plugin/server-plugin-archetype/pom.xml@@ -6,7 +6,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><build><resources>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 53dccc091f..b6260c7ed2 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@@ -114,7 +114,7 @@<plugin><groupId>io.onedev</groupId><artifactId>plugin-maven</artifactId>- <version>2.0.7</version>+ <version>2.0.8</version><executions><execution><id>populate-resources</id>diff --git a/server-plugin/server-plugin-authenticator-ldap/pom.xml b/server-plugin/server-plugin-authenticator-ldap/pom.xmlindex f0f4959b70..0b52ab1790 100644--- a/server-plugin/server-plugin-authenticator-ldap/pom.xml+++ b/server-plugin/server-plugin-authenticator-ldap/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><properties><moduleClass>io.onedev.server.plugin.authenticator.ldap.LdapModule</moduleClass>diff --git a/server-plugin/server-plugin-buildspec-gradle/pom.xml b/server-plugin/server-plugin-buildspec-gradle/pom.xmlindex 103e0b842d..89c4a02dab 100644--- a/server-plugin/server-plugin-buildspec-gradle/pom.xml+++ b/server-plugin/server-plugin-buildspec-gradle/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><properties><moduleClass>io.onedev.server.plugin.buildspec.gradle.GradleModule</moduleClass>diff --git a/server-plugin/server-plugin-buildspec-maven/pom.xml b/server-plugin/server-plugin-buildspec-maven/pom.xmlindex 6c157bb8b3..832a098eed 100644--- a/server-plugin/server-plugin-buildspec-maven/pom.xml+++ b/server-plugin/server-plugin-buildspec-maven/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><properties><moduleClass>io.onedev.server.plugin.buildspec.maven.MavenModule</moduleClass>diff --git a/server-plugin/server-plugin-buildspec-node/pom.xml b/server-plugin/server-plugin-buildspec-node/pom.xmlindex 71d069637b..33c35ae05d 100644--- a/server-plugin/server-plugin-buildspec-node/pom.xml+++ b/server-plugin/server-plugin-buildspec-node/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><properties><moduleClass>io.onedev.server.plugin.buildspec.node.NodePluginModule</moduleClass>diff --git a/server-plugin/server-plugin-executor-kubernetes/pom.xml b/server-plugin/server-plugin-executor-kubernetes/pom.xmlindex 960f7c30b4..6a4263b526 100644--- a/server-plugin/server-plugin-executor-kubernetes/pom.xml+++ b/server-plugin/server-plugin-executor-kubernetes/pom.xml@@ -6,7 +6,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><properties><moduleClass>io.onedev.server.plugin.executor.kubernetes.KubernetesModule</moduleClass>diff --git a/server-plugin/server-plugin-executor-remotedocker/pom.xml b/server-plugin/server-plugin-executor-remotedocker/pom.xmlindex 85b00d7ce1..9cc985037d 100644--- a/server-plugin/server-plugin-executor-remotedocker/pom.xml+++ b/server-plugin/server-plugin-executor-remotedocker/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><dependencies><dependency>diff --git a/server-plugin/server-plugin-executor-remoteshell/pom.xml b/server-plugin/server-plugin-executor-remoteshell/pom.xmlindex 498f7afc1d..02a5b17132 100644--- a/server-plugin/server-plugin-executor-remoteshell/pom.xml+++ b/server-plugin/server-plugin-executor-remoteshell/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><dependencies><dependency>diff --git a/server-plugin/server-plugin-executor-serverdocker/pom.xml b/server-plugin/server-plugin-executor-serverdocker/pom.xmlindex eeb689cd18..19eb7ecb04 100644--- a/server-plugin/server-plugin-executor-serverdocker/pom.xml+++ b/server-plugin/server-plugin-executor-serverdocker/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><properties><moduleClass>io.onedev.server.plugin.executor.serverdocker.ServerDockerModule</moduleClass>diff --git a/server-plugin/server-plugin-executor-servershell/pom.xml b/server-plugin/server-plugin-executor-servershell/pom.xmlindex 53b7df6c3b..414961d0d7 100644--- a/server-plugin/server-plugin-executor-servershell/pom.xml+++ b/server-plugin/server-plugin-executor-servershell/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><properties><moduleClass>io.onedev.server.plugin.executor.servershell.ServerShellModule</moduleClass>diff --git a/server-plugin/server-plugin-import-bitbucketcloud/pom.xml b/server-plugin/server-plugin-import-bitbucketcloud/pom.xmlindex 8c393a3971..6067d13b5e 100644--- a/server-plugin/server-plugin-import-bitbucketcloud/pom.xml+++ b/server-plugin/server-plugin-import-bitbucketcloud/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><properties><moduleClass>io.onedev.server.plugin.imports.bitbucketcloud.BitbucketPluginModule</moduleClass>diff --git a/server-plugin/server-plugin-import-gitea/pom.xml b/server-plugin/server-plugin-import-gitea/pom.xmlindex 03ef6d241e..08186f856b 100644--- a/server-plugin/server-plugin-import-gitea/pom.xml+++ b/server-plugin/server-plugin-import-gitea/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><properties><moduleClass>io.onedev.server.plugin.imports.gitea.GiteaPluginModule</moduleClass>diff --git a/server-plugin/server-plugin-import-github/pom.xml b/server-plugin/server-plugin-import-github/pom.xmlindex cf2f5ae676..d2ef9f5947 100644--- a/server-plugin/server-plugin-import-github/pom.xml+++ b/server-plugin/server-plugin-import-github/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><properties><moduleClass>io.onedev.server.plugin.imports.github.GitHubPluginModule</moduleClass>diff --git a/server-plugin/server-plugin-import-gitlab/pom.xml b/server-plugin/server-plugin-import-gitlab/pom.xmlindex f183c187ed..1307008a76 100644--- a/server-plugin/server-plugin-import-gitlab/pom.xml+++ b/server-plugin/server-plugin-import-gitlab/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><properties><moduleClass>io.onedev.server.plugin.imports.gitlab.GitLabPluginModule</moduleClass>diff --git a/server-plugin/server-plugin-import-jiracloud/pom.xml b/server-plugin/server-plugin-import-jiracloud/pom.xmlindex 7ee0c4dcb8..0abb15f0cf 100644--- a/server-plugin/server-plugin-import-jiracloud/pom.xml+++ b/server-plugin/server-plugin-import-jiracloud/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><properties><moduleClass>io.onedev.server.plugin.imports.jiracloud.JiraPluginModule</moduleClass>diff --git a/server-plugin/server-plugin-import-youtrack/pom.xml b/server-plugin/server-plugin-import-youtrack/pom.xmlindex eeab9baae5..8252d3b394 100644--- a/server-plugin/server-plugin-import-youtrack/pom.xml+++ b/server-plugin/server-plugin-import-youtrack/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><properties><moduleClass>io.onedev.server.plugin.imports.youtrack.YouTrackPluginModule</moduleClass>diff --git a/server-plugin/server-plugin-report-checkstyle/pom.xml b/server-plugin/server-plugin-report-checkstyle/pom.xmlindex 17b34090eb..54fe808356 100644--- a/server-plugin/server-plugin-report-checkstyle/pom.xml+++ b/server-plugin/server-plugin-report-checkstyle/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><dependencies><dependency>diff --git a/server-plugin/server-plugin-report-clover/pom.xml b/server-plugin/server-plugin-report-clover/pom.xmlindex 859e54a2f3..c542168515 100644--- a/server-plugin/server-plugin-report-clover/pom.xml+++ b/server-plugin/server-plugin-report-clover/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><dependencies><dependency>diff --git a/server-plugin/server-plugin-report-coverage/pom.xml b/server-plugin/server-plugin-report-coverage/pom.xmlindex 7d31d1a070..9e4d100915 100644--- a/server-plugin/server-plugin-report-coverage/pom.xml+++ b/server-plugin/server-plugin-report-coverage/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><properties><moduleClass>io.onedev.server.plugin.report.coverage.CoverageReportModule</moduleClass>diff --git a/server-plugin/server-plugin-report-cpd/pom.xml b/server-plugin/server-plugin-report-cpd/pom.xmlindex 0a4c6aabea..43dd922bf5 100644--- a/server-plugin/server-plugin-report-cpd/pom.xml+++ b/server-plugin/server-plugin-report-cpd/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><dependencies><dependency>diff --git a/server-plugin/server-plugin-report-jacoco/pom.xml b/server-plugin/server-plugin-report-jacoco/pom.xmlindex c48751a973..be217f3e72 100644--- a/server-plugin/server-plugin-report-jacoco/pom.xml+++ b/server-plugin/server-plugin-report-jacoco/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><dependencies><dependency>diff --git a/server-plugin/server-plugin-report-jest/pom.xml b/server-plugin/server-plugin-report-jest/pom.xmlindex a2e6ff5988..c1c727a192 100644--- a/server-plugin/server-plugin-report-jest/pom.xml+++ b/server-plugin/server-plugin-report-jest/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><dependencies><dependency>diff --git a/server-plugin/server-plugin-report-junit/pom.xml b/server-plugin/server-plugin-report-junit/pom.xmlindex ab5a8c9c6d..15e2bfbec5 100644--- a/server-plugin/server-plugin-report-junit/pom.xml+++ b/server-plugin/server-plugin-report-junit/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><dependencies><dependency>diff --git a/server-plugin/server-plugin-report-markdown/pom.xml b/server-plugin/server-plugin-report-markdown/pom.xmlindex 515e4b2016..e0e90eafce 100644--- a/server-plugin/server-plugin-report-markdown/pom.xml+++ b/server-plugin/server-plugin-report-markdown/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><properties><moduleClass>io.onedev.server.plugin.report.markdown.MarkdownReportModule</moduleClass>diff --git a/server-plugin/server-plugin-report-pmd/pom.xml b/server-plugin/server-plugin-report-pmd/pom.xmlindex eefaf54b29..e23e10487a 100644--- a/server-plugin/server-plugin-report-pmd/pom.xml+++ b/server-plugin/server-plugin-report-pmd/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><dependencies><dependency>diff --git a/server-plugin/server-plugin-report-problem/pom.xml b/server-plugin/server-plugin-report-problem/pom.xmlindex 563985e6fc..28dfdcd6a8 100644--- a/server-plugin/server-plugin-report-problem/pom.xml+++ b/server-plugin/server-plugin-report-problem/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><properties><moduleClass>io.onedev.server.plugin.report.problem.ProblemReportModule</moduleClass>diff --git a/server-plugin/server-plugin-report-spotbugs/pom.xml b/server-plugin/server-plugin-report-spotbugs/pom.xmlindex 89d4164766..cf448f32e0 100644--- a/server-plugin/server-plugin-report-spotbugs/pom.xml+++ b/server-plugin/server-plugin-report-spotbugs/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><dependencies><dependency>diff --git a/server-plugin/server-plugin-report-unittest/pom.xml b/server-plugin/server-plugin-report-unittest/pom.xmlindex 498d88ff6f..4635300523 100644--- a/server-plugin/server-plugin-report-unittest/pom.xml+++ b/server-plugin/server-plugin-report-unittest/pom.xml@@ -5,7 +5,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><properties><moduleClass>io.onedev.server.plugin.report.unittest.UnitTestReportModule</moduleClass>diff --git a/server-plugin/server-plugin-sso-openid/pom.xml b/server-plugin/server-plugin-sso-openid/pom.xmlindex 83859612d3..8b6b9bf84b 100644--- a/server-plugin/server-plugin-sso-openid/pom.xml+++ b/server-plugin/server-plugin-sso-openid/pom.xml@@ -6,7 +6,7 @@<parent><groupId>io.onedev</groupId><artifactId>server-plugin</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><dependencies><dependency>diff --git a/server-product/jsw/App.sh.in b/server-product/jsw/App.sh.inindex cb861c16d0..a17b989d47 100644--- a/server-product/jsw/App.sh.in+++ b/server-product/jsw/App.sh.in@@ -1,7 +1,7 @@#! /bin/sh#-# Copyright (c) 1999, 2020 Tanuki Software, Ltd.+# Copyright (c) 1999, 2021 Tanuki Software, Ltd.# http://www.tanukisoftware.com# All rights reserved.#@@ -12,7 +12,7 @@## Java Service Wrapper sh script. Suitable for starting and stopping# wrapped Java applications on UNIX platforms.-# Optimized for use with version 3.5.44-st of the Wrapper.+# Optimized for use with version 3.5.47-st of the Wrapper.##-----------------------------------------------------------------------------@@ -130,28 +130,26 @@ WAIT_FOR_STARTED_TIMEOUT=120# be overriden.#PAUSABLE_MODE=signals-# If specified, the Wrapper will be run as the specified user.+# 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.-# NOTE - This will set the user which is used to run the Wrapper as well as+# 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=-# Set the full path to the 'su' command (substitute user).-# NOTE - In case 'su' is not in the PATH, you can set the absolute path here,-# for example:-# SU_BIN=/bin/su-# NOTE - For Red Hat, the script will use '/sbin/runuser' if it is present and-# ignore the value of SU_BIN.-SU_BIN=su--# Set option(s) for 'su' or 'runuser'.-# In case the user set in RUN_AS_USER has no bash set, the 'su' command will fail.-# The workaround for GNU/Linux system is to specify which bash to use with-# the '-s' option.+# 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.@@ -210,6 +208,13 @@ 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 | sed 's/^uid=//;s/(.*$//'` != "0" ] ; thenIS_ROOT=false@@ -218,11 +223,54 @@ checkIsRoot() {fi}-gettext() {- "$WRAPPER_CMD" --translate "$1" "$WRAPPER_CONF" 2>/dev/null- if [ $? != 0 ] ; then- echo "$1"+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}##@@ -277,7 +325,7 @@ resolveLocation() {resolveIdLocation() {# On Solaris, the version in /usr/xpg4/bin should be used in priority.- resolveLocation ID_BIN id "/usr/xpg4/bin/id;;/usr/bin/id" 1+ resolveLocation ID_BIN id "/usr/xpg4/bin;;/usr/bin" 1}resolveCurrentUser() {@@ -287,6 +335,391 @@ resolveCurrentUser() {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@@ -298,6 +731,37 @@ thenexit 1fi+# 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@@ -306,11 +770,6 @@ if [ $# -gt 1 ] ; thenfifi-# Required for HP-UX Startup-if [ `uname -s` = "HP-UX" -o `uname -s` = "HP-UX64" ] ; then- PATH=$PATH:/usr/bin-fi-# Get the fully qualified path to the scriptcase $0 in/*)@@ -333,7 +792,7 @@ CHANGED=truewhile [ "X$CHANGED" != "X" ]do# Change spaces to ":" so the tokens can be parsed.- SAFESCRIPT=`echo $SCRIPT | sed -e 's; ;:;g'`+ SAFESCRIPT=`echo "$SCRIPT" | sed -e 's; ;:;g'`# Get the real path to this script, resolving any symbolic linksTOKENS=`echo $SAFESCRIPT | sed -e 's;/; ;g'`REALPATH=@@ -363,6 +822,8 @@ dofidone+normalizeFilePath REALPATH $REALPATH+# Try to source a file with the same filename as the script and with the '.shconf' extension.case $REALPATH in*.sh)@@ -401,63 +862,59 @@ fi# Get the location of the script.REALDIR=`dirname "$REALPATH"`-if [ "X$RUN_AS_USER" != "X" ] ; then- CHECK_FOLDER_PERMISSIONS=0- if [ "$COMMAND" = "console" -o "$COMMAND" = "start" -o "$COMMAND" = "restart" -o "$COMMAND" = "condrestart" -o "$COMMAND" = "install" -o "$COMMAND" = "installstart" ] ; then- checkIsRoot- if [ "$IS_ROOT" = "true" ] ; then- if [ -f "/sbin/runuser" -a $COMMAND != "console" ] ; then- result=`/sbin/runuser - $RUN_AS_USER -c "cd \"${REALDIR}\"" $SU_OPTS 2>/dev/null`+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+ validateRunUserelse- result=`$SU_BIN - $RUN_AS_USER -c "cd \"${REALDIR}\"" $SU_OPTS 2>/dev/null`+ mustBeRootOrExitfi- CHECK_FOLDER_PERMISSIONS=$?- fi- fi-else- # Technically REALDIR should not be required for all commands, but in fact the script will fail below if the Wrapper binaries can't be accessed.- # It is thus better to show a message and print folder permissions now.+ ;;+ '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`- CHECK_FOLDER_PERMISSIONS=$?-fi-if [ $CHECK_FOLDER_PERMISSIONS -ne 0 ] ; then- if [ "X$RUN_AS_USER" != "X" ] ; then- CHECK_USER=$RUN_AS_USER- else+ 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- CHECK_USER=$CURRENT_USER+ reportRealDirNotAccessible $CURRENT_USER+ exit 1fi- # 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 \"$CHECK_USER\" from traversing one of the folders. Please check the following permissions:'`-- OIFS=$IFS- IFS='/'- for DIR in $REALDIR- do- INT_PATH="${INT_PATH}/$DIR"- if [ "$DIR" != "." -a "$DIR" != ".." ] ; then- 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- exit 1fi-# Normalize the path-REALDIR=`cd "${REALDIR}"; pwd`-# 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" != "/" ]thenPIDDIR=$REALDIR/$PIDDIR+ normalizeDirPath PIDDIR $PIDDIRfi# Same test for WRAPPER_CMDFIRST_CHAR=`echo $WRAPPER_CMD | cut -c1,1`@@ -481,17 +938,6 @@ if [ "X$APP_LONG_NAME" = "X" -o "$APP_LONG_NAME" = "${DELIMITER}app.long.name${DAPP_LONG_NAME=$APP_NAMEfi-# 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)-# Process IDANCHORFILE="$PIDDIR/$APP_NAME.anchor"COMMANDFILE="$PIDDIR/$APP_NAME.command"@@ -502,36 +948,6 @@ LOCKDIR="/var/lock/subsys"LOCKFILE="$LOCKDIR/$APP_NAME"pid=""-# 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-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- ;;- 'darwin')- DIST_OS="macosx"- ;;- 'unix_sv')- DIST_OS="unixware"- ;;- 'os/390')- DIST_OS="zos"- ;;- 'linux')- DIST_OS="linux"- ;;-esac-# Compare Versions $1<$2=0, $1==$2=1, $1>$2=2compareVersions () {if [ "$1" = "$2" ]@@ -570,7 +986,13 @@ compareVersions () {if [ "$DIST_OS" = "macosx" ]thenOS_VER=`sw_vers | grep 'ProductVersion:' | grep -o '[0-9]*\.[0-9]*\.[0-9]*\|[0-9]*\.[0-9]*'`- DIST_ARCH="universal"+ 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"+ ficompareVersions "$OS_VER" "10.5.0"if [ $? -lt 1 ]then@@ -686,15 +1108,14 @@ else;;aarch64* | arm64*)# 'aarch64_be', 'aarch64', 'arm64', etc.- # => only armhf is 64-bit- DIST_ARCH="armhf"+ 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="armhf"+ DIST_ARCH="arm"DIST_BITS="64"else# Note: The following command returns nothing on SUSE for Raspberry Pi 3 (aarch64).@@ -924,11 +1345,11 @@ prepAdditionalParams() {*=*)# 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."`+ 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>'."`+ 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\>\".'`;;esacfi@@ -988,37 +1409,17 @@ resolveSysLocale() {fi}-resolveSuLocale() {- if [ "X$PASS_SU_LANG" = "X" -a "X$RUN_AS_USER" != "X" ] ; then- PASS_SU_LANG=`$SU_BIN - $RUN_AS_USER -c "locale" $SU_OPTS | grep "LANG=" 2>/dev/null`- if [ "X$PASS_SU_LANG" != "X" ] ; then- PASS_SU_LANG="$PASS_SU_LANG "- fi- fi-}-checkUser() {+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- resolveCurrentUser- if [ "$CURRENT_USER" = "$RUN_AS_USER" ]- then- # Already running as the configured user. Avoid password prompts by not calling su.- RUN_AS_USER=""- fi- fi- if [ "X$RUN_AS_USER" != "X" ]- then- 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-# 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@@ -1054,39 +1455,40 @@ checkUser() {shiftdone- # runuser doesn't transmit signals (such as ctrl+c) to the Wrapper. This causes problem when running as a console.- # When the Wrapper is launched as a service on RedHat, runuser should be used in preference to su.resolveSysLocale- if [ -f "/sbin/runuser" -a $COMMAND != "console" ] ; then- # Unlike su, runuser doesn't use the default system locale. Force passing it for consistency.- if [ "X$PASS_SYS_LANG" = "X" ] ; then- # Fallback to the same locale as when using SU (which should be the system encoding).- resolveSuLocale- PASS_SYS_LANG=$PASS_SU_LANG- fi- /sbin/runuser - $RUN_AS_USER -c "$PASS_SYS_LANG\"$REALPATH\" $ADDITIONAL_PARA" $SU_OPTS- else- # Normally SU should use the default system locale, but make sure it is the case.- resolveSuLocale- if [ "X$PASS_SU_LANG" != "X" -a "$PASS_SU_LANG" != "$PASS_SYS_LANG" ] ; then- PASS_SU_LANG=$PASS_SYS_LANG- else- PASS_SU_LANG=""- fi- $SU_BIN - $RUN_AS_USER -c "$PASS_SU_LANG\"$REALPATH\" $ADDITIONAL_PARA" $SU_OPTS- fi+ RUNUSER_INTERRUPT_TRAPPED=false+ $RUNUSER_BIN - $RUN_AS_USER -c "IS_SUBSTITUTE_USER=true $PASS_SYS_LANG\"$REALPATH\" $ADDITIONAL_PARA" $SU_OPTSRUN_AS_USER_EXITCODE=$?- # we check if the previous command has failed- if [ $RUN_AS_USER_EXITCODE -ne 0 ]- then- if [ $RUN_AS_USER_EXITCODE -eq 1 ]- then- checkForkCommand- else- eval echo `gettext 'Error executing the requested command with user \"$RUN_AS_USER\" \(error code $RUN_AS_USER_EXITCODE\).'`- echo ""+ 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...'`+ fifi+ 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.+ checkForkCommandfi# Now that we are the original user again, we may need to clean up the lock file.@@ -1110,12 +1512,7 @@ checkUser() {# Try to fork by executing a simple command.# With this function, we want to make sure we are able to fork.checkForkCommand() {-- if [ -f "/sbin/runuser" -a $COMMAND != "console" ] ; then- /sbin/runuser - $RUN_AS_USER -c "ls \"$REALPATH\"" $SU_OPTS > /dev/null 2>&1 &- else- $SU_BIN - $RUN_AS_USER -c "ls \"$REALPATH\"" $SU_OPTS > /dev/null 2>&1 &- fi+ $RUNUSER_BIN - $RUN_AS_USER -c "ls \"$REALPATH\"" $SU_OPTS > /dev/null 2>&1 &CHECK_EXITCODE=$?if [ $CHECK_EXITCODE -ne 0 ]@@ -1126,7 +1523,7 @@ checkForkCommand() {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).'`+ eval echo `gettext '2. Use a OS service management tool \(only available on some platforms\).'`echo ""fi}@@ -1201,6 +1598,9 @@ getpid() {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`;;@@ -1322,8 +1722,8 @@ launchinternal() {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.44 $ADDITIONAL_PARA"- eval $COMMAND_LINE+ 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.47 $ADDITIONAL_PARA"+ eval "$COMMAND_LINE"elseeval echo `gettext '$APP_LONG_NAME is already running.'`exit 1@@ -1335,18 +1735,70 @@ launchinternal() {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...'`getpidif [ "X$pid" = "X" ]then- trap '' 3-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.44 $ADDITIONAL_PARA"- eval $COMMAND_LINE+ 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.47 $ADDITIONAL_PARA"+ eval "$COMMAND_LINE"COMMAND_EXIT_CODE=$?if [ $COMMAND_EXIT_CODE -ne 0 ] ; thenexit $COMMAND_EXIT_CODE@@ -1383,7 +1835,37 @@ waitforjavastartup() {doneecho ""}-++##+# 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@@ -1404,7 +1886,8 @@ startwait() {getpidif [ "X$pid" = "X" ]then- eval echo `gettext ' WARNING: $APP_LONG_NAME may have failed to start.'`+ eval echo `gettext 'WARNING: $APP_LONG_NAME may have failed to start.'`+ printlogfilepath " "exit 1elseeval echo `gettext ' running: PID:$pid'`@@ -1414,14 +1897,6 @@ startwait() {fi}-mustBeRootOrExit() {- checkIsRoot- if [ "$IS_ROOT" != "true" ] ; then- eval echo `gettext 'Must be root to perform this action.'`- exit 1- fi-}-mustBeStoppedOrExit() {getpidif [ "X$pid" != "X" ] ; then@@ -1501,42 +1976,6 @@ macosxRestart() {startwait}-# 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-}-upstartInstall() {# Always verify that upstart exists.upstartDetection@@ -1602,21 +2041,9 @@ upstartRestart() {}upstartRemove() {- stopit "0"- eval echo `gettext ' Removing the $APP_LONG_NAME daemon from upstart...'`- rm "/etc/init/${APP_NAME}.conf"-}--# 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 $?+ stopit "0"+ eval echo `gettext ' Removing the $APP_LONG_NAME daemon from upstart...'`+ rm "/etc/init/${APP_NAME}.conf"}systemdInstall() {@@ -1641,9 +2068,13 @@ systemdInstall() {echo "Type=forking" >> "${SYSTEMD_SERVICE_FILE}"case "${REALPATH}" in*\ *)- # REALPATH contains space- echo 'ExecStart=/usr/bin/env "'${REALPATH}'" start sysd' >> "${SYSTEMD_SERVICE_FILE}"- echo 'ExecStop=/usr/bin/env "'${REALPATH}'" stop sysd' >> "${SYSTEMD_SERVICE_FILE}"+ # 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}"@@ -1674,7 +2105,7 @@ systemdStart() {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 '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 1fi@@ -1684,6 +2115,7 @@ systemdStart() {systemctl start $APP_NAMEif [ $? -ne 0 ] ; theneval echo `gettext 'Failed to start $APP_LONG_NAME.'`+ printlogfilepathexit 1fi@@ -1713,6 +2145,7 @@ systemdRestart() {systemctl restart $APP_NAMEif [ $? -ne 0 ] ; theneval echo `gettext 'Failed to restart service $APP_NAME'`+ printlogfilepathexit 1fi@@ -1727,14 +2160,6 @@ systemdRemove() {systemctl daemon-reload}-# 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 $?-}-srcInstall() {# Always verify that SRC exists.srcDetection@@ -1768,6 +2193,7 @@ srcStart() {startsrc -s "${APP_NAME}"if [ $? -ne 0 ] ; theneval echo `gettext 'Failed to start $APP_LONG_NAME.'`+ printlogfilepathexit 1fi@@ -1809,8 +2235,8 @@ start() {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.44 $ADDITIONAL_PARA"- eval $COMMAND_LINE+ 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.47 $ADDITIONAL_PARA"+ eval "$COMMAND_LINE"startwait}@@ -1950,78 +2376,31 @@ resume() {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+# 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+ ;;+ esacfi}@@ -2062,15 +2441,6 @@ status() {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-}-resolveInitdCommand() {# NOTE: update-rc.d & chkconfig are the recommended interfaces for managing# init scripts. insserv is a low level tool used by these interfaces.@@ -2123,6 +2493,18 @@ installdaemon() {eval echo `gettext ' The $APP_LONG_NAME daemon is already installed with $installedWith.'`elif [ -n "$USE_SYSTEMD" ] ; thensystemdInstall++ # 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+ fielif [ -n "$USE_UPSTART" ] ; thenupstartInstallelse@@ -2296,26 +2678,27 @@ installdaemon() {}startdaemon() {- if [ "$DIST_OS" = "macosx" -a -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then+ getServiceControlMethod+ if [ "$CTRL_WITH_LAUNCHD" = "true" ] ; thenmacosxStart- elif [ "$DIST_OS" = "linux" -a -n "$USE_UPSTART" ] && [ -f "/etc/init/${APP_NAME}.conf" ] ; then+ elif [ "$CTRL_WITH_UPSTART" = "true" ] ; thenupstartStart- elif [ "$DIST_OS" = "linux" -a -n "$USE_SYSTEMD" -a -z "$SYSD" ] && [ -f "${SYSTEMD_SERVICE_FILE}" ] ; then+ elif [ "$CTRL_WITH_SYSTEMD" = "true" ] ; thensystemdStart- elif [ "$DIST_OS" = "aix" -a -n "$USE_SRC" ] && [ -n "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then+ elif [ "$CTRL_WITH_SRC" = "true" ] ; thensrcStartelseif [ -n "$SYSD" ] ; thenshiftfi- checkUser touchlock "$@"+ checkRunUser touchlock "$@"if [ ! -n "$FIXED_COMMAND" ] ; thenshiftfiif [ "$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."`+ eval echo `gettext 'Starting without using the configured service management tool \"$SERVICE_MANAGEMENT_TOOL\" because the service $APP_NAME is not installed.'`fistart "$@"@@ -2323,16 +2706,17 @@ startdaemon() {}restartdaemon() {- if [ "$DIST_OS" = "macosx" -a -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then+ getServiceControlMethod+ if [ "$CTRL_WITH_LAUNCHD" = "true" ] ; thenmacosxRestart $1- elif [ "$DIST_OS" = "linux" -a -n "$USE_UPSTART" ] && [ -f "/etc/init/${APP_NAME}.conf" ] ; then+ elif [ "$CTRL_WITH_UPSTART" = "true" ] ; thenupstartRestart $1- elif [ "$DIST_OS" = "linux" -a -n "$USE_SYSTEMD" -a -z "$SYSD" ] && [ -f "${SYSTEMD_SERVICE_FILE}" ] ; then+ elif [ "$CTRL_WITH_SYSTEMD" = "true" ] ; thensystemdRestart $1- elif [ "$DIST_OS" = "aix" -a -n "$USE_SRC" ] && [ -n "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then+ elif [ "$CTRL_WITH_SRC" = "true" ] ; thensrcRestart $1else- checkUser touchlock "$COMMAND"+ checkRunUser touchlock "$COMMAND"checkRunning $1if [ "X$pid" != "X" ] ; then@@ -2379,6 +2763,18 @@ removedaemon() {isBitSet $installedStatus $SERVICE_INSTALLED_SYSTEMDif [ $? -eq 1 ] ; thensystemdRemove++ # 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+ fifiisBitSet $installedStatus $SERVICE_INSTALLED_UPSTARTif [ $? -eq 1 ] ; then@@ -2561,77 +2957,6 @@ sourceFiles() {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- 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-}-# 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,@@ -2675,83 +3000,14 @@ checkArguments() {fi}-# 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-}--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-}-docommand() {case "$COMMAND" in'console')checkArguments 1- checkUser touchlock "$@"+ # trap signals (this must be done before changing the user)+ consoleTrapSignals+ checkRunUser touchlock "$@"if [ ! -n "$FIXED_COMMAND" ] ; thenshiftfi@@ -2767,16 +3023,17 @@ docommand() {'stop')checkArguments 0setServiceManagementTool- if [ "$DIST_OS" = "macosx" -a -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then+ getServiceControlMethod+ if [ "$CTRL_WITH_LAUNCHD" = "true" ] ; thenmacosxStop- elif [ "$DIST_OS" = "linux" -a -n "$USE_UPSTART" ] && [ -f "/etc/init/${APP_NAME}.conf" ] ; then+ elif [ "$CTRL_WITH_UPSTART" = "true" ] ; thenupstartStop- elif [ "$DIST_OS" = "linux" -a -n "$USE_SYSTEMD" -a -z "$SYSD" ] && [ -f "${SYSTEMD_SERVICE_FILE}" ] ; then+ elif [ "$CTRL_WITH_SYSTEMD" = "true" ] ; thensystemdStop- elif [ "$DIST_OS" = "aix" -a -n "$USE_SRC" ] && [ -n "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then+ elif [ "$CTRL_WITH_SRC" = "true" ] ; thensrcStopelse- checkUser "" "$COMMAND"+ checkRunUser "" "$COMMAND"stopit "0"fi;;@@ -2842,28 +3099,28 @@ docommand() {'dump')checkArguments 0- checkUser "" "$COMMAND"+ checkRunUser "" "$COMMAND"dump;;'start_msg')# Internal command called by launchd on HP-UX.- checkUser "" "$COMMAND"+ checkRunUser "" "$COMMAND"startmsg;;'stop_msg')# Internal command called by launchd on HP-UX.- checkUser "" "$COMMAND"+ checkRunUser "" "$COMMAND"stopmsg;;'launchdinternal' | 'upstartinternal')if [ ! "$DIST_OS" = "macosx" -o ! -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then- checkUser touchlock "$@"+ checkRunUser touchlock "$@"fi# Internal command called by launchd on Max OSX.- # We do not want to call checkUser here as it is handled in the launchd plist file. Doing it here would confuse launchd.+ # 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" ] ; thenshiftfidiff --git a/server-product/jsw/AppCommand.bat.in b/server-product/jsw/AppCommand.bat.inindex a60d7509d1..f8c351a659 100644--- a/server-product/jsw/AppCommand.bat.in+++ b/server-product/jsw/AppCommand.bat.in@@ -1,311 +1,326 @@-@echo off-setlocal--rem-rem Copyright (c) 1999, 2020 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.44-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 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%-pause-goto :eof--: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.- pause- goto :eof-)--: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.- pause- goto :eof- )-)--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-pause-goto :eof--: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.-)-pause+@echo off+setlocal++rem+rem Copyright (c) 1999, 2021 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.47-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.confindex 7ecb70a72a..8847869b72 100644--- a/server-product/jsw/agent-license.conf+++ b/server-product/jsw/agent-license.conf@@ -1,13 +1,13 @@#encoding=UTF-8wrapper.license.type=DEV-wrapper.license.id=202108130000064+wrapper.license.id=202112090000008wrapper.license.licensee=OneDevwrapper.license.group=service wrappingwrapper.license.dev_application=Service Wrappingwrapper.license.features=64bitwrapper.license.upgrade_term.begin_date=2020-11-09wrapper.license.upgrade_term.end_date=2022-04-26-wrapper.license.key.1=8912-a606-266c-63bf-wrapper.license.key.2=3d3a-f0a5-b30c-8463-wrapper.license.key.3=e883-6cc7-2fca-0d77-wrapper.license.key.4=860a-6383-8aa1-2d44\ No newline at end of file+wrapper.license.key.1=2c69-1962-aac9-1994+wrapper.license.key.2=1c57-3351-2b51-6a7d+wrapper.license.key.3=1328-c562-6762-cd3c+wrapper.license.key.4=8037-b40e-6e87-5391\ No newline at end of filediff --git a/server-product/jsw/server-license.conf b/server-product/jsw/server-license.confindex fe6297a353..2a9942ad59 100644--- a/server-product/jsw/server-license.conf+++ b/server-product/jsw/server-license.conf@@ -1,13 +1,13 @@#encoding=UTF-8wrapper.license.type=DEV-wrapper.license.id=202108300000010+wrapper.license.id=202112090000007wrapper.license.licensee=OneDevwrapper.license.group=service wrappingwrapper.license.dev_application=Service Wrappingwrapper.license.features=64bitwrapper.license.upgrade_term.begin_date=2020-11-09wrapper.license.upgrade_term.end_date=2022-04-26-wrapper.license.key.1=b528-07db-e82f-69d9-wrapper.license.key.2=76ab-ca7b-8f3e-b66f-wrapper.license.key.3=7a35-1c28-454a-f91e-wrapper.license.key.4=1753-a1df-4ee0-b711\ No newline at end of file+wrapper.license.key.1=d587-6c74-2f1c-da71+wrapper.license.key.2=a309-ff0a-465e-72f9+wrapper.license.key.3=8c77-45f1-304d-c9c4+wrapper.license.key.4=82c2-5964-8594-d506\ No newline at end of filediff --git a/server-product/jsw/wrapper-delta-pack-3.5.44-st.zip b/server-product/jsw/wrapper-delta-pack-3.5.44-st.zipdeleted file mode 100644index 47182310dc..0000000000Binary files a/server-product/jsw/wrapper-delta-pack-3.5.44-st.zip and /dev/null differdiff --git a/server-product/jsw/wrapper-delta-pack-3.5.47-st.zip b/server-product/jsw/wrapper-delta-pack-3.5.47-st.zipnew file mode 100644index 0000000000..af88e65628Binary files /dev/null and b/server-product/jsw/wrapper-delta-pack-3.5.47-st.zip differdiff --git a/server-product/pom.xml b/server-product/pom.xmlindex f497b97232..2342f888f7 100644--- a/server-product/pom.xml+++ b/server-product/pom.xml@@ -7,7 +7,7 @@<parent><groupId>io.onedev</groupId><artifactId>server</artifactId>- <version>6.0.0</version>+ <version>6.1.0</version></parent><dependencies><dependency>