VirtualBox

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

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

scm --update-copyright-year

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