mariadb/storage/mroonga/packages/debian/mysql-server-mroonga.postrm

38 lines
1.3 KiB
Bash
Executable file

#! /bin/sh
set -e
if [ "$1" = "purge" ]; then
mysql_apparmor_profile_name=usr.sbin.mysqld
mysql_apparmor_profile=/etc/apparmor.d/${mysql_apparmor_profile_name}
mysql_local_apparmor_profile=/etc/apparmor.d/local/${mysql_apparmor_profile_name}
mysql_abstraction_apparmor_profile=/etc/apparmor.d/abstractions/mysql
apparmor_profile_name=mysql-server-mroonga
if test -f "${mysql_local_apparmor_profile}"; then
include_profile="#include <abstractions/${apparmor_profile_name}>"
if grep -q "${include_profile}" "${mysql_local_apparmor_profile}"; then
sed -i'' -e "s,${include_profile},," \
"${mysql_local_apparmor_profile}"
fi
else
start_marker_re="^# ${apparmor_profile_name}: START$"
end_marker_re="^# ${apparmor_profile_name}: END$"
if test -f "${mysql_abstraction_apparmor_profile}" && \
grep -q "${start_marker_re}" \
"${mysql_abstraction_apparmor_profile}"; then
sed -i'' -e "/${start_marker_re}/,/${end_marker_re}/d" \
"${mysql_abstraction_apparmor_profile}"
fi
fi
rm -f "/etc/apparmor.d/local/${apparmor_profile_name}" || true
rmdir /etc/apparmor.d/local 2>/dev/null || true
if aa-status --enabled 2>/dev/null; then
apparmor_parser -r -T -W "${mysql_apparmor_profile}" || true
fi
fi
#DEBHELPER#
exit 0