VirtualBox

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

Last change on this file since 15926 was 15926, checked in by vboxsync, 16 years ago

Installers/Linux: cosmetic patch for init scripts for ArchLinux, contributed by ColdShine

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