VirtualBox

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

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

small cosmetical fixes

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 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# Use only with permission.
10#
11
12# chkconfig: 35 35 56
13# description: VirtualBox Additions timesync
14#
15### BEGIN INIT INFO
16# Provides: vboxadd-timesync
17# Required-Start: vboxadd
18# Required-Stop: vboxadd
19# Default-Start: 3 5
20# Default-Stop:
21# Description: VirtualBox Additions timesync
22### END INIT INFO
23
24PATH=$PATH:/bin:/sbin:/usr/sbin
25
26system=unknown
27if [ -f /etc/redhat-release ]; then
28 system=redhat
29 PIDFILE="/var/lock/subsys/vboxadd-timesync"
30elif [ -f /etc/SuSE-release ]; then
31 system=suse
32 PIDFILE="/var/lock/subsys/vboxadd-timesync"
33elif [ -f /etc/debian_version ]; then
34 system=debian
35 PIDFILE="/var/run/vboxadd-timesync"
36elif [ -f /etc/gentoo-release ]; then
37 system=gentoo
38 PIDFILE="/var/run/vboxadd-timesync"
39elif [ -f /etc/slackware-version ]; then
40 system=slackware
41else
42 echo "$0: Unknown system" 1>&2
43fi
44
45if [ "$system" = "redhat" ]; then
46 . /etc/init.d/functions
47 fail_msg() {
48 echo_failure
49 echo
50 }
51
52 succ_msg() {
53 echo_success
54 echo
55 }
56fi
57
58if [ "$system" = "suse" ]; then
59 . /etc/rc.status
60 daemon() {
61 startproc ${1+"$@"}
62 }
63
64 fail_msg() {
65 rc_failed 1
66 rc_status -v
67 }
68
69 succ_msg() {
70 rc_reset
71 rc_status -v
72 }
73fi
74
75if [ "$system" = "debian" ]; then
76 daemon() {
77 start-stop-daemon --start --exec $1 -- $2
78 }
79
80 killproc() {
81 start-stop-daemon --stop --exec $@
82 }
83
84 fail_msg() {
85 echo " ...fail!"
86 }
87
88 succ_msg() {
89 echo " ...done."
90 }
91fi
92
93if [ "$system" = "gentoo" ]; then
94 . /sbin/functions.sh
95 daemon() {
96 start-stop-daemon --start --exec $1 -- $2
97 }
98
99 killproc() {
100 start-stop-daemon --stop --exec $@
101 }
102
103 fail_msg() {
104 echo " ...fail!"
105 }
106
107 succ_msg() {
108 echo " ...done."
109 }
110
111 if [ "`which $0`" = "/sbin/rc" ]; then
112 shift
113 fi
114fi
115
116if [ "$system" = "slackware" ]; then
117 fail_msg() {
118 echo " ...fail!"
119 }
120
121 succ_msg() {
122 echo " ...done."
123 }
124
125 begin() {
126 echo -n "$1"
127 }
128fi
129
130binary=/usr/sbin/vboxadd-timesync
131
132test -x "$binary" || {
133 echo "Cannot run $binary"
134 exit 1
135}
136
137vboxaddrunning() {
138 lsmod | grep -q vboxadd[^_-]
139}
140
141start() {
142 if ! test -f $PIDFILE; then
143 echo -n "Starting VirtualBox host to guest time synchronisation ";
144 vboxaddrunning || {
145 echo "VirtualBox Additions module not loaded!"
146 exit 1
147 }
148 daemon $binary --daemonize
149 RETVAL=$?
150 test $RETVAL -eq 0 && touch $PIDFILE
151 succ_msg
152 fi
153 return $RETVAL
154}
155
156stop() {
157 if test -f $PIDFILE; then
158 echo -n "Stopping VirtualBox host to guest time synchronisation ";
159 vboxaddrunning || {
160 echo "VirtualBox Additions module not loaded!"
161 exit 1
162 }
163 killproc $binary
164 RETVAL=$?
165 test $RETVAL -eq 0 && rm -f $PIDFILE
166 succ_msg
167 fi
168 return $RETVAL
169}
170
171restart() {
172 stop && start
173}
174
175dmnstatus() {
176 status vboxadd-timesync
177}
178
179case "$1" in
180start)
181 start
182 ;;
183stop)
184 stop
185 ;;
186restart)
187 restart
188 ;;
189status)
190 dmnstatus
191 ;;
192*)
193 echo "Usage: $0 {start|stop|restart|status}"
194 exit 1
195esac
196
197exit $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