File: kmod.postinst

package info (click to toggle)
kmod 34.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie, trixie-proposed-updates
  • size: 2,864 kB
  • sloc: ansic: 16,990; makefile: 498; sh: 382; xml: 61; perl: 12
file content (51 lines) | stat: -rw-r--r-- 1,240 bytes parent folder | download
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
#!/bin/sh -e

delete_old_etc_modules() {
  [ -e /etc/modules ] || return 0
  # normalize the files by ignoring empty lines
  local modules_hash="$(sed -e '/^$/d' /etc/modules | md5sum | cut -d ' ' -f1)"

  case "$modules_hash" in
    330dcf902eae56682d44133c168fee89) ;;
    6e5894c5d926d1e69968e64e3ffa1cbd) ;;
    *) return ;;
  esac

  # delete the unmodified /etc/modules
  rm -f /etc/modules
}

create_etc_modules() {
  [ -e /etc/modules ] && return 0
  cat <<END > /etc/modules
# /etc/modules is obsolete and has been replaced by /etc/modules-load.d/.
# Please see modules-load.d(5) and modprobe.d(5) for details.
#
# Updating this file still works, but it is undocumented and unsupported.
END
  chmod 644 /etc/modules
  if which restorecon > /dev/null 2>&1; then
    restorecon /etc/modules
  fi
}

sysvinit_cleanup() {
  [ "$2" ] || return 0

  dpkg --compare-versions $2 lt 34-3~ || return 0
  # update-rc.d removes symlinks even if LSB initscript exists, contrary to
  # update-rc-d(8). See #680293. Can be removed once it is fixed.
  [ -f /etc/init.d/kmod ] && return 0
  update-rc.d kmod remove || true
}

case "$1" in
  configure)
  sysvinit_cleanup "$@"
  delete_old_etc_modules
  create_etc_modules
esac

#DEBHELPER#

exit 0