summarylogtreecommitdiffstats
path: root/linux-enable-ir-emitter.install
blob: 1e9a253b77b85ad6c3564cf3955b732b985cbd37 (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
post_intall() {
  # support update v3 to v4 
  if [ -f /etc/linux-enable-ir-emitter.yaml ]; then 
    python /usr/lib/linux-enable-ir-emitter/migrate-v3.py
    rm -f /etc/linux-enable-ir-emitter.yaml
  fi

  # if SELinux is installed, fix denied access to /dev/video
  which semanage &> /dev/null
  if [ "$?" -eq 0 ]; then
      semanage fcontext -a -t bin_t /usr/lib/linux-enable-ir-emitter/driver/execute-driver
      semanage fcontext -a -t bin_t /usr/lib/linux-enable-ir-emitter/driver/driver-generator
      restorecon -v /usr/lib/linux-enable-ir-emitter/driver/* 1> /dev/null
  fi
}

post_remove() {
  # remove SeLinux permission
  which semanage &> /dev/null
  if [ "$?" -eq 0 ]; then
      semanage fcontext -d /usr/lib/linux-enable-ir-emitter/driver/execute-driver
      semanage fcontext -d /usr/lib/linux-enable-ir-emitter/driver/driver-generator
  fi

  # delete python cache
  rm -rf /usr/lib/linux-enable-ir-emitter/

  # delete drivers
  rm -rf /etc/linux-enable-ir-emitter
  
  # delete systemd service
  systemctl disable linux-enable-ir-emitter &> /dev/null
  rm -f /usr/lib/systemd/system/linux-enable-ir-emitter.service
  rm -f /etc/udev/rules.d/99-linux-enable-ir-emitter.rules
}