Delete system apps after reinstall (SIP)

Hello, I am looking to find a solution to delete system app such as Mail.app
I currently do it manually with a script that I launch from the recovery partition. The script disables SIP, delete the apps, re-enables SIP and reboot.
Is there a way to have it to run after MDS reinstalls the OS ? I assume when the system is reinstalled, the OS installer doesn’t run from SIP, so I cannot add the script to the MDS OS post install scripts ?

You could set a script to run “with workflow” to disable SIP using the csrutil command, then have a script that runs after the OS is installed to do your changes then reenable SIP. I have not done this myself, but it should work.

tim

Thank you Tim for the help.
The thing is that you can enable/disable SIP only from the Recovery HD. I am not sure the macOS performs the install while booted on recovery HD.
I have added a script in the workflow to disable SIP, delete apps, then enable SIP, and it didn’t work.

From my testing, you can enable SIP in regular macOS, but it doesn’t take effect until you reboot.

I think it was “csrutil clear”

tim