VirtualBox

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

Last change on this file since 438 was 352, checked in by vboxsync, 18 years ago

Linux installer tidy-ups

  • 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 InnoTek Systemberatung GmbH
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 as published by the Free Software Foundation,
13# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14# distribution. VirtualBox OSE is distributed in the hope that it will
15# be useful, but WITHOUT ANY WARRANTY of any kind.
16#
17# If you received this file as part of a commercial VirtualBox
18# distribution, then only the terms of your commercial VirtualBox
19# license agreement apply instead of the previous paragraph.
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"
49elif [ -f /etc/slackware-version ]; then
50 system=slackware
51else
52 echo "$0: Unknown system" 1>&2
53fi
54
55if [ "$system" = redhat ]; then
56 . /etc/init.d/functions
57 fail_msg() {
58 echo_failure
59 echo
60 }
61
62 succ_msg() {
63 echo_success
64 echo
65 }
66fi
67
68if [ "$system" = suse ]; then
69 . /etc/rc.status
70 daemon() {
71 startproc ${1+"$@"}
72 }
73
74 fail_msg() {
75 rc_failed 1
76 rc_status -v
77 }
78
79 succ_msg() {
80 rc_reset
81 rc_status -v
82 }
83fi
84
85if [ "$system" = debian ]; then
86 daemon() {
87 start-stop-daemon --start --exec $1 -- $2
88 }
89
90 killproc() {
91 start-stop-daemon --stop --exec $@
92 }
93
94 fail_msg() {
95 echo " ...fail!"
96 }
97
98 succ_msg() {
99 echo " ...done."
100 }
101fi
102
103if [ "$system" = gentoo ]; then
104 . /sbin/functions.sh
105 daemon() {
106 start-stop-daemon --start --exec $1 -- $2
107 }
108
109 killproc() {
110 start-stop-daemon --stop --exec $@
111 }
112
113 fail_msg() {
114 echo " ...fail!"
115 }
116
117 succ_msg() {
118 echo " ...done."
119 }
120
121 if [ "`which $0`" = "/sbin/rc" ]; then
122 shift
123 fi
124fi
125
126if [ "$system" = slackware ]; then
127 fail_msg() {
128 echo " ...fail!"
129 }
130
131 succ_msg() {
132 echo " ...done."
133 }
134
135 begin() {
136 echo -n $1
137 }
138fi
139
140binary=/usr/sbin/vboxadd-timesync
141
142test -x "$binary" || {
143 echo "Cannot run $binary"
144 exit 1
145}
146
147vboxaddrunning() {
148 lsmod | grep -q vboxadd[^_-]
149}
150
151start() {
152 if ! test -f $PIDFILE; then
153 echo -n "Starting VirtualBox host to guest time synchronisation";
154 vboxaddrunning || {
155 echo "VirtualBox Additions module not loaded!"
156 exit 1
157 }
158 daemon $binary --daemonize
159 RETVAL=$?
160 test $RETVAL -eq 0 && touch $PIDFILE
161 succ_msg
162 fi
163 return $RETVAL
164}
165
166stop() {
167 if test -f $PIDFILE; then
168 echo -n "Stopping VirtualBox host to guest time synchronisation";
169 vboxaddrunning || {
170 echo "VirtualBox Additions module not loaded!"
171 exit 1
172 }
173 killproc $binary
174 RETVAL=$?
175 test $RETVAL -eq 0 && rm -f $PIDFILE
176 succ_msg
177 fi
178 return $RETVAL
179}
180
181restart() {
182 stop && start
183}
184
185dmnstatus() {
186 status vboxadd-timesync
187}
188
189case "$1" in
190start)
191 start
192 ;;
193stop)
194 stop
195 ;;
196restart)
197 restart
198 ;;
199status)
200 dmnstatus
201 ;;
202*)
203 echo "Usage: $0 {start|stop|restart|status}"
204 exit 1
205esac
206
207exit $RETVAL
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette