~ubuntu-branches/ubuntu/vivid/virtualbox-ose/vivid

« back to all changes in this revision

Viewing changes to debian/virtualbox-ose-guest-utils.init

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-10-13 23:06:00 UTC
  • mfrom: (0.3.2 upstream) (0.1.12 sid)
  • Revision ID: james.westby@ubuntu.com-20091013230600-xhu2pwizq0wo63l9
Tags: 3.0.8-dfsg-1ubuntu1
* Merge from debian unstable (LP: #444812), remaining changes:
  - Enable DKMS support on virtualbox host and guest modules (LP: #267097)
    - Drop virtualbox-ose{-guest,}-modules-* package templates
    - Recommend *-source instead of *-modules packages
    - Replace error messages related to missing/mismatched
      kernel module accordingly
  - Autoload kernel module
    - LOAD_VBOXDRV_MODULE=1 in virtualbox-ose.default
  - Disable update action
    - patches/u01-disable-update-action.dpatch
  - Virtualbox should go in Accessories, not in System tools (LP: #288590)
    - virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add apport hook
    - virtualbox-ose.files/source_virtualbox-ose.py
    - virtualbox-ose.install
  - Add launchpad integration
    - control
    - lpi-bug.xpm
    - patches/u02-lp-integration.dpatch
* Try to remove existing dkms modules before adding the new modules
  (LP: #434503)
  - debian/virtualbox-ose-source.postinst
  - debian/virtualbox-ose-guest-source.postinst
* Don't fail if dkms modules have already been removed
  - debian/virtualbox-ose-source.prerm
  - debian/virtualbox-ose-guest-source.prerm

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
# (C) 2007 Michael Meskes <meskes@debian.org>
3
3
 
4
4
### BEGIN INIT INFO
5
 
# Provides:          vboxadd
 
5
# Provides:          vboxadd virtualbox-ose-guest-utils
6
6
# Short-Description: VirtualBox Linux Additions
7
7
# Required-Start:    $remote_fs
8
8
# Required-Stop:     $remote_fs
14
14
 
15
15
. /lib/lsb/init-functions
16
16
 
 
17
test -d /usr/share/doc/virtualbox-ose-guest-utils -a -x /usr/sbin/VBoxService || exit 0
 
18
 
17
19
in_virtual_machine()
18
20
{
19
21
        if [ -z "$(lspci -d 80ee:beef)" ]; then
20
 
                log_warning_msg 'VirtualBox Additions Disabled, not in a Virtual Machine';
 
22
                log_warning_msg "VirtualBox Additions disabled, not in a Virtual Machine"
21
23
                return 1
22
24
        fi
23
25
 
24
26
        return 0
25
27
}
26
28
 
 
29
running()
 
30
{
 
31
    lsmod | grep -q "$1[^_-]"
 
32
}
 
33
 
27
34
case "$1" in
28
35
  start)
29
 
        in_virtual_machine || exit 0
30
 
        log_action_begin_msg 'Starting VirtualBox Additions';
31
 
 
32
 
        # udev should have already handled this module
33
 
        modprobe --quiet vboxadd
34
 
        if [ "$?" -ne 0 ]; then
35
 
                # vboxadd not installed, or has a problem
36
 
                log_action_msg 'no guest utils available, kernel module not loadable';
37
 
                log_end_msg 1
38
 
                exit 0
39
 
        fi
40
 
 
41
 
        # this one is not handled by udev
42
 
        modprobe --quiet vboxvfs
43
 
        if [ "$?" -ne 0 ]; then
44
 
                # vboxvfs not installed, or has a problem
45
 
                log_action_msg 'shared folders not available, kernel module not loadable';
46
 
                log_end_msg 1
47
 
                exit 0
48
 
        fi
 
36
        in_virtual_machine || exit 0
 
37
        log_begin_msg "Starting VirtualBox Additions"
 
38
 
 
39
        # should already be loaded automatically
 
40
        if ! running vboxadd; then
 
41
                if ! modprobe vboxadd > /dev/null 2>&1; then
 
42
                        # vboxadd not installed, or has a problem
 
43
                        log_failure_msg "Guest additions not available, kernel module not loadable (vboxadd)"
 
44
                        log_end_msg 1
 
45
                        exit 1
 
46
                fi
 
47
        fi
 
48
 
 
49
        if ! running vboxvfs; then
 
50
                if ! modprobe vboxvfs > /dev/null 2>&1; then
 
51
                        # vboxvfs not installed, or has a problem
 
52
                        log_failure_msg "Shared folders not available, kernel module not loadable (vboxvfs)"
 
53
                        log_end_msg 1
 
54
                        exit 1
 
55
                fi
 
56
        fi
 
57
 
49
58
        # Mount all shared folders from /etc/fstab. Normally this is done by some
50
 
        # other startup script but this requires the vboxdrv kernel module loaded.
 
59
        # other startup script but this requires the vboxvfs kernel module loaded.
51
60
        mount -a -t vboxsf
52
61
 
53
 
        start-stop-daemon --start --quiet --exec /usr/sbin/VBoxService
54
 
        log_end_msg $?
 
62
        start-stop-daemon --start --quiet --oknodo --exec /usr/sbin/VBoxService
 
63
        if [ $? -ne 0 ]; then
 
64
                log_end_msg 1
 
65
                exit 1
 
66
        fi
 
67
 
 
68
        log_end_msg 0
55
69
        ;;
 
70
 
56
71
  stop)
57
 
        in_virtual_machine || exit 0
58
 
        log_action_begin_msg 'Stopping VirtualBox Additions';
 
72
        in_virtual_machine || exit 0
 
73
        log_begin_msg "Stopping VirtualBox Additions"
 
74
 
59
75
        start-stop-daemon --stop --quiet --oknodo --exec /usr/sbin/VBoxService
60
 
        log_end_msg $?
 
76
        if [ $? -ne 0 ]; then
 
77
                log_end_msg 1
 
78
                exit 1
 
79
        fi
 
80
 
 
81
        umount -a -t vboxsf
 
82
 
 
83
        if running vboxvfs; then
 
84
                if ! rmmod vboxvfs 2>/dev/null; then
 
85
                        log_failure_msg "Cannot unload shared folders kernel module (vboxvfs)"
 
86
                        log_end_msg 1
 
87
                        exit 1
 
88
                fi
 
89
        fi
 
90
 
 
91
        if running vboxadd; then
 
92
                if ! rmmod vboxadd 2>/dev/null; then
 
93
                        log_failure_msg "Cannot unload guest additions kernel module (vboxadd)"
 
94
                        log_end_msg 1
 
95
                        exit 1
 
96
                fi
 
97
        fi
 
98
 
 
99
        log_end_msg 0
61
100
        ;;
 
101
 
62
102
  restart|force-reload)
63
 
        #
64
 
        #       If the "reload" option is implemented, move the "force-reload"
65
 
        #       option to the "reload" entry. If not, "force-reload" is
66
 
        #       just the same as "restart".
67
 
        #
68
 
        $0 stop
69
 
        $0 start
70
 
        ;;
 
103
        $0 stop && $0 start
 
104
        ;;
 
105
 
 
106
  status)
 
107
        status=0
 
108
 
 
109
        if ! running vboxadd; then
 
110
                echo "Guest additions kernel module (vboxadd) not loaded"
 
111
                status=3
 
112
        fi
 
113
 
 
114
        if ! running vboxvfs; then
 
115
                echo "Shared folders kernel module (vboxvfs) not loaded"
 
116
                status=3
 
117
        fi
 
118
 
 
119
        if ! pgrep -x VBoxService > /dev/null; then
 
120
                echo "VBoxService daemon isn't running"
 
121
                status=3
 
122
        fi
 
123
 
 
124
        exit $status
 
125
        ;;
 
126
 
71
127
  *)
72
 
        echo "Usage: $0 {start|stop|restart|force-reload}" >&2
 
128
        echo "Usage: $0 {start|stop|restart|force-reload|status}"
73
129
        exit 1
74
130
        ;;
75
131
esac
76
 
 
77
 
exit 0