VirtualBox

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

最後變更 在這個檔案從9104是 9104,由 vboxsync 提交於 17 年 前

Linux additions kernel module loader scripts: minor cosmetical fixes

  • 屬性 svn:eol-style 設為 LF
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 4.6 KB
 
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.alldomusa.eu.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
35[ -f /lib/lsb/init-functions ] || NOLSB=yes
36
37if [ -f /etc/redhat-release ]; then
38 system=redhat
39elif [ -f /etc/SuSE-release ]; then
40 system=suse
41elif [ -f /etc/debian_version ]; then
42 system=debian
43elif [ -f /etc/gentoo-release ]; then
44 system=gentoo
45fi
46
47if [ -z "$NOLSB" ]; then
48 . /lib/lsb/init-functions
49 fail_msg() {
50 echo ""
51 log_failure_msg "$1"
52 }
53 succ_msg() {
54 log_end_msg 0
55 }
56 begin_msg() {
57 log_daemon_msg "$@"
58 }
59else
60 if [ "$system" = "redhat" ]; then
61 . /etc/init.d/functions
62 fail_msg() {
63 echo -n " "
64 echo_failure
65 echo
66 echo " ($1)"
67 }
68 succ_msg() {
69 echo -n " "
70 echo_success
71 echo
72 }
73 elif [ "$system" = "suse" ]; then
74 . /etc/rc.status
75 fail_msg() {
76 rc_failed 1
77 rc_status -v
78 echo " ($1)"
79 }
80 succ_msg() {
81 rc_reset
82 rc_status -v
83 }
84 elif [ "$system" = "gentoo" ]; then
85 . /sbin/functions.sh
86 fail_msg() {
87 eerror "$1"
88 }
89 succ_msg() {
90 eend "$?"
91 }
92 begin_msg() {
93 ebegin "$1"
94 }
95 if [ "`which $0`" = "/sbin/rc" ]; then
96 shift
97 fi
98 else
99 fail_msg() {
100 echo " ...failed!"
101 echo " ($1)"
102 }
103 succ_msg() {
104 echo " ...done."
105 }
106 fi
107 if [ "$system" != "gentoo" ]; then
108 begin_msg() {
109 [ -z "${1:-}" ] && return 1
110 if [ -z "${2:-}" ]; then
111 echo -n "$1"
112 else
113 echo -n "$1: $2"
114 fi
115 }
116 fi
117fi
118
119if [ "$system" = "redhat" ]; then
120 PIDFILE="/var/lock/subsys/vboxadd-timesync"
121elif [ "$system" = "suse" ]; then
122 PIDFILE="/var/lock/subsys/vboxadd-timesync"
123 daemon() {
124 startproc ${1+"$@"}
125 }
126elif [ "$system" = "debian" ]; then
127 PIDFILE="/var/run/vboxadd-timesync"
128 daemon() {
129 start-stop-daemon --start --exec $1 -- $2
130 }
131 killproc() {
132 start-stop-daemon --stop --exec $@
133 }
134elif [ "$system" = "gentoo" ]; then
135 PIDFILE="/var/run/vboxadd-timesync"
136 daemon() {
137 start-stop-daemon --start --exec $1 -- $2
138 }
139 killproc() {
140 start-stop-daemon --stop --exec $@
141 }
142else
143 if [ -d /var/run -a -w /var/run ]; then
144 PIDFILE="/var/run/vboxadd-timesync"
145 fi
146fi
147
148binary=/usr/sbin/vboxadd-timesync
149
150test -x "$binary" || {
151 echo "Cannot run $binary"
152 exit 1
153}
154
155vboxaddrunning() {
156 lsmod | grep -q "vboxadd[^_-]"
157}
158
159start() {
160 if ! test -f $PIDFILE; then
161 begin_msg "Starting VirtualBox host to guest time synchronisation";
162 vboxaddrunning || {
163 failure "VirtualBox Additions module not loaded!"
164 }
165 daemon $binary --daemonize
166 RETVAL=$?
167 test $RETVAL -eq 0 && touch $PIDFILE
168 succ_msg
169 fi
170 return $RETVAL
171}
172
173stop() {
174 if test -f $PIDFILE; then
175 begin_msg "Stopping VirtualBox host to guest time synchronisation";
176 vboxaddrunning || {
177 failure "VirtualBox Additions module not loaded!"
178 }
179 killproc $binary
180 RETVAL=$?
181 test $RETVAL -eq 0 && rm -f $PIDFILE
182 succ_msg
183 fi
184 return $RETVAL
185}
186
187restart() {
188 stop && start
189}
190
191dmnstatus() {
192 status vboxadd-timesync
193}
194
195case "$1" in
196start)
197 start
198 ;;
199stop)
200 stop
201 ;;
202restart)
203 restart
204 ;;
205status)
206 dmnstatus
207 ;;
208*)
209 echo "Usage: $0 {start|stop|restart|status}"
210 exit 1
211esac
212
213exit $RETVAL
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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