3d3c25c70a412daf8bdd235baf09fa11ff7d2398vboxsync# Copyright (C) 2008-2014 Oracle Corporation
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync# available from http://www.virtualbox.org. This file is free software;
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync# you can redistribute it and/or modify it under the terms of the GNU
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync# General Public License (GPL) as published by the Free Software
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync# smf-vboxwebsrv method
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync# Argument is the method name (start, stop, ...)
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync echo "ERROR: /opt/VirtualBox/vboxwebsrv does not exist."
3d3c25c70a412daf8bdd235baf09fa11ff7d2398vboxsync echo "ERROR: /opt/VirtualBox/vboxwebsrv is not executable."
c315c89581ef4e2ce4240d4346a33d04d0299693vboxsync # Get svc configuration
c315c89581ef4e2ce4240d4346a33d04d0299693vboxsync VW_USER=`/usr/bin/svcprop -p config/user $SMF_FMRI 2>/dev/null`
c315c89581ef4e2ce4240d4346a33d04d0299693vboxsync VW_HOST=`/usr/bin/svcprop -p config/host $SMF_FMRI 2>/dev/null`
c315c89581ef4e2ce4240d4346a33d04d0299693vboxsync VW_PORT=`/usr/bin/svcprop -p config/port $SMF_FMRI 2>/dev/null`
48f33dfd8f615d457106bf76ae2d09b8b9167c1avboxsync VW_SSL_KEYFILE=`/usr/bin/svcprop -p config/ssl_keyfile $SMF_FMRI 2>/dev/null`
48f33dfd8f615d457106bf76ae2d09b8b9167c1avboxsync VW_SSL_PASSWORDFILE=`/usr/bin/svcprop -p config/ssl_passwordfile $SMF_FMRI 2>/dev/null`
48f33dfd8f615d457106bf76ae2d09b8b9167c1avboxsync VW_SSL_CACERT=`/usr/bin/svcprop -p config/ssl_cacert $SMF_FMRI 2>/dev/null`
48f33dfd8f615d457106bf76ae2d09b8b9167c1avboxsync VW_SSL_CAPATH=`/usr/bin/svcprop -p config/ssl_capath $SMF_FMRI 2>/dev/null`
48f33dfd8f615d457106bf76ae2d09b8b9167c1avboxsync VW_SSL_DHFILE=`/usr/bin/svcprop -p config/ssl_dhfile $SMF_FMRI 2>/dev/null`
48f33dfd8f615d457106bf76ae2d09b8b9167c1avboxsync VW_SSL_RANDFILE=`/usr/bin/svcprop -p config/ssl_randfile $SMF_FMRI 2>/dev/null`
9cc8595a52cf33777684fe153fdcdff6182c93dcvboxsync VW_AUTH_LIBRARY=`/usr/bin/svcprop -p config/auth_library $SMF_FMRI 2>/dev/null`
9cc8595a52cf33777684fe153fdcdff6182c93dcvboxsync VW_AUTH_PWHASH=`/usr/bin/svcprop -p config/auth_pwhash $SMF_FMRI 2>/dev/null`
46ae1eadfe6de26dc0114cca2b7a49ce18fcb5bfvboxsync VW_TIMEOUT=`/usr/bin/svcprop -p config/timeout $SMF_FMRI 2>/dev/null`
46ae1eadfe6de26dc0114cca2b7a49ce18fcb5bfvboxsync VW_CHECK_INTERVAL=`/usr/bin/svcprop -p config/checkinterval $SMF_FMRI 2>/dev/null`
48f33dfd8f615d457106bf76ae2d09b8b9167c1avboxsync VW_THREADS=`/usr/bin/svcprop -p config/threads $SMF_FMRI 2>/dev/null`
2371db3c644a3af0577a2c86803ea2f68cc1db15vboxsync VW_KEEPALIVE=`/usr/bin/svcprop -p config/keepalive $SMF_FMRI 2>/dev/null`
48f33dfd8f615d457106bf76ae2d09b8b9167c1avboxsync VW_AUTHENTICATION=`/usr/bin/svcprop -p config/authentication $SMF_FMRI 2>/dev/null`
48f33dfd8f615d457106bf76ae2d09b8b9167c1avboxsync VW_LOGFILE=`/usr/bin/svcprop -p config/logfile $SMF_FMRI 2>/dev/null`
38341ab10424bc12e9eb42f1594927883d99b59fvboxsync VW_ROTATE=`/usr/bin/svcprop -p config/logrotate $SMF_FMRI 2>/dev/null`
38341ab10424bc12e9eb42f1594927883d99b59fvboxsync VW_LOGSIZE=`/usr/bin/svcprop -p config/logsize $SMF_FMRI 2>/dev/null`
38341ab10424bc12e9eb42f1594927883d99b59fvboxsync VW_LOGINTERVAL=`/usr/bin/svcprop -p config/loginterval $SMF_FMRI 2>/dev/null`
c315c89581ef4e2ce4240d4346a33d04d0299693vboxsync # Provide sensible defaults
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync [ -z "$VW_PORT" -o "$VW_PORT" -eq 0 ] && VW_PORT=18083
48f33dfd8f615d457106bf76ae2d09b8b9167c1avboxsync # Derived and optional settings
48f33dfd8f615d457106bf76ae2d09b8b9167c1avboxsync [ -n "$VW_SSL_KEYFILE" ] && VW_SSL_KEYFILE="--keyfile $VW_SSL_KEYFILE"
48f33dfd8f615d457106bf76ae2d09b8b9167c1avboxsync [ -n "$VW_SSL_PASSWORDFILE" ] && VW_SSL_PASSWORDFILE="--passwordfile $VW_SSL_PASSWORDFILE"
48f33dfd8f615d457106bf76ae2d09b8b9167c1avboxsync [ -n "$VW_SSL_CACERT" ] && VW_SSL_CACERT="--cacert $VW_SSL_CACERT"
48f33dfd8f615d457106bf76ae2d09b8b9167c1avboxsync [ -n "$VW_SSL_CAPATH" ] && VW_SSL_CAPATH="--capath $VW_SSL_CAPATH"
48f33dfd8f615d457106bf76ae2d09b8b9167c1avboxsync [ -n "$VW_SSL_DHFILE" ] && VW_SSL_DHFILE="--dhfile $VW_SSL_DHFILE"
48f33dfd8f615d457106bf76ae2d09b8b9167c1avboxsync [ -n "$VW_SSL_RANDFILE" ] && VW_SSL_RANDFILE="--randfile $VW_SSL_RANDFILE"
48f33dfd8f615d457106bf76ae2d09b8b9167c1avboxsync [ -n "$VW_LOGFILE" ] && VW_LOGFILE="--logfile $VW_LOGFILE"
d17bb285d369c5209dd3484e99c6f385896ce901vboxsync # Set authentication method + password hash
d17bb285d369c5209dd3484e99c6f385896ce901vboxsync if [ -n "$VW_AUTH_LIBRARY" ]; then
9cc8595a52cf33777684fe153fdcdff6182c93dcvboxsync su - "$VW_USER" -c "/opt/VirtualBox/VBoxManage setproperty websrvauthlibrary \"$VW_AUTH_LIBRARY\""
d17bb285d369c5209dd3484e99c6f385896ce901vboxsync if [ $? != 0 ]; then
d17bb285d369c5209dd3484e99c6f385896ce901vboxsync echo "Error $? setting webservice authentication library to $VW_AUTH_LIBRARY"
d17bb285d369c5209dd3484e99c6f385896ce901vboxsync if [ -n "$VW_AUTH_PWHASH" ]; then
9cc8595a52cf33777684fe153fdcdff6182c93dcvboxsync su - "$VW_USER" -c "/opt/VirtualBox/VBoxManage setextradata global \"VBoxAuthSimple/users/$VW_USER\" \"$VW_AUTH_PWHASH\""
d17bb285d369c5209dd3484e99c6f385896ce901vboxsync if [ $? != 0 ]; then
d17bb285d369c5209dd3484e99c6f385896ce901vboxsync echo "Error $? setting webservice password hash"
48f33dfd8f615d457106bf76ae2d09b8b9167c1avboxsync 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\""
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync echo "vboxwebsrv failed with $VW_EXIT."
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync # Kill service contract