VirtualBox

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

最後變更 在這個檔案從2723是 2530,由 vboxsync 提交於 18 年 前

Updated the Linux installer init scripts to work with unknown distributions

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

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