VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/installer/vboxadd-timesync.sh@ 8155

Last change on this file since 8155 was 8155, checked in by vboxsync, 17 years ago

The Big Sun Rebranding Header Change

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1#!/bin/sh
2#
3# innotek VirtualBox
4#
5# Linux Additions timesync daemon init script
6#
7# Copyright (C) 2006-2007 Sun Microsystems, Inc.
8#
9# This file is part of VirtualBox Open Source Edition (OSE), as
10# available from http://www.virtualbox.org. This file is free software;
11# you can redistribute it and/or modify it under the terms of the GNU
12# General Public License (GPL) as published by the Free Software
13# Foundation, in version 2 as it comes in the "COPYING" file of the
14# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16#
17# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18# Clara, CA 95054 USA or visit http://www.sun.com if you need
19# additional information or have any questions.
20#
21
22# chkconfig: 35 35 56
23# description: VirtualBox Additions timesync
24#
25### BEGIN INIT INFO
26# Provides: vboxadd-timesync
27# Required-Start: vboxadd
28# Required-Stop: vboxadd
29# Default-Start: 3 5
30# Default-Stop:
31# Description: VirtualBox Additions timesync
32### END INIT INFO
33
34PATH=$PATH:/bin:/sbin:/usr/sbin
35
36system=unknown
37if [ -f /etc/redhat-release ]; then
38 system=redhat
39 PIDFILE="/var/lock/subsys/vboxadd-timesync"
40elif [ -f /etc/SuSE-release ]; then
41 system=suse
42 PIDFILE="/var/lock/subsys/vboxadd-timesync"
43elif [ -f /etc/debian_version ]; then
44 system=debian
45 PIDFILE="/var/run/vboxadd-timesync"
46elif [ -f /etc/gentoo-release ]; then
47 system=gentoo
48 PIDFILE="/var/run/vboxadd-timesync"
49else
50 system=other
51 if [ -d /var/run -a -w /var/run ]; then
52 PIDFILE="/var/run/vboxadd-timesync"
53 fi
54fi
55
56if [ "$system" = "redhat" ]; then
57 . /etc/init.d/functions
58 fail_msg() {
59 echo_failure
60 echo
61 }
62
63 succ_msg() {
64 echo_success
65 echo
66 }
67fi
68
69if [ "$system" = "suse" ]; then
70 . /etc/rc.status
71 daemon() {
72 startproc ${1+"$@"}
73 }
74
75 fail_msg() {
76 rc_failed 1
77 rc_status -v
78 }
79
80 succ_msg() {
81 rc_reset
82 rc_status -v
83 }
84fi
85
86if [ "$system" = "debian" ]; then
87 daemon() {
88 start-stop-daemon --start --exec $1 -- $2
89 }
90
91 killproc() {
92 start-stop-daemon --stop --exec $@
93 }
94
95 fail_msg() {
96 echo " ...fail!"
97 }
98
99 succ_msg() {
100 echo " ...done."
101 }
102fi
103
104if [ "$system" = "gentoo" ]; then
105 . /sbin/functions.sh
106 daemon() {
107 start-stop-daemon --start --exec $1 -- $2
108 }
109
110 killproc() {
111 start-stop-daemon --stop --exec $@
112 }
113
114 fail_msg() {
115 echo " ...fail!"
116 }
117
118 succ_msg() {
119 echo " ...done."
120 }
121
122 if [ "`which $0`" = "/sbin/rc" ]; then
123 shift
124 fi
125fi
126
127if [ "$system" = "other" ]; then
128 fail_msg() {
129 echo " ...fail!"
130 }
131
132 succ_msg() {
133 echo " ...done."
134 }
135
136 begin() {
137 echo -n "$1"
138 }
139fi
140
141binary=/usr/sbin/vboxadd-timesync
142
143test -x "$binary" || {
144 echo "Cannot run $binary"
145 exit 1
146}
147
148vboxaddrunning() {
149 lsmod | grep -q vboxadd[^_-]
150}
151
152start() {
153 if ! test -f $PIDFILE; then
154 echo -n "Starting VirtualBox host to guest time synchronisation ";
155 vboxaddrunning || {
156 echo "VirtualBox Additions module not loaded!"
157 exit 1
158 }
159 daemon $binary --daemonize
160 RETVAL=$?
161 test $RETVAL -eq 0 && touch $PIDFILE
162 succ_msg
163 fi
164 return $RETVAL
165}
166
167stop() {
168 if test -f $PIDFILE; then
169 echo -n "Stopping VirtualBox host to guest time synchronisation ";
170 vboxaddrunning || {
171 echo "VirtualBox Additions module not loaded!"
172 exit 1
173 }
174 killproc $binary
175 RETVAL=$?
176 test $RETVAL -eq 0 && rm -f $PIDFILE
177 succ_msg
178 fi
179 return $RETVAL
180}
181
182restart() {
183 stop && start
184}
185
186dmnstatus() {
187 status vboxadd-timesync
188}
189
190case "$1" in
191start)
192 start
193 ;;
194stop)
195 stop
196 ;;
197restart)
198 restart
199 ;;
200status)
201 dmnstatus
202 ;;
203*)
204 echo "Usage: $0 {start|stop|restart|status}"
205 exit 1
206esac
207
208exit $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