Created
April 12, 2015 18:10
-
-
Save Mic92/f7abdd6cbd814d4399ad to your computer and use it in GitHub Desktop.
Execute a command for every lxc instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# replace this with your rootfs | |
lxc_root=/data/containers | |
for n in `lxc-ls`; do | |
name=n | |
r=$lxc_root/$n/rootfs | |
root=$r | |
c=$lxc_root/$n/config | |
config=$c | |
eval echo "\$ $1" 1>&2 | |
eval "$1" | |
done | |
# example usage | |
$ lxc-foreach 'lxc-attach -n $n -- apt-get upgrade' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment