File: //usr/local/mgr5/sbin/remove_apache_instance.sh
#!/bin/bash
set -eu
if [ ${#} != 1 ] ; then
echo usage: ${0} '<suffix>'
exit 1
fi
if [ -e /etc/redhat-release ]; then
NATIVE_PATH=/etc/httpd
else
NATIVE_PATH=/etc/apache2
fi
SUFFIX=${1#"isp-"}
INSTANCE_PATH=${NATIVE_PATH}-isp-${SUFFIX}
INSTANCE_NAME=${INSTANCE_PATH##*/}
find ${INSTANCE_PATH} \( -not -path "${INSTANCE_PATH}" -and -not -path "${INSTANCE_PATH}/users-php*" -and -not -path "${INSTANCE_PATH}/vhosts-php*" \) -delete
if ! [ -e /etc/redhat-release ]; then
for a in a2enmod a2dismod a2ensite a2dissite a2enconf a2disconf apache2ctl ; do
rm -f /usr/local/sbin/${a}-isp-${SUFFIX}
done
fi
rm -rf /run/${INSTANCE_NAME}
rm -rf /var/log/${INSTANCE_NAME}
rm -f /etc/logrotate.d/${INSTANCE_NAME}