summarylogtreecommitdiffstats
path: root/dgrp-install.sh
blob: 3710099a0e864f8db57b371b98c59012031d3868 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
_daemons=('daemon' 'ditty')

pre_install() {
  set -u
  # Ensure that config files don't get lost on reinstall, chiefly from the Digi make install to package upgrade
  # post_install code will rename it back
  if [ -s '/etc/dgrp.backing.store' ] && [ ! -s '/etc/dgrp.backing.store.pacsave' ]; then
    mv '/etc/dgrp.backing.store' '/etc/dgrp.backing.store.pacsave'
  fi
  set +u
}

post_upgrade() {
  set -u
  #mandb -q
  # rmdir '/tmp/dgrp' # postinstall forgets to remove this. Useful on /tmp folders that are not mounted tmpfs
  systemctl daemon-reload
  #udevadm control --reload # Seems to work without this
  # Digi's postinstall automatically loads the daemons so we might as well too
  if [ ! -d /usr/src/dgrp-*/ ]; then # detect DKMS
    /usr/bin/dgrp/config/postinstall # this used to run depmod -a
    depmod -a
    local _daemon
    for _daemon in "${_daemons[@]}"; do
      systemctl enable "dgrp_${_daemon}.service"
      systemctl start "dgrp_${_daemon}.service"
    done
    #echo "RealPort (dgrp) startup scripts updated or installed"
  fi
  set +u
}

post_install() {
  post_upgrade
}

pre_upgrade() {
  set -u
  if [ ! -d /usr/src/dgrp-*/ ]; then
    local _daemon
    for _daemon in "${_daemons[@]}"; do
      systemctl stop "dgrp_${_daemon}.service"
      systemctl disable "dgrp_${_daemon}.service"
    done
    /usr/bin/dgrp/config/preuninstall
  fi
  set +u
}

pre_remove() {
  pre_upgrade
  set -u
  . '/usr/bin/dgrp/config/file_locations'
  if [ -f "${DGRP_STORE}.old" ]; then
    echo "To clean fully you may want to remove your config backup: ${DGRP_STORE}.old"
  fi
  if [ -f "${DGRP_STORE}.pacsave" ]; then
    echo "To clean fully you may want to remove your config backup: ${DGRP_STORE}.pacsave"
  fi
  set +u
}

post_remove() {
  set -u
  #mandb -q
  systemctl daemon-reload
  #udevadm control --reload # Seems to work without this
  #echo "RealPort (dgrp) startup scripts removed"
  set +u
}