smf-vboxwebsrv.sh revision fecf6ed6bcd1186078b5b49423a73c9da7ef2c3b
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync#!/sbin/sh
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync# $Id$
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync# Copyright (C) 2008 Sun Microsystems, Inc.
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync#
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#
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync# Clara, CA 95054 USA or visit http://www.sun.com if you need
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync# additional information or have any questions.
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync#
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync#
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync# smf-vboxwebsrv method
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync#
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync# Argument is the method name (start, stop, ...)
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync. /lib/svc/share/smf_include.sh
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsyncVW_OPT="$1"
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsyncVW_EXIT=0
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsynccase $VW_OPT in
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync start)
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync if [ ! -x /opt/VirtualBox/vboxwebsrv ]; then
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync echo "ERROR: /opt/VirtualBox/vboxwebsrv does not exist."
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync return $SMF_EXIT_ERR_CONFIG
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync fi
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync if [ ! -f /opt/VirtualBox/vboxwebsrv ]; then
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync echo "ERROR: /opt/VirtualBox/vboxwebsrv does not exist."
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync return $SMF_EXIT_ERR_CONFIG
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync fi
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync
9e2988e7dd31e70d37bccca86b186493543e26e8vboxsync if [ ! -f /opt/VirtualBox/etc/webservice.cfg ]; then
9e2988e7dd31e70d37bccca86b186493543e26e8vboxsync echo "ERROR: /opt/VirtualBox/etc/webservice.cfg does not exist."
9e2988e7dd31e70d37bccca86b186493543e26e8vboxsync return $SMF_EXIT_ERR_CONFIG
9e2988e7dd31e70d37bccca86b186493543e26e8vboxsync fi
9e2988e7dd31e70d37bccca86b186493543e26e8vboxsync
9e2988e7dd31e70d37bccca86b186493543e26e8vboxsync . /opt/VirtualBox/etc/webservice.cfg
9e2988e7dd31e70d37bccca86b186493543e26e8vboxsync
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync [ -z "$VW_USER" ] && VW_USER=root
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync [ -z "$VW_HOST" ] && VW_HOST=localhost
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync [ -z "$VW_PORT" -o "$VW_PORT" -eq 0 ] && VW_PORT=18083
fecf6ed6bcd1186078b5b49423a73c9da7ef2c3bvboxsync su "$VW_USER" -c "LOGNAME=\"$VW_USER\" USER=\"$VW_USER\" /opt/VirtualBox/vboxwebsrv --background --host \"$VW_HOST\" --port \"$VW_PORT\""
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync VW_EXIT=$?
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync if [ $VW_EXIT != 0 ]; then
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync echo "vboxwebsrv failed with $VW_EXIT."
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync VW_EXIT=1
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync fi
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync ;;
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync stop)
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync # Kill service contract
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync smf_kill_contract $2 TERM 1
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync ;;
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync *)
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync VW_EXIT=$SMF_EXIT_ERR_CONFIG
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync ;;
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsyncesac
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsync
204c10a47f2896a5472f9477a6f93ccc3a90a3f4vboxsyncexit $VW_EXIT