VirtualBox

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

Last change on this file since 98715 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

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