VirtualBox

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

Last change on this file since 40130 was 40130, checked in by vboxsync, 13 years ago

Main/webservice+doc/manual: Add SSL support to the webservice, and also add an optional parameter which ensures the authentication setting is correct. Update manual and SDK reference.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
Line 
1#!/sbin/sh
2# $Id: smf-vboxwebsrv.sh 40130 2012-02-14 15:17:35Z vboxsync $
3
4# Copyright (C) 2008-2012 Oracle Corporation
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
15#
16# smf-vboxwebsrv method
17#
18# Argument is the method name (start, stop, ...)
19
20. /lib/svc/share/smf_include.sh
21
22VW_OPT="$1"
23VW_EXIT=0
24
25case $VW_OPT in
26 start)
27 if [ ! -x /opt/VirtualBox/vboxwebsrv ]; then
28 echo "ERROR: /opt/VirtualBox/vboxwebsrv does not exist."
29 return $SMF_EXIT_ERR_CONFIG
30 fi
31
32 if [ ! -f /opt/VirtualBox/vboxwebsrv ]; then
33 echo "ERROR: /opt/VirtualBox/vboxwebsrv does not exist."
34 return $SMF_EXIT_ERR_CONFIG
35 fi
36
37 # Get svc configuration
38 VW_USER=`/usr/bin/svcprop -p config/user $SMF_FMRI 2>/dev/null`
39 [ $? != 0 ] && VW_USER=
40 VW_HOST=`/usr/bin/svcprop -p config/host $SMF_FMRI 2>/dev/null`
41 [ $? != 0 ] && VW_HOST=
42 VW_PORT=`/usr/bin/svcprop -p config/port $SMF_FMRI 2>/dev/null`
43 [ $? != 0 ] && VW_PORT=
44 VW_SSL_KEYFILE=`/usr/bin/svcprop -p config/ssl_keyfile $SMF_FMRI 2>/dev/null`
45 [ $? != 0 ] && VW_SSL_KEYFILE=
46 VW_SSL_PASSWORDFILE=`/usr/bin/svcprop -p config/ssl_passwordfile $SMF_FMRI 2>/dev/null`
47 [ $? != 0 ] && VW_SSL_PASSWORDFILE=
48 VW_SSL_CACERT=`/usr/bin/svcprop -p config/ssl_cacert $SMF_FMRI 2>/dev/null`
49 [ $? != 0 ] && VW_SSL_CACERT=
50 VW_SSL_CAPATH=`/usr/bin/svcprop -p config/ssl_capath $SMF_FMRI 2>/dev/null`
51 [ $? != 0 ] && VW_SSL_CAPATH=
52 VW_SSL_DHFILE=`/usr/bin/svcprop -p config/ssl_dhfile $SMF_FMRI 2>/dev/null`
53 [ $? != 0 ] && VW_SSL_DHFILE=
54 VW_SSL_RANDFILE=`/usr/bin/svcprop -p config/ssl_randfile $SMF_FMRI 2>/dev/null`
55 [ $? != 0 ] && VW_SSL_RANDFILE=
56 VW_TIMEOUT=`/usr/bin/svcprop -p config/timeout $SMF_FMRI 2>/dev/null`
57 [ $? != 0 ] && VW_TIMEOUT=
58 VW_CHECK_INTERVAL=`/usr/bin/svcprop -p config/checkinterval $SMF_FMRI 2>/dev/null`
59 [ $? != 0 ] && VW_CHECK_INTERVAL=
60 VW_THREADS=`/usr/bin/svcprop -p config/threads $SMF_FMRI 2>/dev/null`
61 [ $? != 0 ] && VW_THREADS=
62 VW_KEEPALIVE=`/usr/bin/svcprop -p config/keepalive $SMF_FMRI 2>/dev/null`
63 [ $? != 0 ] && VW_KEEPALIVE=
64 VW_AUTHENTICATION=`/usr/bin/svcprop -p config/authentication $SMF_FMRI 2>/dev/null`
65 [ $? != 0 ] && VW_AUTHENTICATION=
66 VW_LOGFILE=`/usr/bin/svcprop -p config/logfile $SMF_FMRI 2>/dev/null`
67 [ $? != 0 ] && VW_LOGFILE=
68 VW_ROTATE=`/usr/bin/svcprop -p config/logrotate $SMF_FMRI 2>/dev/null`
69 [ $? != 0 ] && VW_ROTATE=
70 VW_LOGSIZE=`/usr/bin/svcprop -p config/logsize $SMF_FMRI 2>/dev/null`
71 [ $? != 0 ] && VW_LOGSIZE=
72 VW_LOGINTERVAL=`/usr/bin/svcprop -p config/loginterval $SMF_FMRI 2>/dev/null`
73 [ $? != 0 ] && VW_LOGINTERVAL=
74
75 # Provide sensible defaults
76 [ -z "$VW_USER" ] && VW_USER=root
77 [ -z "$VW_HOST" ] && VW_HOST=localhost
78 [ -z "$VW_PORT" -o "$VW_PORT" -eq 0 ] && VW_PORT=18083
79 [ -z "$VW_TIMEOUT" ] && VW_TIMEOUT=20
80 [ -z "$VW_CHECK_INTERVAL" ] && VW_CHECK_INTERVAL=5
81 [ -z "$VW_THREADS" ] && VW_THREADS=100
82 [ -z "$VW_KEEPALIVE" ] && VW_KEEPALIVE=100
83 [ -z "$VW_ROTATE" ] && VW_ROTATE=10
84 [ -z "$VW_LOGSIZE" ] && VW_LOGSIZE=104857600
85 [ -z "$VW_LOGINTERVAL" ] && VW_LOGINTERVAL=86400
86
87 # Derived and optional settings
88 VW_SSL=
89 [ -n "$VW_SSL_KEYFILE" ] && VW_SSL=--ssl
90 [ -n "$VW_SSL_KEYFILE" ] && VW_SSL_KEYFILE="--keyfile $VW_SSL_KEYFILE"
91 [ -n "$VW_SSL_PASSWORDFILE" ] && VW_SSL_PASSWORDFILE="--passwordfile $VW_SSL_PASSWORDFILE"
92 [ -n "$VW_SSL_CACERT" ] && VW_SSL_CACERT="--cacert $VW_SSL_CACERT"
93 [ -n "$VW_SSL_CAPATH" ] && VW_SSL_CAPATH="--capath $VW_SSL_CAPATH"
94 [ -n "$VW_SSL_DHFILE" ] && VW_SSL_DHFILE="--dhfile $VW_SSL_DHFILE"
95 [ -n "$VW_SSL_RANDFILE" ] && VW_SSL_RANDFILE="--randfile $VW_SSL_RANDFILE"
96 [ -n "$VW_LOGFILE" ] && VW_LOGFILE="--logfile $VW_LOGFILE"
97
98 exec su - "$VW_USER" -c "/opt/VirtualBox/vboxwebsrv --background --host \"$VW_HOST\" --port \"$VW_PORT\" $VW_SSL $VW_SSL_KEYFILE $VW_SSL_PASSWORDFILE $VW_SSL_CACERT $VW_SSL_CAPATH $VW_SSL_DHFILE $VW_SSL_RANDFILE --timeout \"$VW_TIMEOUT\" --check-interval \"$VW_CHECK_INTERVAL\" --threads \"$VW_THREADS\" --keepalive \"$VW_KEEPALIVE\" --authentication \"$VW_AUTHENTICATION\" $VW_LOGFILE --logrotate \"$VW_ROTATE\" --logsize \"$VW_LOGSIZE\" --loginterval \"$VW_LOGINTERVAL\""
99
100 VW_EXIT=$?
101 if [ $VW_EXIT != 0 ]; then
102 echo "vboxwebsrv failed with $VW_EXIT."
103 VW_EXIT=1
104 fi
105 ;;
106 stop)
107 # Kill service contract
108 smf_kill_contract $2 TERM 1
109 ;;
110 *)
111 VW_EXIT=$SMF_EXIT_ERR_CONFIG
112 ;;
113esac
114
115exit $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