summarylogtreecommitdiffstats
path: root/connecttech-cti-serial-install.sh
blob: 88e8a7b4ed2590aa9304fbc2fcf29c7eb4383e7b (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
_pkgname='connecttech-cti-serial'
_servicename='cti-serial-set485.service'
_etcconf='/etc/cti-serial-set485.sh'

post_upgrade() {
  set -u
  # mandb -q
  systemctl daemon-reload
  # Handle the module update if DKMS doesn't
  if [ ! -d "/usr/src/${_pkgname}"-*/ ]; then
    # depmod -a # now done by a pacman hook
    if systemctl -q is-enabled "${_servicename}"; then
      systemctl start "${_servicename}"
    fi
  fi
  set +u
}

post_install() {
  post_upgrade
  set -u
  if systemctl -q is-enabled "${_servicename}" && ! systemctl -q is-active "${_servicename}"; then
    # We can't auto start the service because DKMS hasn't made the module yet
    echo "If you have RS-485 jumperless settings add them to ${_etcconf} and start the service with"
    echo "  systemctl start ${_servicename}"
  fi
  set +u
}

pre_upgrade() {
  set -u
  if [ ! -d "/usr/src/${_pkgname}"-*/ ]; then
    systemctl stop "${_servicename}" # also rmmod the module
  fi
  set +u
}

pre_remove() {
  set -u
  systemctl stop "${_servicename}" # pre_upgrade
  set +u
}

post_remove() {
  set -u
  systemctl daemon-reload
  set +u
}