forked from whamcloud/integrated-manager-for-lustre
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vagrant-virsh
executable file
·44 lines (40 loc) · 1.52 KB
/
vagrant-virsh
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
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
set -e
# this environment variable is the whole reason for this script
# this needs to be set and there is no way to have it set from fence_virsh
export LIBVIRT_DEFAULT_URI=qemu:///system
if [ -e /tmp/vagrant-virsh.log ]; then
echo "$(date) got command: $SSH_ORIGINAL_COMMAND" >> /tmp/vagrant-virsh.log
fi
if [[ "$SSH_ORIGINAL_COMMAND" = *EXPECT* ]]; then
while true; do
echo -n "[EXPECT]# "
read -r COMMAND
# TODO: a bit more security here to isolate this script to only desired
# virsh commands would be good
if [[ $COMMAND = virsh\ * ]]; then
if [ -e /tmp/vagrant-virsh.log ]; then
echo "$(date) executing command: $COMMAND" >> /tmp/vagrant-virsh.log
fi
$COMMAND
elif [[ $COMMAND = quit ]]; then
if [ -e /tmp/vagrant-virsh.log ]; then
echo "$(date) got quit command, exiting" >> /tmp/vagrant-virsh.log
fi
exit 0
else
if [ -e /tmp/vagrant-virsh.log ]; then
echo "$(date) not executing disallowed command: $COMMAND" >> /tmp/vagrant-virsh.log
fi
echo "Disallowed command: $SSH_ORIGINAL_COMMAND"
exit 1
fi
done
else
# TODO: a bit more security here to isolate this script to only desired
# virsh commands would be good
if [ -e /tmp/vagrant-virsh.log ]; then
echo "$(date) executing command: $SSH_ORIGINAL_COMMAND" >> /tmp/vagrant-virsh.log
fi
eval $SSH_ORIGINAL_COMMAND
fi