summarylogtreecommitdiffstats
path: root/virtualbox-bin.install
blob: 19d582e69d24ed7696ce87a087c37be5f3038616 (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
update_databases() {
  # Update mime database
  type -P update-mime-database &>/dev/null &&
    update-mime-database /usr/share/mime &>/dev/null

  # Update xdg icon database
  type -P xdg-icon-resource &>/dev/null &&
    xdg-icon-resource forceupdate --theme hicolor &>/dev/null

  # Update desktop database
  type -P update-desktop-database &>/dev/null &&
    update-desktop-database -q &>/dev/null
}

# arg 1:  the new package version
post_install() {
  # Add vboxusers group, GID 108 is reserved (http://wiki.archlinux.org/index.php/UID_and_GID_list),
  getent group vboxusers &> /dev/null || groupadd -f -g 108 vboxusers

  # Load new udev rule for module vboxdrv
  udevadm control --reload-rules

  # Update databases
  update_databases

  # Show warnings
  cat <<EOF

==> Remember to add allowed users to the vboxusers group:
==> # gpasswd -a USERNAME vboxusers
EOF

}

# arg 1:  the new package version
# arg 2:  the old package version
pre_upgrade() {
  # Remove any stuff remaining from the module compilation
  rm -Rf "/opt/VirtualBox"
}

# arg 1:  the new package version
# arg 2:  the old package version
post_upgrade() {
  post_install "$1"
  (($(vercmp $2 '4.1.14-2') < 0 )) && cat <<EOF || true

==> **Warning**
==> This version drop vboxdrv initscript.
==> Please change to dkms instead of vboxdrv in DAEMONS in rc.conf.
==>
EOF
}

# arg 1:  the old package version
post_remove() {
  # Remove any stuff remaining from the module compilation
  rm -Rf "/opt/VirtualBox"

  # Remove any run files
  rm -Rf "/var/run/VirtualBox"

  # Update databases
  update_databases

  # remove vboxusers group
  groupdel vboxusers &>/dev/null || true
}

# vim:set ts=2 sw=2 ft=sh et: