smf-vboxwebsrv.sh revision fecf6ed6bcd1186078b5b49423a73c9da7ef2c3b
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster#!/sbin/sh
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster# $Id$
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster# Copyright (C) 2008 Sun Microsystems, Inc.
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster#
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster# This file is part of VirtualBox Open Source Edition (OSE), as
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster# available from http://www.virtualbox.org. This file is free software;
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster# you can redistribute it and/or modify it under the terms of the GNU
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster# General Public License (GPL) as published by the Free Software
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster# Foundation, in version 2 as it comes in the "COPYING" file of the
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster#
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster# Clara, CA 95054 USA or visit http://www.sun.com if you need
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster# additional information or have any questions.
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster#
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster#
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster# smf-vboxwebsrv method
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster#
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster# Argument is the method name (start, stop, ...)
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster. /lib/svc/share/smf_include.sh
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster
0a99555401a033704f1f171baab6db11fb5528f2Allan FosterVW_OPT="$1"
0a99555401a033704f1f171baab6db11fb5528f2Allan FosterVW_EXIT=0
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster
0a99555401a033704f1f171baab6db11fb5528f2Allan Fostercase $VW_OPT in
79943d71bcf8d4933e74f29a1b0e87f8898508cbPeter Major start)
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster if [ ! -x /opt/VirtualBox/vboxwebsrv ]; then
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster echo "ERROR: /opt/VirtualBox/vboxwebsrv does not exist."
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster return $SMF_EXIT_ERR_CONFIG
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster fi
5deb404a3d276c42ef3e4adef5e584211ab1e8ddjeff.schenk
79943d71bcf8d4933e74f29a1b0e87f8898508cbPeter Major if [ ! -f /opt/VirtualBox/vboxwebsrv ]; then
79943d71bcf8d4933e74f29a1b0e87f8898508cbPeter Major echo "ERROR: /opt/VirtualBox/vboxwebsrv does not exist."
79943d71bcf8d4933e74f29a1b0e87f8898508cbPeter Major return $SMF_EXIT_ERR_CONFIG
79943d71bcf8d4933e74f29a1b0e87f8898508cbPeter Major fi
79943d71bcf8d4933e74f29a1b0e87f8898508cbPeter Major
79943d71bcf8d4933e74f29a1b0e87f8898508cbPeter Major if [ ! -f /opt/VirtualBox/etc/webservice.cfg ]; then
79943d71bcf8d4933e74f29a1b0e87f8898508cbPeter Major echo "ERROR: /opt/VirtualBox/etc/webservice.cfg does not exist."
79943d71bcf8d4933e74f29a1b0e87f8898508cbPeter Major return $SMF_EXIT_ERR_CONFIG
79943d71bcf8d4933e74f29a1b0e87f8898508cbPeter Major fi
79943d71bcf8d4933e74f29a1b0e87f8898508cbPeter Major
79943d71bcf8d4933e74f29a1b0e87f8898508cbPeter Major . /opt/VirtualBox/etc/webservice.cfg
79943d71bcf8d4933e74f29a1b0e87f8898508cbPeter Major
79943d71bcf8d4933e74f29a1b0e87f8898508cbPeter Major [ -z "$VW_USER" ] && VW_USER=root
79943d71bcf8d4933e74f29a1b0e87f8898508cbPeter Major [ -z "$VW_HOST" ] && VW_HOST=localhost
79943d71bcf8d4933e74f29a1b0e87f8898508cbPeter Major [ -z "$VW_PORT" -o "$VW_PORT" -eq 0 ] && VW_PORT=18083
79943d71bcf8d4933e74f29a1b0e87f8898508cbPeter Major su "$VW_USER" -c "LOGNAME=\"$VW_USER\" USER=\"$VW_USER\" /opt/VirtualBox/vboxwebsrv --background --host \"$VW_HOST\" --port \"$VW_PORT\""
0a99555401a033704f1f171baab6db11fb5528f2Allan Foster
79943d71bcf8d4933e74f29a1b0e87f8898508cbPeter Major VW_EXIT=$?
5deb404a3d276c42ef3e4adef5e584211ab1e8ddjeff.schenk if [ $VW_EXIT != 0 ]; then
5deb404a3d276c42ef3e4adef5e584211ab1e8ddjeff.schenk echo "vboxwebsrv failed with $VW_EXIT."
5deb404a3d276c42ef3e4adef5e584211ab1e8ddjeff.schenk VW_EXIT=1
5deb404a3d276c42ef3e4adef5e584211ab1e8ddjeff.schenk fi
;;
stop)
# Kill service contract
smf_kill_contract $2 TERM 1
;;
*)
VW_EXIT=$SMF_EXIT_ERR_CONFIG
;;
esac
exit $VW_EXIT