Last active
September 20, 2017 04:03
-
-
Save lcherone/880b95aa51186c307e04ef048d4487ef to your computer and use it in GitHub Desktop.
LXD apply autostart [true|false] to all containers and default profile.
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 | |
# | |
# Apply autostart to all containers and default profile. | |
# - Especially handy if containers have their own autostart value. | |
# - Could be used for any config value with a tweek. | |
# | |
# ask | |
while true; do | |
read -p "Apply autostart [true or false] to all containers? " autostart | |
case $autostart in | |
[true]* ) autostart=true ; break;; | |
[false]* ) autostart=false ; break;; | |
* ) echo "Please answer true or false.";; | |
esac | |
done | |
# apply to default profile | |
lxc profile set default boot.autostart "$autostart" | |
# update containers configs | |
for container in $(lxc list --format=csv -c n); do | |
lxc config set "$container" boot.autostart "$autostart" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment