Skip to content

Instantly share code, notes, and snippets.

@lcherone
Last active September 20, 2017 04:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lcherone/880b95aa51186c307e04ef048d4487ef to your computer and use it in GitHub Desktop.
Save lcherone/880b95aa51186c307e04ef048d4487ef to your computer and use it in GitHub Desktop.
LXD apply autostart [true|false] to all containers and default profile.
#!/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