VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/installer/vboxadd-service.sh@ 97405

Last change on this file since 97405 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1#!/bin/sh
2# $Id: vboxadd-service.sh 96407 2022-08-22 17:43:14Z vboxsync $
3## @file
4# Linux Additions Guest Additions service daemon init script.
5#
6
7#
8# Copyright (C) 2006-2022 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
29# X-Conflicts-With is our own invention, which we use when converting to
30# a systemd unit.
31
32# chkconfig: 345 35 65
33# description: VirtualBox Additions service
34#
35### BEGIN INIT INFO
36# Provides: vboxadd-service
37# Required-Start: vboxadd
38# Required-Stop: vboxadd
39# Default-Start: 2 3 4 5
40# Default-Stop: 0 1 6
41# X-Conflicts-With: systemd-timesyncd.service
42# Description: VirtualBox Additions Service
43### END INIT INFO
44
45PATH=$PATH:/bin:/sbin:/usr/sbin
46SCRIPTNAME=vboxadd-service.sh
47
48PIDFILE="/var/run/${SCRIPTNAME}"
49
50# Preamble for Gentoo
51if [ "`which $0`" = "/sbin/rc" ]; then
52 shift
53fi
54
55begin()
56{
57 test -n "${2}" && echo "${SCRIPTNAME}: ${1}."
58 logger -t "${SCRIPTNAME}" "${1}."
59}
60
61succ_msg()
62{
63 logger -t "${SCRIPTNAME}" "${1}."
64}
65
66fail_msg()
67{
68 echo "${SCRIPTNAME}: ${1}." >&2
69 logger -t "${SCRIPTNAME}" "${1}."
70}
71
72daemon() {
73 $1 $2 $3
74}
75
76killproc() {
77 killall $1
78 rm -f $PIDFILE
79}
80
81if which start-stop-daemon >/dev/null 2>&1; then
82 daemon() {
83 start-stop-daemon --start --exec $1 -- $2 $3
84 }
85
86 killproc() {
87 start-stop-daemon --stop --retry 2 --exec $@
88 }
89fi
90
91binary=/usr/sbin/VBoxService
92
93testbinary() {
94 test -x "$binary" || {
95 echo "Cannot run $binary"
96 exit 1
97 }
98}
99
100vboxaddrunning() {
101 lsmod | grep -q "vboxguest[^_-]"
102}
103
104start() {
105 if ! test -f $PIDFILE; then
106 begin "Starting VirtualBox Guest Addition service" console;
107 vboxaddrunning || {
108 echo "VirtualBox Additions module not loaded!"
109 exit 1
110 }
111 testbinary
112 daemon $binary --pidfile $PIDFILE > /dev/null
113 RETVAL=$?
114 succ_msg "VirtualBox Guest Addition service started"
115 fi
116 return $RETVAL
117}
118
119stop() {
120 if test -f $PIDFILE; then
121 begin "Stopping VirtualBox Guest Addition service" console;
122 killproc $binary
123 RETVAL=$?
124 if ! pidof VBoxService > /dev/null 2>&1; then
125 rm -f $PIDFILE
126 succ_msg "VirtualBox Guest Addition service stopped"
127 else
128 fail_msg "VirtualBox Guest Addition service failed to stop"
129 fi
130 fi
131 return $RETVAL
132}
133
134restart() {
135 stop && start
136}
137
138status() {
139 echo -n "Checking for VBoxService"
140 if [ -f $PIDFILE ]; then
141 echo " ...running"
142 else
143 echo " ...not running"
144 fi
145}
146
147case "$1" in
148start)
149 start
150 ;;
151stop)
152 stop
153 ;;
154restart)
155 restart
156 ;;
157status)
158 status
159 ;;
160setup)
161 ;;
162cleanup)
163 ;;
164*)
165 echo "Usage: $0 {start|stop|restart|status}"
166 exit 1
167esac
168
169exit $RETVAL
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