2 # This file is part of the LibreOffice project.
3 # ------------------------------------------------------------------
5 # Copyright (C) 2016 Canonical Ltd.
7 # This Source Code Form is subject to the terms of the Mozilla Public
8 # License, v. 2.0. If a copy of the MPL was not distributed with this
9 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 # Author: Bryan Quigley <bryan.quigley@canonical.com>
13 # ------------------------------------------------------------------
15 # This is a simple script to help get AppArmor working on different distros
16 # Generally these apparmor profiles target the latest LibreOffice
18 INST_ROOT
=$1 #Where libreoffice program folder can be found
19 PROFILESFROM
=$2 #Where the profile files are
20 INSTALLTO
=$3 #Where should the apparmor profiles (For manual use should be /etc/apparmor.d)
21 RESTART
=$4 #Should we restart apparmor using service?
24 #Ubuntu 16.04 with stock LibreOffice:
25 # sudo ./sysui/desktop/share/apparmor.sh /usr/lib/libreoffice/ sysui/desktop/apparmor/ /etc/apparmor.d/ true
27 #Ubuntu 16.04, with built debs from LibreOffice git
28 # sudo ./sysui/desktop/share/apparmor.sh /opt/libreofficedev5.2/ sysui/desktop/apparmor/ /etc/apparmor.d/ true
30 #Ubuntu 16.04, running from git!
31 # sudo ./sysui/desktop/share/apparmor.sh /mnt/store/git/libo/instdir/ sysui/desktop/apparmor/ /etc/apparmor.d/ true
33 #Need to convert / to . for profile names
34 INST_ROOT_FORMAT
=${INST_ROOT/\//}
35 INST_ROOT_FORMAT
=${INST_ROOT_FORMAT////.}
37 #Need to escape / for sed
38 INST_ROOT_SED
=${INST_ROOT////\\/}
40 for filename
in $
(ls $PROFILESFROM)
42 tourl
=$INSTALLTO$INST_ROOT_FORMAT$filename
43 sed "s/INSTDIR-/$INST_ROOT_SED/g" $PROFILESFROM$filename > $tourl
48 if [ "$RESTART" = true
] ; then
49 echo "Restarting AppArmor"
50 service apparmor restart