#!/bin/bash

/usr/sbin/service stop nginx
/usr/sbin/service stop haproxy
set -e
/bin/rm -f /etc/init.d/nginx
/bin/rm -f /etc/init.d/haproxy
/usr/sbin/update-rc.d nginx remove
/usr/sbin/update-rc.d haproxy remove
#!/bin/bash
if[ -f /etc/init.d/nginx ]; then
  ps aux | grep "nginx: master process" | grep -v grep | awk ' { print $2 } ' | xargs kill
   /bin/rm -f /etc/init.d/nginx
   /usr/sbin/update-rc.d nginx remove
fi

if[ -f /etc/init.d/nginx ]; then
  ps aux | grep "/usr/sbin/haproxy" | grep -v grep | awk ' { print $2 } ' | xargs kill
  /bin/rm -f /etc/init.d/haproxy
  /usr/sbin/update-rc.d haproxy remove
fi
Make the purge init_d script kill process only if its not upstart
Make the purge init_d script kill process only if its not upstart
