mirror of
https://github.com/msmhq/msm.git
synced 2024-08-30 18:12:35 +00:00
Added support for "all" server name. Fixes #16.
Using "all" executes a command for all servers.
This commit is contained in:
@ -74,7 +74,7 @@ _msm() {
|
||||
if [ -d "$SERVER_STORAGE_PATH" ]; then
|
||||
local servers="$(ls -1 "$SERVER_STORAGE_PATH")"
|
||||
fi
|
||||
options="help start stop restart version server jargroup $servers"
|
||||
options="help start stop restart version server jargroup all $servers"
|
||||
else
|
||||
case "${COMP_WORDS[1]}" in
|
||||
stop|restart)
|
||||
@ -112,7 +112,7 @@ _msm() {
|
||||
# Server options
|
||||
|
||||
local server_path="$SERVER_STORAGE_PATH/${COMP_WORDS[1]}"
|
||||
if [ -e "$server_path" ]; then
|
||||
if [[ "${COMP_WORDS[1]}" == "all" ]] || [ -e "$server_path" ]; then
|
||||
# If the server exists
|
||||
|
||||
__init_server "${COMP_WORDS[1]}"
|
||||
|
16
init/msm
16
init/msm
@ -1728,7 +1728,7 @@ main() {
|
||||
;;
|
||||
*)
|
||||
if [[ "$1" == "all" ]] || [[ -d "$SERVER_STORAGE_PATH/$1" ]]; then
|
||||
|
||||
command_server() {
|
||||
if [ -d "$SERVER_STORAGE_PATH/$1" ]; then
|
||||
local id="$(server_get_id "$1")"
|
||||
else
|
||||
@ -2248,6 +2248,20 @@ main() {
|
||||
error_exit INVALID_COMMAND "Invalid command. See \"$0 help\" for more information."
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
if [[ "$1" == "all" ]]; then
|
||||
# Execute the command for all server names
|
||||
while IFS= read -r -d $'\0' path; do
|
||||
local name="$(basename "$path")"
|
||||
args="${@:2}"
|
||||
echo "Calling $0 \"$name\" \"$args\""
|
||||
command_server "$name" $args
|
||||
done < <(find "$SERVER_STORAGE_PATH" -mindepth 1 -maxdepth 1 -type d -print0)
|
||||
else
|
||||
# Execute the command for a single server
|
||||
command_server "$@"
|
||||
fi
|
||||
else
|
||||
error_exit NAME_NOT_FOUND "No server with that name."
|
||||
fi
|
||||
|
Reference in New Issue
Block a user