two files in debian control postinst & postrm Code: #!/bin/sh #update sudoers update-sudoers create the following file etc/sudoers.d/healthcheck.sudoers Code: user ALL = NOPASSWD: /<path>/command put all the commands you need to run as root. this will allow commands to be run as root when your package is installed, and stopped when package is removed.
#!/bin/sh #update sudoers update-sudoers
user ALL = NOPASSWD: /<path>/command