VirtualBox

source: vbox/trunk/src/VBox/Installer/solaris/smf-vboxwebsrv.sh@ 19200

Last change on this file since 19200 was 19200, checked in by vboxsync, 15 years ago

Solaris/Installer/webservice: bump VBoxSVC sem-id limit to 1024.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1#!/sbin/sh
2# $Id: smf-vboxwebsrv.sh 19200 2009-04-27 09:44:37Z vboxsync $
3
4# Copyright (C) 2008 Sun Microsystems, Inc.
5#
6# This file is part of VirtualBox Open Source Edition (OSE), as
7# available from http://www.virtualbox.org. This file is free software;
8# you can redistribute it and/or modify it under the terms of the GNU
9# General Public License (GPL) as published by the Free Software
10# Foundation, in version 2 as it comes in the "COPYING" file of the
11# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
12# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
13#
14# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
15# Clara, CA 95054 USA or visit http://www.sun.com if you need
16# additional information or have any questions.
17#
18
19#
20# smf-vboxwebsrv method
21#
22# Argument is the method name (start, stop, ...)
23
24. /lib/svc/share/smf_include.sh
25
26VW_OPT="$1"
27VW_EXIT=0
28
29case $VW_OPT in
30 start)
31 if [ ! -x /opt/VirtualBox/vboxwebsrv ]; then
32 echo "ERROR: /opt/VirtualBox/vboxwebsrv does not exist."
33 return $SMF_EXIT_ERR_CONFIG
34 fi
35
36 if [ ! -f /opt/VirtualBox/vboxwebsrv ]; then
37 echo "ERROR: /opt/VirtualBox/vboxwebsrv does not exist."
38 return $SMF_EXIT_ERR_CONFIG
39 fi
40
41 # Get svc configuration
42 VW_USER=`/usr/bin/svcprop -p config/user $SMF_FMRI 2>/dev/null`
43 [ $? != 0 ] && VW_USER=
44 VW_HOST=`/usr/bin/svcprop -p config/host $SMF_FMRI 2>/dev/null`
45 [ $? != 0 ] && VW_HOST=
46 VW_PORT=`/usr/bin/svcprop -p config/port $SMF_FMRI 2>/dev/null`
47 [ $? != 0 ] && VW_PORT=
48 VW_TIMEOUT=`/usr/bin/svcprop -p config/timeout $SMF_FMRI 2>/dev/null`
49 [ $? != 0 ] && VW_TIMEOUT=
50 VW_CHECK_INTERVAL=`/usr/bin/svcprop -p config/checkinterval $SMF_FMRI 2>/dev/null`
51 [ $? != 0 ] && VW_CHECK_INTERVAL=
52
53 # Provide sensible defaults
54 [ -z "$VW_USER" ] && VW_USER=root
55 [ -z "$VW_HOST" ] && VW_HOST=localhost
56 [ -z "$VW_PORT" -o "$VW_PORT" -eq 0 ] && VW_PORT=18083
57 [ -z "$VW_TIMEOUT" ] && VW_TIMEOUT=20
58 [ -z "$VW_CHECK_INTERVAL" ] && VW_CHECK_INTERVAL=5
59 su - "$VW_USER" -c "/opt/VirtualBox/vboxwebsrv --background --host \"$VW_HOST\" --port \"$VW_PORT\" --timeout \"$VW_TIMEOUT\" --check-interval \"$VW_CHECK_INTERVAL\""
60
61 VW_EXIT=$?
62 if [ $VW_EXIT != 0 ]; then
63 echo "vboxwebsrv failed with $VW_EXIT."
64 VW_EXIT=1
65 fi
66
67 # Bump per-process semaphore limit of VBoxSVC
68 PRCTLBIN=`which prctl`
69 if test ! -f "$PRTCLBIN"; then
70 # Wait for VBoxSVC to spawn
71 TRIES=0
72 while test $TRIES -le 3; do
73 VBOXSVC_PID=`ps -eo pid,fname | grep VBoxSVC | grep -v grep | cut -f 1 -d " "`
74 if test $VBOXSVC_PID -ge 0; then
75 $PRCTLBIN -r -n project.max-sem-ids -v 1024 $VBOXSVC_PID
76 if test $? -eq 0; then
77 echo "Successfully bumped VBoxSVC (pid $VBOXSVC_PID) semaphore id limit to 1024."
78 else
79 echo "Failed to bump VBoxSVC (pid $VBOXSVC_PID) semaphore id limit."
80 fi
81 break
82 else
83 sleep 1
84 fi
85 TRIES=`expr $TRIES + 1`
86 done
87 if test $TRIES -eq 3; then
88 echo "Stopped waiting for VBoxSVC to spawn..."
89 echo "Failed to bump VBoxSVC process' semaphore id limit."
90 fi
91 else
92 echo "Failed to find prctl to bump VBoxSVC semaphore id limit."
93 echo "As a result, not more than 99 VMs can be started."
94 fi
95 ;;
96 stop)
97 # Kill service contract
98 smf_kill_contract $2 TERM 1
99 ;;
100 *)
101 VW_EXIT=$SMF_EXIT_ERR_CONFIG
102 ;;
103esac
104
105exit $VW_EXIT
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