VirtualBox

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

Last change on this file since 74186 was 69500, checked in by vboxsync, 7 years ago

*: scm --update-copyright-year

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1#!/sbin/sh
2# $Id: smf-vboxwebsrv.sh 69500 2017-10-28 15:14:05Z vboxsync $
3
4#
5# Copyright (C) 2008-2017 Oracle Corporation
6#
7# This file is part of VirtualBox Open Source Edition (OSE), as
8# available from http://www.virtualbox.org. This file is free software;
9# you can redistribute it and/or modify it under the terms of the GNU
10# General Public License (GPL) as published by the Free Software
11# Foundation, in version 2 as it comes in the "COPYING" file of the
12# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14#
15
16#
17# smf-vboxwebsrv method
18#
19# Argument is the method name (start, stop, ...)
20
21. /lib/svc/share/smf_include.sh
22
23VW_OPT="$1"
24VW_EXIT=0
25
26case $VW_OPT in
27 start)
28 if [ ! -f /opt/VirtualBox/vboxwebsrv ]; then
29 echo "ERROR: /opt/VirtualBox/vboxwebsrv does not exist."
30 return $SMF_EXIT_ERR_CONFIG
31 fi
32
33 if [ ! -x /opt/VirtualBox/vboxwebsrv ]; then
34 echo "ERROR: /opt/VirtualBox/vboxwebsrv is not executable."
35 return $SMF_EXIT_ERR_CONFIG
36 fi
37
38 # Get svc configuration
39 VW_USER=`/usr/bin/svcprop -p config/user $SMF_FMRI 2>/dev/null`
40 [ $? != 0 ] && VW_USER=
41 VW_HOST=`/usr/bin/svcprop -p config/host $SMF_FMRI 2>/dev/null`
42 [ $? != 0 ] && VW_HOST=
43 VW_PORT=`/usr/bin/svcprop -p config/port $SMF_FMRI 2>/dev/null`
44 [ $? != 0 ] && VW_PORT=
45 VW_SSL_KEYFILE=`/usr/bin/svcprop -p config/ssl_keyfile $SMF_FMRI 2>/dev/null`
46 [ $? != 0 ] && VW_SSL_KEYFILE=
47 VW_SSL_PASSWORDFILE=`/usr/bin/svcprop -p config/ssl_passwordfile $SMF_FMRI 2>/dev/null`
48 [ $? != 0 ] && VW_SSL_PASSWORDFILE=
49 VW_SSL_CACERT=`/usr/bin/svcprop -p config/ssl_cacert $SMF_FMRI 2>/dev/null`
50 [ $? != 0 ] && VW_SSL_CACERT=
51 VW_SSL_CAPATH=`/usr/bin/svcprop -p config/ssl_capath $SMF_FMRI 2>/dev/null`
52 [ $? != 0 ] && VW_SSL_CAPATH=
53 VW_SSL_DHFILE=`/usr/bin/svcprop -p config/ssl_dhfile $SMF_FMRI 2>/dev/null`
54 [ $? != 0 ] && VW_SSL_DHFILE=
55 VW_SSL_RANDFILE=`/usr/bin/svcprop -p config/ssl_randfile $SMF_FMRI 2>/dev/null`
56 [ $? != 0 ] && VW_SSL_RANDFILE=
57 VW_AUTH_LIBRARY=`/usr/bin/svcprop -p config/auth_library $SMF_FMRI 2>/dev/null`
58 [ $? != 0 ] && VW_AUTH_LIBRARY=
59 VW_AUTH_PWHASH=`/usr/bin/svcprop -p config/auth_pwhash $SMF_FMRI 2>/dev/null`
60 [ $? != 0 ] && VW_AUTH_PWHASH=
61 VW_TIMEOUT=`/usr/bin/svcprop -p config/timeout $SMF_FMRI 2>/dev/null`
62 [ $? != 0 ] && VW_TIMEOUT=
63 VW_CHECK_INTERVAL=`/usr/bin/svcprop -p config/checkinterval $SMF_FMRI 2>/dev/null`
64 [ $? != 0 ] && VW_CHECK_INTERVAL=
65 VW_THREADS=`/usr/bin/svcprop -p config/threads $SMF_FMRI 2>/dev/null`
66 [ $? != 0 ] && VW_THREADS=
67 VW_KEEPALIVE=`/usr/bin/svcprop -p config/keepalive $SMF_FMRI 2>/dev/null`
68 [ $? != 0 ] && VW_KEEPALIVE=
69 VW_AUTHENTICATION=`/usr/bin/svcprop -p config/authentication $SMF_FMRI 2>/dev/null`
70 [ $? != 0 ] && VW_AUTHENTICATION=
71 VW_LOGFILE=`/usr/bin/svcprop -p config/logfile $SMF_FMRI 2>/dev/null`
72 [ $? != 0 ] && VW_LOGFILE=
73 VW_ROTATE=`/usr/bin/svcprop -p config/logrotate $SMF_FMRI 2>/dev/null`
74 [ $? != 0 ] && VW_ROTATE=
75 VW_LOGSIZE=`/usr/bin/svcprop -p config/logsize $SMF_FMRI 2>/dev/null`
76 [ $? != 0 ] && VW_LOGSIZE=
77 VW_LOGINTERVAL=`/usr/bin/svcprop -p config/loginterval $SMF_FMRI 2>/dev/null`
78 [ $? != 0 ] && VW_LOGINTERVAL=
79
80 # Provide sensible defaults
81 [ -z "$VW_USER" ] && VW_USER=root
82 [ -z "$VW_HOST" ] && VW_HOST=localhost
83 [ -z "$VW_PORT" -o "$VW_PORT" -eq 0 ] && VW_PORT=18083
84 [ -z "$VW_TIMEOUT" ] && VW_TIMEOUT=20
85 [ -z "$VW_CHECK_INTERVAL" ] && VW_CHECK_INTERVAL=5
86 [ -z "$VW_THREADS" ] && VW_THREADS=100
87 [ -z "$VW_KEEPALIVE" ] && VW_KEEPALIVE=100
88 [ -z "$VW_ROTATE" ] && VW_ROTATE=10
89 [ -z "$VW_LOGSIZE" ] && VW_LOGSIZE=104857600
90 [ -z "$VW_LOGINTERVAL" ] && VW_LOGINTERVAL=86400
91
92 # Derived and optional settings
93 VW_SSL=
94 [ -n "$VW_SSL_KEYFILE" ] && VW_SSL=--ssl
95 [ -n "$VW_SSL_KEYFILE" ] && VW_SSL_KEYFILE="--keyfile $VW_SSL_KEYFILE"
96 [ -n "$VW_SSL_PASSWORDFILE" ] && VW_SSL_PASSWORDFILE="--passwordfile $VW_SSL_PASSWORDFILE"
97 [ -n "$VW_SSL_CACERT" ] && VW_SSL_CACERT="--cacert $VW_SSL_CACERT"
98 [ -n "$VW_SSL_CAPATH" ] && VW_SSL_CAPATH="--capath $VW_SSL_CAPATH"
99 [ -n "$VW_SSL_DHFILE" ] && VW_SSL_DHFILE="--dhfile $VW_SSL_DHFILE"
100 [ -n "$VW_SSL_RANDFILE" ] && VW_SSL_RANDFILE="--randfile $VW_SSL_RANDFILE"
101 [ -n "$VW_LOGFILE" ] && VW_LOGFILE="--logfile $VW_LOGFILE"
102
103 # Set authentication method + password hash
104 if [ -n "$VW_AUTH_LIBRARY" ]; then
105 su - "$VW_USER" -c "/opt/VirtualBox/VBoxManage setproperty websrvauthlibrary \"$VW_AUTH_LIBRARY\""
106 if [ $? != 0 ]; then
107 echo "Error $? setting webservice authentication library to $VW_AUTH_LIBRARY"
108 fi
109 fi
110 if [ -n "$VW_AUTH_PWHASH" ]; then
111 su - "$VW_USER" -c "/opt/VirtualBox/VBoxManage setextradata global \"VBoxAuthSimple/users/$VW_USER\" \"$VW_AUTH_PWHASH\""
112 if [ $? != 0 ]; then
113 echo "Error $? setting webservice password hash"
114 fi
115 fi
116
117 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\""
118
119 VW_EXIT=$?
120 if [ $VW_EXIT != 0 ]; then
121 echo "vboxwebsrv failed with $VW_EXIT."
122 VW_EXIT=1
123 fi
124 ;;
125 stop)
126 # Kill service contract
127 smf_kill_contract $2 TERM 1
128 # Be careful: wait 1 second, making sure that everything is cleaned up.
129 smf_kill_contract $2 TERM 1
130 ;;
131 *)
132 VW_EXIT=$SMF_EXIT_ERR_CONFIG
133 ;;
134esac
135
136exit $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