VirtualBox

source: vbox/trunk/src/VBox/Additions/freebsd/Installer/vboxguest.sh@ 14683

Last change on this file since 14683 was 8178, checked in by vboxsync, 17 years ago

rebranding

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
1#!/bin/bash
2# Sun xVM VirtualBox
3# VirtualBox Guest Additions kernel module control script for FreeBSD.
4#
5# Copyright (C) 2008 Sun Microsystems, Inc.
6#
7# This file is part of VirtualBox Open Source Edition (OSE), as
8# available from http://www.virtualbox.org. This file is free software;
9# you can redistribute it and/or modify it under the terms of the GNU
10# General Public License (GPL) as published by the Free Software
11# Foundation, in version 2 as it comes in the "COPYING" file of the
12# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14#
15# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
16# Clara, CA 95054 USA or visit http://www.sun.com if you need
17# additional information or have any questions.
18#
19
20VBOXGUESTFILE=""
21SILENTUNLOAD=""
22
23abort()
24{
25 echo 1>&2 "$1"
26 exit 1
27}
28
29info()
30{
31 echo 1>&2 "$1"
32}
33
34get_module_path()
35{
36 moduledir="/boot/kernel";
37 modulepath=$moduledir/vboxguest.ko
38 if test -f "$modulepath"; then
39 VBOXGUESTFILE="$modulepath"
40 else
41 VBOXGUESTFILE=""
42 fi
43}
44
45check_if_installed()
46{
47 if test "$VBOXGUESTFILE" -a -f "$VBOXGUESTFILE"; then
48 return 0
49 fi
50 abort "VirtualBox kernel module (vboxguest) not installed."
51}
52
53module_loaded()
54{
55 loadentry=`kldstat | grep vboxguest`
56 if test -z "$loadentry"; then
57 return 1
58 fi
59 return 0
60}
61
62check_root()
63{
64 if test `id -u` -ne 0; then
65 abort "This program must be run with administrator privileges. Aborting"
66 fi
67}
68
69start()
70{
71 if module_loaded; then
72 info "vboxguest already loaded..."
73 else
74 /sbin/kldload vboxguest.ko
75 if ! module_loaded; then
76 abort "Failed to load vboxguest."
77 elif test -c "/dev/vboxguest"; then
78 info "Loaded vboxguest."
79 else
80 stop
81 abort "Aborting due to attach failure."
82 fi
83 fi
84}
85
86stop()
87{
88 if module_loaded; then
89 /sbin/kldunload vboxguest.ko
90 info "Unloaded vboxguest."
91 elif test -z "$SILENTUNLOAD"; then
92 info "vboxguest not loaded."
93 fi
94}
95
96restart()
97{
98 stop
99 sync
100 start
101 return 0
102}
103
104status()
105{
106 if module_loaded; then
107 info "vboxguest running."
108 else
109 info "vboxguest stopped."
110 fi
111}
112
113check_root
114get_module_path
115check_if_installed
116
117if test "$2" = "silentunload"; then
118 SILENTUNLOAD="$2"
119fi
120
121case "$1" in
122start)
123 start
124 ;;
125stop)
126 stop
127 ;;
128restart)
129 restart
130 ;;
131status)
132 status
133 ;;
134*)
135 echo "Usage: $0 {start|stop|restart|status}"
136 exit 1
137esac
138
139exit
140
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette