Subversion Repositories configs

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 - 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 echo_success() and echo_failure() on RedHat
17
if [ -r "$INITSCRIPTDIR"'/functions' ]; then
18
   . "$INITSCRIPTDIR"'/functions'
19
fi
20
 
21
vmware_failed() {
22
  if [ "`type -t 'echo_failure' 2>/dev/null`" = 'function' ]; then
23
    echo_failure
24
  else
25
    echo -n "$rc_failed"
26
  fi
27
}
28
 
29
vmware_success() {
30
  if [ "`type -t 'echo_success' 2>/dev/null`" = 'function' ]; then
31
    echo_success
32
  else
33
    echo -n "$rc_done"
34
  fi
35
}
36
 
37
# Execute a macro
38
vmware_exec() {
39
  local msg="$1"  # IN
40
  local func="$2" # IN
41
  shift 2
42
 
43
  # On Caldera 2.2, SIGHUP is sent to all our children when this script exits
44
  # I wanted to use shopt -u huponexit instead but their bash version
45
  # 1.14.7(1) is too old
46
  #
47
  # Ksh does not recognize the SIG prefix in front of a signal name
48
  if [ "$VMWARE_DEBUG" = 'yes' ]; then
49
    (trap '' HUP; "$func" "$@")
50
  else
51
    (trap '' HUP; "$func" "$@") >/dev/null 2>&1
52
  fi
53
  if [ "$?" -gt 0 ]; then
54
    vmware_failed
55
    echo
56
    return 1
57
  fi
58
 
59
  vmware_success
60
  echo
61
  return 0
62
}
63
 
64
# Start the virtual machine USB Arbitrator service
65
vmwareStartUSBArbitrator() {
66
    # The executable checks for already running instances, so it
67
    #  is safe to just run it.
68
    "$BINDIR"/vmware-usbarbitrator
69
}
70
 
71
# Stop the virtual machine USB Arbitrator service
72
vmwareStopUSBArbitrator() {
73
    # The service knows how to stop itself.
74
    "$BINDIR"/vmware-usbarbitrator --kill
75
}
76
 
77
vmwareService() {
78
   case "$1" in
79
      start)
80
         vmware_exec 'VMware USB Arbitrator' vmwareStartUSBArbitrator
81
         exitcode=$(($exitcode + $?))
82
         if [ "$exitcode" -gt 0 ]; then
83
            exit 1
84
         fi
85
         ;;
86
      stop)
87
         vmware_exec 'VMware USB Arbitrator' vmwareStopUSBArbitrator
88
         exitcode=$(($exitcode + $?))
89
         if [ "$exitcode" -gt 0 ]; then
90
            exit 1
91
         fi
92
         ;;
93
      restart)
94
         "$SCRIPTNAME" stop && "$SCRIPTNAME" start
95
         ;;
96
      *)
97
         echo "Usage: $BASENAME {start|stop|restart}"
98
         exit 1
99
   esac
100
}
101
 
102
SCRIPTNAME="$0"
103
BASENAME=`basename "$SCRIPTNAME"`
104
 
105
# Check permissions
106
if [ "`id -ur`" != '0' ]; then
107
   echo 'Error: you must be root.'
108
   echo
109
   exit 1
110
fi
111
 
112
vmwareService "$1"
113
 
114
exit 0