VirtualBox

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

Last change on this file was 106061, checked in by vboxsync, 2 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
1#!/bin/bash
2# $Id: vboxguest.sh 106061 2024-09-16 14:03:52Z vboxsync $
3## @file
4# VirtualBox Guest Additions kernel module control script for FreeBSD.
5#
6
7#
8# Copyright (C) 2008-2024 Oracle and/or its affiliates.
9#
10# This file is part of VirtualBox base platform packages, as
11# available from https://www.virtualbox.org.
12#
13# This program is free software; you can redistribute it and/or
14# modify it under the terms of the GNU General Public License
15# as published by the Free Software Foundation, in version 3 of the
16# License.
17#
18# This program is distributed in the hope that it will be useful, but
19# WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21# General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with this program; if not, see <https://www.gnu.org/licenses>.
25#
26# SPDX-License-Identifier: GPL-3.0-only
27#
28
29VBOXGUESTFILE=""
30SILENTUNLOAD=""
31
32abort()
33{
34 echo 1>&2 "$1"
35 exit 1
36}
37
38info()
39{
40 echo 1>&2 "$1"
41}
42
43get_module_path()
44{
45 moduledir="/boot/kernel";
46 modulepath=$moduledir/vboxguest.ko
47 if test -f "$modulepath"; then
48 VBOXGUESTFILE="$modulepath"
49 else
50 VBOXGUESTFILE=""
51 fi
52}
53
54check_if_installed()
55{
56 if test "$VBOXGUESTFILE" -a -f "$VBOXGUESTFILE"; then
57 return 0
58 fi
59 abort "VirtualBox kernel module (vboxguest) not installed."
60}
61
62module_loaded()
63{
64 loadentry=`kldstat | grep vboxguest`
65 if test -z "$loadentry"; then
66 return 1
67 fi
68 return 0
69}
70
71check_root()
72{
73 if test `id -u` -ne 0; then
74 abort "This program must be run with administrator privileges. Aborting"
75 fi
76}
77
78start()
79{
80 if module_loaded; then
81 info "vboxguest already loaded..."
82 else
83 /sbin/kldload vboxguest.ko
84 if ! module_loaded; then
85 abort "Failed to load vboxguest."
86 elif test -c "/dev/vboxguest"; then
87 info "Loaded vboxguest."
88 else
89 stop
90 abort "Aborting due to attach failure."
91 fi
92 fi
93}
94
95stop()
96{
97 if module_loaded; then
98 /sbin/kldunload vboxguest.ko
99 info "Unloaded vboxguest."
100 elif test -z "$SILENTUNLOAD"; then
101 info "vboxguest not loaded."
102 fi
103}
104
105restart()
106{
107 stop
108 sync
109 start
110 return 0
111}
112
113status()
114{
115 if module_loaded; then
116 info "vboxguest running."
117 else
118 info "vboxguest stopped."
119 fi
120}
121
122check_root
123get_module_path
124check_if_installed
125
126if test "$2" = "silentunload"; then
127 SILENTUNLOAD="$2"
128fi
129
130case "$1" in
131start)
132 start
133 ;;
134stop)
135 stop
136 ;;
137restart)
138 restart
139 ;;
140status)
141 status
142 ;;
143*)
144 echo "Usage: $0 {start|stop|restart|status}"
145 exit 1
146esac
147
148exit
149
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