rabbitmq-server/scripts/rabbitmq-script-wrapper

119 lines
3.1 KiB
Plaintext
Raw Normal View History

#!/bin/sh
## The contents of this file are subject to the Mozilla Public License
## Version 1.1 (the "License"); you may not use this file except in
## compliance with the License. You may obtain a copy of the License
URL Cleanup This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener). # HTTP URLs that Could Not Be Fixed These URLs were unable to be fixed. Please review them to see if they can be manually resolved. * http://blog.listincomprehension.com/search/label/procket (200) with 1 occurrences could not be migrated: ([https](https://blog.listincomprehension.com/search/label/procket) result ClosedChannelException). * http://dozzie.jarowit.net/trac/wiki/TOML (200) with 1 occurrences could not be migrated: ([https](https://dozzie.jarowit.net/trac/wiki/TOML) result SSLHandshakeException). * http://dozzie.jarowit.net/trac/wiki/subproc (200) with 1 occurrences could not be migrated: ([https](https://dozzie.jarowit.net/trac/wiki/subproc) result SSLHandshakeException). * http://e2project.org (200) with 1 occurrences could not be migrated: ([https](https://e2project.org) result AnnotatedConnectException). * http://nitrogenproject.com/ (200) with 2 occurrences could not be migrated: ([https](https://nitrogenproject.com/) result ConnectTimeoutException). * http://proper.softlab.ntua.gr (200) with 1 occurrences could not be migrated: ([https](https://proper.softlab.ntua.gr) result SSLHandshakeException). * http://yaws.hyber.org (200) with 1 occurrences could not be migrated: ([https](https://yaws.hyber.org) result AnnotatedConnectException). * http://httpredir.debian.org/debian (302) with 1 occurrences could not be migrated: ([https](https://httpredir.debian.org/debian) result AnnotatedConnectException). * http://choven.ca (503) with 1 occurrences could not be migrated: ([https](https://choven.ca) result ConnectTimeoutException). # Fixed URLs ## Fixed But Review Recommended These URLs were fixed, but the https status was not OK. However, the https status was the same as the http request or http redirected to an https URL, so they were migrated. Your review is recommended. * http://fixprotocol.org/ (301) with 1 occurrences migrated to: https://fixtrading.org ([https](https://fixprotocol.org/) result SSLHandshakeException). * http://nsis.sourceforge.net/Setting_Environment_Variables (301) with 1 occurrences migrated to: https://nsis.sourceforge.io/Setting_Environment_Variables ([https](https://nsis.sourceforge.net/Setting_Environment_Variables) result AnnotatedConnectException). * http://erldb.org (UnknownHostException) with 1 occurrences migrated to: https://erldb.org ([https](https://erldb.org) result UnknownHostException). * http://www.rabbitmq.com/releases/rabbitmq-server/v (404) with 1 occurrences migrated to: https://www.rabbitmq.com/releases/rabbitmq-server/v ([https](https://www.rabbitmq.com/releases/rabbitmq-server/v) result 404). * http://www.rabbitmq.com/releases/rabbitmq-server/v% (404) with 1 occurrences migrated to: https://www.rabbitmq.com/releases/rabbitmq-server/v% ([https](https://www.rabbitmq.com/releases/rabbitmq-server/v%) result 404). ## Fixed Success These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended. * http://cloudi.org/ with 27 occurrences migrated to: https://cloudi.org/ ([https](https://cloudi.org/) result 200). * http://erlware.org/ with 1 occurrences migrated to: https://erlware.org/ ([https](https://erlware.org/) result 200). * http://inaka.github.io/cowboy-trails/ with 1 occurrences migrated to: https://inaka.github.io/cowboy-trails/ ([https](https://inaka.github.io/cowboy-trails/) result 200). * http://ninenines.eu with 6 occurrences migrated to: https://ninenines.eu ([https](https://ninenines.eu) result 200). * http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html with 1 occurrences migrated to: https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html ([https](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) result 200). * http://www.actordb.com/ with 2 occurrences migrated to: https://www.actordb.com/ ([https](https://www.actordb.com/) result 200). * http://www.cs.kent.ac.uk/projects/wrangler/Home.html with 1 occurrences migrated to: https://www.cs.kent.ac.uk/projects/wrangler/Home.html ([https](https://www.cs.kent.ac.uk/projects/wrangler/Home.html) result 200). * http://www.debian.org/doc/debian-policy/ with 2 occurrences migrated to: https://www.debian.org/doc/debian-policy/ ([https](https://www.debian.org/doc/debian-policy/) result 200). * http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ with 1 occurrences migrated to: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ ([https](https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/) result 200). * http://www.rabbitmq.com/ with 2 occurrences migrated to: https://www.rabbitmq.com/ ([https](https://www.rabbitmq.com/) result 200). * http://www.rabbitmq.com/debian/ with 3 occurrences migrated to: https://www.rabbitmq.com/debian/ ([https](https://www.rabbitmq.com/debian/) result 200). * http://www.rabbitmq.com/monitoring.html with 2 occurrences migrated to: https://www.rabbitmq.com/monitoring.html ([https](https://www.rabbitmq.com/monitoring.html) result 200). * http://www.rebar3.org with 1 occurrences migrated to: https://www.rebar3.org ([https](https://www.rebar3.org) result 200). * http://contributor-covenant.org with 1 occurrences migrated to: https://contributor-covenant.org ([https](https://contributor-covenant.org) result 301). * http://contributor-covenant.org/version/1/3/0/ with 1 occurrences migrated to: https://contributor-covenant.org/version/1/3/0/ ([https](https://contributor-covenant.org/version/1/3/0/) result 301). * http://inaka.github.com/apns4erl with 1 occurrences migrated to: https://inaka.github.com/apns4erl ([https](https://inaka.github.com/apns4erl) result 301). * http://inaka.github.com/edis/ with 1 occurrences migrated to: https://inaka.github.com/edis/ ([https](https://inaka.github.com/edis/) result 301). * http://lasp-lang.org/ with 1 occurrences migrated to: https://lasp-lang.org/ ([https](https://lasp-lang.org/) result 301). * http://saleyn.github.com/erlexec with 1 occurrences migrated to: https://saleyn.github.com/erlexec ([https](https://saleyn.github.com/erlexec) result 301). * http://www.debian-administration.org/articles/286 with 1 occurrences migrated to: https://www.debian-administration.org/articles/286 ([https](https://www.debian-administration.org/articles/286) result 301). * http://www.erlang.org/download.html with 1 occurrences migrated to: https://www.erlang.org/download.html ([https](https://www.erlang.org/download.html) result 301). * http://www.mozilla.org/MPL/ with 5 occurrences migrated to: https://www.mozilla.org/MPL/ ([https](https://www.mozilla.org/MPL/) result 301). * http://zhongwencool.github.io/observer_cli with 1 occurrences migrated to: https://zhongwencool.github.io/observer_cli ([https](https://zhongwencool.github.io/observer_cli) result 301).
2019-03-20 16:22:38 +08:00
## at https://www.mozilla.org/MPL/
##
## Software distributed under the License is distributed on an "AS IS"
## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
## the License for the specific language governing rights and
## limitations under the License.
##
## The Original Code is RabbitMQ.
##
## The Initial Developer of the Original Code is GoPivotal, Inc.
2019-12-29 00:35:38 +08:00
## Copyright (c) 2007-2020 Pivotal Software, Inc. All rights reserved.
##
SCRIPT="$(basename "$0")"
RABBITMQ_LOG_BASE=/var/log/rabbitmq
main() {
ensure_we_are_in_a_readable_dir
2017-08-02 00:17:39 +08:00
if current_user_is_rabbitmq && calling_rabbitmq_server
then
2017-08-02 00:17:39 +08:00
exec_rabbitmq_server "$@"
elif current_user_is_rabbitmq && ! calling_rabbitmq_plugins
then
exec_script_as_rabbitmq "$@"
elif current_user_is_root && calling_rabbitmq_plugins
then
run_script_as_rabbitmq "$@"
maybe_fixup_erlang_cookie
elif current_user_is_root
then
exec_script_as_root "$@"
else
run_script_help_and_fail
fi
}
maybe_fixup_erlang_cookie() {
# rabbitmq/rabbitmq-server-release#85
_rabbitmq_home="$(cd ~rabbitmq && pwd)"
_erlang_cookie="$_rabbitmq_home/.erlang.cookie"
if [ -f "$_erlang_cookie" ]
then
chown @RABBITMQ_USER@:@RABBITMQ_GROUP@ "$_erlang_cookie"
chmod 400 "$_erlang_cookie"
fi
}
ensure_we_are_in_a_readable_dir() {
# shellcheck disable=SC2164
cd ~rabbitmq || cd /
}
current_user_is_rabbitmq() {
[ "$(id -un)" = "rabbitmq" ]
}
current_user_is_root() {
[ "$(id -u)" = 0 ]
}
calling_rabbitmq_server() {
[ "$SCRIPT" = "rabbitmq-server" ]
}
2017-08-02 00:17:39 +08:00
calling_rabbitmq_plugins() {
[ "$SCRIPT" = "rabbitmq-plugins" ]
}
exec_rabbitmq_server() {
exec /usr/lib/rabbitmq/bin/rabbitmq-server "$@" @STDOUT_STDERR_REDIRECTION@
}
run_script_as_rabbitmq() {
HOME="$(cd ~rabbitmq && pwd)" "/usr/lib/rabbitmq/bin/$SCRIPT" "$@"
}
exec_script_as_rabbitmq() {
HOME="$(cd ~rabbitmq && pwd)" exec "/usr/lib/rabbitmq/bin/$SCRIPT" "$@"
}
exec_script_as_root() {
if [ -x /sbin/runuser ]
then
# TODO:
# At some point all of the RabbitMQ supported distributions will be using
# the util-linux version of /sbin/runuser, as it has been removed from GNU
# coreutils as of 2012. At that point the first clause of the following
# if statement can become the only statement used and the if/then
# removed
if /sbin/runuser --version | grep -qF util-linux
then
exec /sbin/runuser -u rabbitmq -- "/usr/lib/rabbitmq/bin/$SCRIPT" "$@"
else
exec /sbin/runuser -s /bin/sh -- rabbitmq "/usr/lib/rabbitmq/bin/$SCRIPT" "$@"
fi
elif [ -x /bin/su ]
then
exec /bin/su -s /bin/sh rabbitmq -- "/usr/lib/rabbitmq/bin/$SCRIPT" "$@"
else
2017-08-17 21:03:04 +08:00
echo "Please ensure /bin/su or /sbin/runuser exists and can be executed by $USER." 1>&2
exit 1
fi
}
run_script_help_and_fail() {
"/usr/lib/rabbitmq/bin/$SCRIPT" help
echo "
Only root or rabbitmq can run $SCRIPT
"
exit 1
}
main "$@"