VirtualBox

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

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

Linux/Solaris installers: Bugfixes.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 6.0 KB
Line 
1#!/sbin/sh
2# $Id: smf-vboxwebsrv.sh 41369 2012-05-21 13:33:10Z 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_AUTH_LIBRARY=`/usr/bin/svcprop -p config/auth_library $SMF_FMRI 2>/dev/null`
57 [ $? != 0 ] && VW_AUTH_LIBRARY=
58 VW_AUTH_PWHASH=`/usr/bin/svcprop -p config/auth_pwhash $SMF_FMRI 2>/dev/null`
59 [ $? != 0 ] && VW_AUTH_PWHASH=
60 VW_TIMEOUT=`/usr/bin/svcprop -p config/timeout $SMF_FMRI 2>/dev/null`
61 [ $? != 0 ] && VW_TIMEOUT=
62 VW_CHECK_INTERVAL=`/usr/bin/svcprop -p config/checkinterval $SMF_FMRI 2>/dev/null`
63 [ $? != 0 ] && VW_CHECK_INTERVAL=
64 VW_THREADS=`/usr/bin/svcprop -p config/threads $SMF_FMRI 2>/dev/null`
65 [ $? != 0 ] && VW_THREADS=
66 VW_KEEPALIVE=`/usr/bin/svcprop -p config/keepalive $SMF_FMRI 2>/dev/null`
67 [ $? != 0 ] && VW_KEEPALIVE=
68 VW_AUTHENTICATION=`/usr/bin/svcprop -p config/authentication $SMF_FMRI 2>/dev/null`
69 [ $? != 0 ] && VW_AUTHENTICATION=
70 VW_LOGFILE=`/usr/bin/svcprop -p config/logfile $SMF_FMRI 2>/dev/null`
71 [ $? != 0 ] && VW_LOGFILE=
72 VW_ROTATE=`/usr/bin/svcprop -p config/logrotate $SMF_FMRI 2>/dev/null`
73 [ $? != 0 ] && VW_ROTATE=
74 VW_LOGSIZE=`/usr/bin/svcprop -p config/logsize $SMF_FMRI 2>/dev/null`
75 [ $? != 0 ] && VW_LOGSIZE=
76 VW_LOGINTERVAL=`/usr/bin/svcprop -p config/loginterval $SMF_FMRI 2>/dev/null`
77 [ $? != 0 ] && VW_LOGINTERVAL=
78
79 # Provide sensible defaults
80 [ -z "$VW_USER" ] && VW_USER=root
81 [ -z "$VW_HOST" ] && VW_HOST=localhost
82 [ -z "$VW_PORT" -o "$VW_PORT" -eq 0 ] && VW_PORT=18083
83 [ -z "$VW_TIMEOUT" ] && VW_TIMEOUT=20
84 [ -z "$VW_CHECK_INTERVAL" ] && VW_CHECK_INTERVAL=5
85 [ -z "$VW_THREADS" ] && VW_THREADS=100
86 [ -z "$VW_KEEPALIVE" ] && VW_KEEPALIVE=100
87 [ -z "$VW_ROTATE" ] && VW_ROTATE=10
88 [ -z "$VW_LOGSIZE" ] && VW_LOGSIZE=104857600
89 [ -z "$VW_LOGINTERVAL" ] && VW_LOGINTERVAL=86400
90
91 # Derived and optional settings
92 VW_SSL=
93 [ -n "$VW_SSL_KEYFILE" ] && VW_SSL=--ssl
94 [ -n "$VW_SSL_KEYFILE" ] && VW_SSL_KEYFILE="--keyfile $VW_SSL_KEYFILE"
95 [ -n "$VW_SSL_PASSWORDFILE" ] && VW_SSL_PASSWORDFILE="--passwordfile $VW_SSL_PASSWORDFILE"
96 [ -n "$VW_SSL_CACERT" ] && VW_SSL_CACERT="--cacert $VW_SSL_CACERT"
97 [ -n "$VW_SSL_CAPATH" ] && VW_SSL_CAPATH="--capath $VW_SSL_CAPATH"
98 [ -n "$VW_SSL_DHFILE" ] && VW_SSL_DHFILE="--dhfile $VW_SSL_DHFILE"
99 [ -n "$VW_SSL_RANDFILE" ] && VW_SSL_RANDFILE="--randfile $VW_SSL_RANDFILE"
100 [ -n "$VW_LOGFILE" ] && VW_LOGFILE="--logfile $VW_LOGFILE"
101
102 # Set authentication method + password hash
103 if [ -n "$VW_AUTH_LIBRARY" ]; then
104 su - "$VW_USER" -c "/opt/VirtualBox/VBoxManage setproperty websrvauthlibrary \"$VW_AUTH_LIBRARY\""
105 if [ $? != 0 ]; then
106 echo "Error $? setting webservice authentication library to $VW_AUTH_LIBRARY"
107 fi
108 fi
109 if [ -n "$VW_AUTH_PWHASH" ]; then
110 su - "$VW_USER" -c "/opt/VirtualBox/VBoxManage setextradata global \"VBoxAuthSimple/users/$VW_USER\" \"$VW_AUTH_PWHASH\""
111 if [ $? != 0 ]; then
112 echo "Error $? setting webservice password hash"
113 fi
114 fi
115
116 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\""
117
118 VW_EXIT=$?
119 if [ $VW_EXIT != 0 ]; then
120 echo "vboxwebsrv failed with $VW_EXIT."
121 VW_EXIT=1
122 fi
123 ;;
124 stop)
125 # Kill service contract
126 smf_kill_contract $2 TERM 1
127 ;;
128 *)
129 VW_EXIT=$SMF_EXIT_ERR_CONFIG
130 ;;
131esac
132
133exit $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