VirtualBox

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

Last change on this file since 78425 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

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