VirtualBox

source: vbox/trunk/src/VBox/Installer/solaris/smf-vboxautostart.sh@ 52167

Last change on this file since 52167 was 50295, checked in by vboxsync, 11 years ago

Autostart/Solaris: Fix the autostart script, contributed by kburtch. Make the group configurable (defaulting to staff like before)

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1#!/sbin/sh
2# $Id: smf-vboxautostart.sh 50295 2014-01-30 19:31:51Z vboxsync $
3
4# Copyright (C) 2012-2014 Oracle Corporation
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
15#
16# smf-vboxautostart method
17#
18# Argument is the method name (start, stop, ...)
19
20. /lib/svc/share/smf_include.sh
21
22VW_OPT="$1"
23VW_EXIT=0
24
25case $VW_OPT in
26 start)
27 if [ ! -f /opt/VirtualBox/VBoxAutostart ]; then
28 echo "ERROR: /opt/VirtualBox/VBoxAutostart does not exist."
29 return $SMF_EXIT_ERR_CONFIG
30 fi
31
32 if [ ! -x /opt/VirtualBox/VBoxAutostart ]; then
33 echo "ERROR: /opt/VirtualBox/VBoxAutostart is not exectuable."
34 return $SMF_EXIT_ERR_CONFIG
35 fi
36
37 # Get svc configuration
38 VW_CONFIG=`/usr/bin/svcprop -p config/config $SMF_FMRI 2>/dev/null`
39 [ $? != 0 ] && VW_CONFIG=
40 VW_ROTATE=`/usr/bin/svcprop -p config/logrotate $SMF_FMRI 2>/dev/null`
41 [ $? != 0 ] && VW_ROTATE=
42 VW_LOGSIZE=`/usr/bin/svcprop -p config/logsize $SMF_FMRI 2>/dev/null`
43 [ $? != 0 ] && VW_LOGSIZE=
44 VW_LOGINTERVAL=`/usr/bin/svcprop -p config/loginterval $SMF_FMRI 2>/dev/null`
45 [ $? != 0 ] && VW_LOGINTERVAL=
46 VW_VBOXGROUP=`/usr/bin/svcprop -p config/vboxgroup $SMF_FMRI 2>/dev/null`
47 [ $? != 0 ] && VW_VBOXGROUP=
48
49 # Provide sensible defaults
50 [ -z "$VW_CONFIG" ] && VW_CONFIG=/etc/vbox/autostart.cfg
51 [ -z "$VW_ROTATE" ] && VW_ROTATE=10
52 [ -z "$VW_LOGSIZE" ] && VW_LOGSIZE=104857600
53 [ -z "$VW_LOGINTERVAL" ] && VW_LOGINTERVAL=86400
54 [ -z "$VW_VBOXGROUP" ] && VW_VBOXGROUP=staff
55
56 # Get all users
57 for VW_USER in `logins -g $VW_VBOXGROUP | cut -d' ' -f1`
58 do
59 su - "$VW_USER" -c "/opt/VirtualBox/VBoxAutostart --background --start --config \"$VW_CONFIG\" --logrotate \"$VW_ROTATE\" --logsize \"$VW_LOGSIZE\" --loginterval \"$VW_LOGINTERVAL\""
60
61 VW_EXIT=$?
62 if [ $VW_EXIT != 0 ]; then
63 echo "VBoxAutostart failed with $VW_EXIT."
64 VW_EXIT=1
65 break
66 fi
67 done
68 ;;
69 stop)
70 if [ ! -f /opt/VirtualBox/VBoxAutostart ]; then
71 echo "ERROR: /opt/VirtualBox/VBoxAutostart does not exist."
72 return $SMF_EXIT_ERR_CONFIG
73 fi
74
75 if [ ! -x /opt/VirtualBox/VBoxAutostart ]; then
76 echo "ERROR: /opt/VirtualBox/VBoxAutostart is not executable."
77 return $SMF_EXIT_ERR_CONFIG
78 fi
79
80 # Get svc configuration
81 VW_CONFIG=`/usr/bin/svcprop -p config/config $SMF_FMRI 2>/dev/null`
82 [ $? != 0 ] && VW_CONFIG=
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 VW_VBOXGROUP=`/usr/bin/svcprop -p config/vboxgroup $SMF_FMRI 2>/dev/null`
90 [ $? != 0 ] && VW_VBOXGROUP=
91
92 # Provide sensible defaults
93 [ -z "$VW_CONFIG" ] && VW_CONFIG=/etc/vbox/autostart.cfg
94 [ -z "$VW_ROTATE" ] && VW_ROTATE=10
95 [ -z "$VW_LOGSIZE" ] && VW_LOGSIZE=104857600
96 [ -z "$VW_LOGINTERVAL" ] && VW_LOGINTERVAL=86400
97 [ -z "$VW_VBOXGROUP" ] && VW_VBOXGROUP=staff
98
99 # Get all users
100 for VW_USER in `logins -g $VW_VBOXGROUP | cut -d' ' -f1`
101 do
102 su - "$VW_USER" -c "/opt/VirtualBox/VBoxAutostart --stop --config \"$VW_CONFIG\" --logrotate \"$VW_ROTATE\" --logsize \"$VW_LOGSIZE\" --loginterval \"$VW_LOGINTERVAL\""
103
104 VW_EXIT=$?
105 if [ $VW_EXIT != 0 ]; then
106 echo "VBoxAutostart failed with $VW_EXIT."
107 VW_EXIT=1
108 break
109 fi
110 done
111 ;;
112 *)
113 VW_EXIT=$SMF_EXIT_ERR_CONFIG
114 ;;
115esac
116
117exit $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