aboutsummarylogtreecommitdiffstats
path: root/freeshow-bin.install
blob: 9bed2f3c79b8b160fdf472e9408ca3ac55d13c85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
post_install() {
  echo ">>> Installing FreeShow..."

  ln -sf /opt/FreeShow/FreeShow /usr/bin/FreeShow

  if ! { [[ -L /proc/self/ns/user ]] && unshare --user true; }; then
    chmod 4755 /opt/FreeShow/chrome-sandbox || true
  else
    chmod 0755 /opt/FreeShow/chrome-sandbox || true
  fi

  if command -v update-mime-database >/dev/null 2>&1; then
    update-mime-database /usr/share/mime || true
  fi

  if command -v update-desktop-database >/dev/null 2>&1; then
    update-desktop-database /usr/share/applications || true
  fi

  if command -v apparmor_status >/dev/null 2>&1 && apparmor_status --enabled >/dev/null 2>&1; then
    APPARMOR_PROFILE_SOURCE='/opt/FreeShow/resources/apparmor-profile'
    APPARMOR_PROFILE_TARGET='/etc/apparmor.d/FreeShow'
    if apparmor_parser --skip-kernel-load --debug "$APPARMOR_PROFILE_SOURCE" >/dev/null 2>&1; then
      cp -f "$APPARMOR_PROFILE_SOURCE" "$APPARMOR_PROFILE_TARGET"
      if ! { [ -x '/usr/bin/ischroot' ] && /usr/bin/ischroot; } && command -v apparmor_parser >/dev/null 2>&1; then
        apparmor_parser --replace --write-cache --skip-read-cache "$APPARMOR_PROFILE_TARGET"
      fi
    else
      echo ">>> Error AppArmor!"
    fi
  fi
}

post_upgrade() {
  post_install
}

pre_remove() {
  echo ">>> Uninstalling FreeShow..."
}

post_remove() {
  rm -f /usr/bin/FreeShow

  if command -v update-mime-database >/dev/null 2>&1; then
    update-mime-database /usr/share/mime || true
  fi

  if command -v update-desktop-database >/dev/null 2>&1; then
    update-desktop-database /usr/share/applications || true
  fi

  APPARMOR_PROFILE_DEST='/etc/apparmor.d/FreeShow'
  if [ -f "$APPARMOR_PROFILE_DEST" ]; then
    rm -f "$APPARMOR_PROFILE_DEST"
  fi
}