If anything goes wrong with the deploy script, such as failing tests, no harm will be done because the script exits upon the first error encountered.
How do you clean up? Once the deploy script is fixed, how do you know what’s been done and what needs redoing?
Have you considered ansible/puppet/chef/salt — environments dedicated to deployment and cleanup, with idempotency to allow for fixing and repeating the deployment, across multiple operating systems and versions?