Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / sysui / desktop / share / apparmor.sh
blob59803e1ae4db6dc5b98c5b38075fc3784f067ea5
1 #!/bin/bash
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?
23 #Example uses:
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
44 echo "$tourl"
46 done
48 if [ "$RESTART" = true ] ; then
49 echo "Restarting AppArmor"
50 service apparmor restart