5
if [ "$1" = "purge" ]; then
6
mysql_apparmor_profile_name=usr.sbin.mysqld
7
mysql_apparmor_profile=/etc/apparmor.d/${mysql_apparmor_profile_name}
8
mysql_local_apparmor_profile=/etc/apparmor.d/local/${mysql_apparmor_profile_name}
9
mysql_abstraction_apparmor_profile=/etc/apparmor.d/abstractions/mysql
10
apparmor_profile_name=mysql-server-mroonga
11
if test -f "${mysql_local_apparmor_profile}"; then
12
include_profile="#include <abstractions/${apparmor_profile_name}>"
13
if grep -q "${include_profile}" "${mysql_local_apparmor_profile}"; then
14
sed -i'' -e "s,${include_profile},," \
15
"${mysql_local_apparmor_profile}"
18
start_marker_re="^# ${apparmor_profile_name}: START$"
19
end_marker_re="^# ${apparmor_profile_name}: END$"
20
if test -f "${mysql_abstraction_apparmor_profile}" && \
21
grep -q "${start_marker_re}" \
22
"${mysql_abstraction_apparmor_profile}"; then
23
sed -i'' -e "/${start_marker_re}/,/${end_marker_re}/d" \
24
"${mysql_abstraction_apparmor_profile}"
28
rm -f "/etc/apparmor.d/local/${apparmor_profile_name}" || true
29
rmdir /etc/apparmor.d/local 2>/dev/null || true
31
if aa-status --enabled 2>/dev/null; then
32
apparmor_parser -r -T -W "${mysql_apparmor_profile}" || true