Subversion Repositories configs

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
192 - 1
#!/usr/bin/env bash
2
#
3
# Copyright 1998-2010 VMware, Inc.  All rights reserved.
4
#
5
# This script manages the VMware USB Arbitrator service
6
#
7
 
8
# Basic support for IRIX style chkconfig
9
# chkconfig: 235 50 8
10
# description: This services starts and stops the USB Arbitrator.
11
 
12
 
13
# Load bootstrapper info
14
. /etc/vmware/bootstrap
15
 
16
# This defines $rc_done and $rc_failed on S.u.S.E.
17
if [ -f /etc/rc.config ]; then
18
   # Don't include the entire file: there could be conflicts
19
   rc_done=`(. /etc/rc.config; echo "$rc_done")`
20
   rc_failed=`(. /etc/rc.config; echo "$rc_failed")`
21
else
22
   # Make sure the ESC byte is literal: Ash does not support echo -e
23
   rc_done=' done'
24
   rc_failed='failed'
25
fi
26
 
27
# This defines echo_success() and echo_failure() on RedHat
28
if [ -r "$INITSCRIPTDIR"'/functions' ]; then
29
   . "$INITSCRIPTDIR"'/functions'
30
fi
31
 
32
vmware_failed() {
33
  if [ "`type -t 'echo_failure' 2>/dev/null`" = 'function' ]; then
34
    echo_failure
35
  else
36
    echo -n "$rc_failed"
37
  fi
38
}
39
 
40
vmware_success() {
41
  if [ "`type -t 'echo_success' 2>/dev/null`" = 'function' ]; then
42
    echo_success
43
  else
44
    echo -n "$rc_done"
45
  fi
46
}
47
 
48
# Execute a macro
49
vmware_exec() {
50
  local msg="$1"  # IN
51
  local func="$2" # IN
52
  shift 2
53
 
54
  # On Caldera 2.2, SIGHUP is sent to all our children when this script exits
55
  # I wanted to use shopt -u huponexit instead but their bash version
56
  # 1.14.7(1) is too old
57
  #
58
  # Ksh does not recognize the SIG prefix in front of a signal name
59
  if [ "$VMWARE_DEBUG" = 'yes' ]; then
60
    (trap '' HUP; "$func" "$@")
61
  else
62
    (trap '' HUP; "$func" "$@") >/dev/null 2>&1
63
  fi
64
  if [ "$?" -gt 0 ]; then
65
    vmware_failed
66
    echo
67
    return 1
68
  fi
69
 
70
  vmware_success
71
  echo
72
  return 0
73
}
74
 
75
# Start the virtual machine USB Arbitrator service
76
vmwareStartUSBArbitrator() {
77
    # The executable checks for already running instances, so it
78
    #  is safe to just run it.
79
    "$BINDIR"/vmware-usbarbitrator
80
}
81
 
82
# Stop the virtual machine USB Arbitrator service
83
vmwareStopUSBArbitrator() {
84
    # The service knows how to stop itself.
85
    "$BINDIR"/vmware-usbarbitrator --kill
86
}
87
 
88
vmwareService() {
89
   case "$1" in
90
      start)
91
         vmware_exec 'VMware USB Arbitrator' vmwareStartUSBArbitrator
92
         exitcode=$(($exitcode + $?))
93
         if [ "$exitcode" -gt 0 ]; then
94
            exit 1
95
         fi
96
         ;;
97
      stop)
98
         vmware_exec 'VMware USB Arbitrator' vmwareStopUSBArbitrator
99
         exitcode=$(($exitcode + $?))
100
         if [ "$exitcode" -gt 0 ]; then
101
            exit 1
102
         fi
103
         ;;
104
      restart)
105
         "$SCRIPTNAME" stop && "$SCRIPTNAME" start
106
         ;;
107
      *)
108
         echo "Usage: $BASENAME {start|stop|restart}"
109
         exit 1
110
   esac
111
}
112
 
113
SCRIPTNAME="$0"
114
BASENAME=`basename "$SCRIPTNAME"`
115
 
116
# Check permissions
117
if [ "`id -ur`" != '0' ]; then
118
   echo 'Error: you must be root.'
119
   echo
120
   exit 1
121
fi
122
 
123
vmwareService "$1"
124
 
125
exit 0