1 | #!/sbin/sh
|
---|
2 | # $Id: smf-vboxwebsrv.sh 11506 2008-08-20 09:07:36Z vboxsync $
|
---|
3 |
|
---|
4 | # Copyright (C) 2008 Sun Microsystems, Inc.
|
---|
5 | #
|
---|
6 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
7 | # available from http://www.virtualbox.org. This file is free software;
|
---|
8 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
9 | # General Public License (GPL) as published by the Free Software
|
---|
10 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
11 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
12 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
13 | #
|
---|
14 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
15 | # Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
16 | # additional information or have any questions.
|
---|
17 | #
|
---|
18 |
|
---|
19 | #
|
---|
20 | # smf-vboxwebsrv method
|
---|
21 | #
|
---|
22 | # Argument is the method name (start, stop, ...)
|
---|
23 |
|
---|
24 | . /lib/svc/share/smf_include.sh
|
---|
25 |
|
---|
26 | VW_OPT="$1"
|
---|
27 | VW_EXIT=0
|
---|
28 |
|
---|
29 | case $VW_OPT in
|
---|
30 | start)
|
---|
31 | if [ ! -x /opt/VirtualBox/vboxwebsrv ]; then
|
---|
32 | echo "ERROR: /opt/VirtualBox/vboxwebsrv does not exist."
|
---|
33 | return $SMF_EXIT_ERR_CONFIG
|
---|
34 | fi
|
---|
35 |
|
---|
36 | if [ ! -f /opt/VirtualBox/vboxwebsrv ]; then
|
---|
37 | echo "ERROR: /opt/VirtualBox/vboxwebsrv does not exist."
|
---|
38 | return $SMF_EXIT_ERR_CONFIG
|
---|
39 | fi
|
---|
40 |
|
---|
41 | if [ ! -f /opt/VirtualBox/etc/webservice.cfg ]; then
|
---|
42 | echo "ERROR: /opt/VirtualBox/etc/webservice.cfg does not exist."
|
---|
43 | return $SMF_EXIT_ERR_CONFIG
|
---|
44 | fi
|
---|
45 |
|
---|
46 | . /opt/VirtualBox/etc/webservice.cfg
|
---|
47 |
|
---|
48 | [ -z "$VW_USER" ] && VW_USER=root
|
---|
49 | [ -z "$VW_HOST" ] && VW_HOST=localhost
|
---|
50 | [ -z "$VW_PORT" -o "$VW_PORT" -eq 0 ] && VW_PORT=18083
|
---|
51 | su "$VW_USER" -c "LOGNAME=\"$VW_USER\" USER=\"$VW_USER\" /opt/VirtualBox/vboxwebsrv --background --host \"$VW_HOST\" --port \"$VW_PORT\""
|
---|
52 |
|
---|
53 | VW_EXIT=$?
|
---|
54 | if [ $VW_EXIT != 0 ]; then
|
---|
55 | echo "vboxwebsrv failed with $VW_EXIT."
|
---|
56 | VW_EXIT=1
|
---|
57 | fi
|
---|
58 | ;;
|
---|
59 | stop)
|
---|
60 | # Kill service contract
|
---|
61 | smf_kill_contract $2 TERM 1
|
---|
62 | ;;
|
---|
63 | *)
|
---|
64 | VW_EXIT=$SMF_EXIT_ERR_CONFIG
|
---|
65 | ;;
|
---|
66 | esac
|
---|
67 |
|
---|
68 | exit $VW_EXIT
|
---|