ARTEMIS-420 user switch when broker is service
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/7864577f Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/7864577f Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/7864577f Branch: refs/heads/master Commit: 7864577fbc723ff318faa3f7ec5fc211f5f1cad1 Parents: edc5141 Author: jbertram <[email protected]> Authored: Wed Apr 13 17:28:01 2016 -0500 Committer: Clebert Suconic <[email protected]> Committed: Wed Apr 13 21:29:59 2016 -0400 ---------------------------------------------------------------------- .../activemq/artemis/cli/commands/bin/artemis-service | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/7864577f/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis-service ---------------------------------------------------------------------- diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis-service b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis-service index 7a53901..ebc60c3 100755 --- a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis-service +++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis-service @@ -6,9 +6,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -95,7 +95,11 @@ start() { return 1 fi - nohup ${ARTEMIS_INSTANCE}/bin/artemis run > /dev/null 2> /dev/null & + if [ -z "$ARTEMIS_USER" -o `id -un` = "$ARTEMIS_USER" ] ; then + nohup ${ARTEMIS_INSTANCE}/bin/artemis run > /dev/null 2> /dev/null & + else + sudo -n -u ${ARTEMIS_USER} nohup ${ARTEMIS_INSTANCE}/bin/artemis run > /dev/null 2> /dev/null & + fi echo $! > "${PID_FILE}"
