VirtualBox

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

Last change on this file since 45733 was 32388, checked in by vboxsync, 14 years ago

more branding fixes

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1#!/bin/bash
2#
3# VirtualBox Guest Additions kernel module control script for FreeBSD.
4#
5# Copyright (C) 2008-2010 Oracle Corporation
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
16VBOXGUESTFILE=""
17SILENTUNLOAD=""
18
19abort()
20{
21 echo 1>&2 "$1"
22 exit 1
23}
24
25info()
26{
27 echo 1>&2 "$1"
28}
29
30get_module_path()
31{
32 moduledir="/boot/kernel";
33 modulepath=$moduledir/vboxguest.ko
34 if test -f "$modulepath"; then
35 VBOXGUESTFILE="$modulepath"
36 else
37 VBOXGUESTFILE=""
38 fi
39}
40
41check_if_installed()
42{
43 if test "$VBOXGUESTFILE" -a -f "$VBOXGUESTFILE"; then
44 return 0
45 fi
46 abort "VirtualBox kernel module (vboxguest) not installed."
47}
48
49module_loaded()
50{
51 loadentry=`kldstat | grep vboxguest`
52 if test -z "$loadentry"; then
53 return 1
54 fi
55 return 0
56}
57
58check_root()
59{
60 if test `id -u` -ne 0; then
61 abort "This program must be run with administrator privileges. Aborting"
62 fi
63}
64
65start()
66{
67 if module_loaded; then
68 info "vboxguest already loaded..."
69 else
70 /sbin/kldload vboxguest.ko
71 if ! module_loaded; then
72 abort "Failed to load vboxguest."
73 elif test -c "/dev/vboxguest"; then
74 info "Loaded vboxguest."
75 else
76 stop
77 abort "Aborting due to attach failure."
78 fi
79 fi
80}
81
82stop()
83{
84 if module_loaded; then
85 /sbin/kldunload vboxguest.ko
86 info "Unloaded vboxguest."
87 elif test -z "$SILENTUNLOAD"; then
88 info "vboxguest not loaded."
89 fi
90}
91
92restart()
93{
94 stop
95 sync
96 start
97 return 0
98}
99
100status()
101{
102 if module_loaded; then
103 info "vboxguest running."
104 else
105 info "vboxguest stopped."
106 fi
107}
108
109check_root
110get_module_path
111check_if_installed
112
113if test "$2" = "silentunload"; then
114 SILENTUNLOAD="$2"
115fi
116
117case "$1" in
118start)
119 start
120 ;;
121stop)
122 stop
123 ;;
124restart)
125 restart
126 ;;
127status)
128 status
129 ;;
130*)
131 echo "Usage: $0 {start|stop|restart|status}"
132 exit 1
133esac
134
135exit
136
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