VirtualBox

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

Last change on this file since 5 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1#!/bin/bash
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
34# We still have some dependency problems to solve
35#if [ ! "`uname -r | grep '2.4'`" = "" ]; then
36# echo The VirtualBox time synchronization module currently does not work on 2.4 series Linux kernels
37# exit 0
38#fi
39
40system=unknown
41if [ -f /etc/redhat-release ]; then
42 system=redhat
43 PIDFILE="/var/lock/subsys/vboxadd-timesync"
44elif [ -f /etc/SuSE-release ]; then
45 system=suse
46 PIDFILE="/var/lock/subsys/vboxadd-timesync"
47elif [ -f /etc/debian_version ]; then
48 system=debian
49 PIDFILE="/var/run/vboxadd-timesync"
50elif [ -f /etc/gentoo-release ]; then
51 system=gentoo
52 PIDFILE="/var/run/vboxadd-timesync"
53else
54 echo "$0: Unknown system" 1>&2
55fi
56
57if [ $system = redhat ]; then
58 . /etc/init.d/functions
59 fail_msg() {
60 echo_failure
61 echo
62 }
63
64 succ_msg() {
65 echo_success
66 echo
67 }
68fi
69
70if [ $system = suse ]; then
71 . /etc/rc.status
72 daemon() {
73 startproc ${1+"$@"}
74 }
75
76 fail_msg() {
77 rc_failed 1
78 rc_status -v
79 }
80
81 succ_msg() {
82 rc_reset
83 rc_status -v
84 }
85fi
86
87if [ $system = debian ]; then
88 daemon() {
89 start-stop-daemon --start --exec $1 -- $2
90 }
91
92 killproc() {
93 start-stop-daemon --stop --exec $@
94 }
95
96 fail_msg() {
97 echo "...fail!"
98 }
99
100 succ_msg() {
101 echo "...done."
102 }
103fi
104
105if [ $system = gentoo ]; then
106 . /sbin/functions.sh
107 daemon() {
108 start-stop-daemon --start --exec $1 -- $2
109 }
110
111 killproc() {
112 start-stop-daemon --stop --exec $@
113 }
114
115 fail_msg() {
116 echo "...fail!"
117 }
118
119 succ_msg() {
120 echo "...done."
121 }
122
123 if [ "`which $0`" = "/sbin/rc" ]; then
124 shift
125 fi
126fi
127
128binary=/usr/sbin/vboxadd-timesync
129
130test -x $binary || {
131 echo "Cannot run $binary"
132 exit 1
133}
134
135vboxaddrunning() {
136 lsmod | grep -q vboxadd[^_-]
137}
138
139start() {
140 if ! test -f $PIDFILE; then
141 echo -n "Starting vboxadd-timesync ";
142 vboxaddrunning || {
143 echo "VirtualBox Additions module not loaded!"
144 exit 1
145 }
146 daemon $binary --daemonize
147 RETVAL=$?
148 test $RETVAL -eq 0 && touch $PIDFILE
149 succ_msg
150 fi
151 return $RETVAL
152}
153
154stop() {
155 if test -f $PIDFILE; then
156 echo -n "Stopping vboxadd-timesync";
157 vboxaddrunning || {
158 echo "VirtualBox Additions module not loaded!"
159 exit 1
160 }
161 killproc $binary
162 RETVAL=$?
163 test $RETVAL -eq 0 && rm -f $PIDFILE
164 succ_msg
165 fi
166 return $RETVAL
167}
168
169restart() {
170 stop && start
171}
172
173dmnstatus() {
174 status vboxadd-timesync
175}
176
177case "$1" in
178start)
179 start
180 ;;
181stop)
182 stop
183 ;;
184restart)
185 restart
186 ;;
187status)
188 dmnstatus
189 ;;
190*)
191 echo "Usage: $0 {start|stop|restart|status}"
192 exit 1
193esac
194
195exit $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