Editing ExecuteInAllVEs
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<code> | <code> | ||
#!/bin/bash | #!/bin/bash | ||
− | + | CONFDIR="/etc/vz/conf" | |
if [ "$1" == "" ]; then | if [ "$1" == "" ]; then | ||
echo "$0 -- Execute a command on all VEs" | echo "$0 -- Execute a command on all VEs" | ||
Line 16: | Line 7: | ||
echo "Example: vzexec service httpd restart" | echo "Example: vzexec service httpd restart" | ||
echo "" | echo "" | ||
− | echo "Note that variables are expanded in the host's shell, and use ' ' to prevent this." | + | echo "Note that variables are expanded in the host's shell, and use '' to prevent this." |
echo "Example: vzexec echo \$PWD and vzexec 'echo \$PWD' are different." | echo "Example: vzexec echo \$PWD and vzexec 'echo \$PWD' are different." | ||
exit | exit | ||
fi | fi | ||
− | for veid | + | for veconf in $CONFDIR/*.conf ; do |
− | echo "*** VE $veid" | + | veid=`basename $veconf .conf` |
+ | if [ "$veid" == "0" ]; then continue; fi | ||
+ | vename=`grep ^NAME $veconf | head -1 | sed -e 's@NAME=@@' | sed -e 's@"@@g'` | ||
+ | echo "*** VE $veid ($vename)" | ||
vzctl exec $veid $@ | vzctl exec $veid $@ | ||
done | done | ||
</code> | </code> |