-
Notifications
You must be signed in to change notification settings - Fork 0
/
rabbitmq.sh
31 lines (25 loc) · 948 Bytes
/
rabbitmq.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
RABBITMQADMIN="rabbitmqadmin -s -H $RABBITMQ_HOST -P $RABBITMQ_MANAGEMENT_PORT -u $RABBITMQ_MANAGEMENT_USER -p $RABBITMQ_MANAGEMENT_PASS"
function rabbitmq_create_vhost () {
$RABBITMQADMIN -V / declare vhost name=$1
$RABBITMQADMIN -V / declare permission vhost=$1 user=root "configure=.*" "write=.*" "read=.*"
}
function rabbitmq_add_permission () {
$RABBITMQADMIN -V / declare permission vhost=$1 user=$2 "configure=.*" "write=.*" "read=.*"
}
function rabbitmq_add_read_permission () {
$RABBITMQADMIN -V / declare permission vhost=$1 user=$2 "configure=''" "write=''" "read=.*"
}
function rabbitmq_vhost_sanitize () {
if [ -z "$2" ]; then
local LENGTH="62"
else
local LENGTH="$2"
fi
echo $1 | tr "[:upper:]" "[:lower:]" | sed "s/[^a-zA-Z0-9-]/-/g" | head -c $LENGTH | sed "s/-$//g" | tr -d '\n' | tr -d '\r'
}
function rabbitmq_purge_queue () {
VHOST=$1
QUEUE=$2
$RABBITMQADMIN -V $VHOST purge queue name=$QUEUE
}