#! /bin/bash

ACTION="custompart-libreoffice_apparmor"

# Add apparmor profile to trust libreoffice in Firefox
logger -it "$ACTION" "Adding LibreOffice to firefox apparmor profile"
echo "$( get custom_partition.mountpoint )/custom/libreoffice/opt/libreoffice7.0/program/soffice.bin Uxr," > /etc/apparmor.d/abstractions/ubuntu-browsers.d/libreoffice
echo '#include <abstractions/ubuntu-browsers.d/libreoffice>' >> /etc/apparmor.d/abstractions/ubuntu-browsers.d/firefox

# reload apparmor only if it is enabled
if [ "$( get system.security.apparmor )" = "true" ] ; then
  logger -it "$ACTION" "Reloading apparmor profiles"
  systemctl reload apparmor.service
else
  logger -it "$ACTION" "Apparmor profiles disabled by setup"
fi

exit 0
