summarylogtreecommitdiffstats
path: root/comtrol-rocketport-upci-install.sh
blob: 4e298b8eedbb489914cc6f56deeb4c0c8da3a632 (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
_pkgname='comtrol-rocketport-upci'
_modulename='rocketupci'
_origmodname='rocket'

post_upgrade() {
  set -u
  systemctl daemon-reload
  if [ ! -d "/usr/src/${_pkgname}"-*/ ]; then
    depmod -a
    if ! lsmod | cut -d' ' -f1 | grep -q "^${_modulename}"'$'; then
      #echo 'Reboot or load now with:'
      #echo "  sudo modprobe '${_modulename}'"
      if [ "${_modulename}" != "${_origmodname}" ]; then
        rmmod "${_origmodname}" 2> /dev/null # blacklisted on boot
      fi
      modprobe "${_modulename}"
      rocketport-upci-firmware.sh -p
    fi
  fi
  set +u
}

post_install() {
  set -u
  post_upgrade
  systemctl enable 'rocketport-upci-firmware.service'
  set +u
}

pre_remove() {
  set -u
  if [ ! -d "/usr/src/${_pkgname}"-*/ ]; then
    rmmod "${_modulename}"
  fi
  systemctl disable 'rocketport-upci-firmware.service'
  set +u
}

post_remove() {
  systemctl daemon-reload
}