#!/bin/sh

set -e

PARAM=$1

qm list | tail -n +2 | awk '{ print $1 }' | while read vmid
do
	case $PARAM in
		0|1)
			qm set $vmid --onboot $PARAM
			;;
		"")
			qm config $vmid | grep -e onboot: -e name:
			;;
		*)
			cat << EOF
usage: manage autostart behaviour of vms on node

	$0       show autstart state for alle vms on node
	$0 <0|1> disables or enables autostart for all vms on node
	$0 help  this help
EOF
			exit 1
			;;
	esac
done