Clear out the old sudoers block before re-adding it in
[invirt/packages/invirt-console.git] / debian / invirt-console-host.postinst
index d2c7c08..9f4b5a8 100755 (executable)
@@ -20,6 +20,9 @@ set -e
 
 case "$1" in
     configure)
+        # Clean up the old sudoers line before we add it back
+        perl -i.bak -ne 's%^### (BEGIN|END) invirt-console-host\s*$%%m && ($skip = ($1 eq "BEGIN")); print unless $skip;' /etc/sudoers
+        
         cat >>/etc/sudoers <<EOF
 ### BEGIN invirt-console-host
 conservr ALL=(ALL) NOPASSWD: /usr/sbin/xm console d_*