Skip to content

Instantly share code, notes, and snippets.

@pfigue
Created May 23, 2012 10:52
Show Gist options
  • Save pfigue/2774550 to your computer and use it in GitHub Desktop.
Save pfigue/2774550 to your computer and use it in GitHub Desktop.
Create a RabbitMQ vhost and user, and provide permissions
#!/bin/bash
# Syntax: create_rabbit_vhost.sh <vhost> <user> <pass>
if [ $# != 3 ]; then
echo "Fail! Syntax: $0 <vhost> <user> <pass>"
exit 1
fi
rabbitmqctl add_vhost $1
if [ $? != 0 ]; then
# echo "failed!"
exit 1
fi
rabbitmqctl add_user $2 $3
if [ $? != 0 ]; then
# echo "failed!"
exit 1
fi
rabbitmqctl set_permissions $2 -p $1 ".*" ".*" ".*"
if [ $? != 0 ]; then
# echo "failed!"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment