CONFFILE=/etc/qemu/qemu-ga.conf if [ "$(which qemu-ga)" == "" ]; then echo "guest agent is not installed" else if [ ! -f $CONFFILE ]; then qemu-ga -D > $CONFFILE sed -i "s/block-rpcs=/block-rpcs=guest-set-user-password/" $CONFFILE systemctl restart qemu-guest-agent else if [ "$(grep guest-set-user-password $CONFFILE)" == "" ]; then echo "block-rpcs=guest-set-user-password" >> $CONFFILE systemctl restart qemu-guest-agent fi fi fi