VirtualBox

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

Last change on this file since 71007 was 69500, checked in by vboxsync, 7 years ago

*: scm --update-copyright-year

  • 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 69500 2017-10-28 15:14:05Z vboxsync $
3
4#
5# Copyright (C) 2012-2017 Oracle Corporation
6#
7# This file is part of VirtualBox Open Source Edition (OSE), as
8# available from http://www.virtualbox.org. This file is free software;
9# you can redistribute it and/or modify it under the terms of the GNU
10# General Public License (GPL) as published by the Free Software
11# Foundation, in version 2 as it comes in the "COPYING" file of the
12# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14#
15
16#
17# smf-vboxautostart method
18#
19# Argument is the method name (start, stop, ...)
20
21. /lib/svc/share/smf_include.sh
22
23VW_OPT="$1"
24VW_EXIT=0
25
26case $VW_OPT in
27 start)
28 if [ ! -f /opt/VirtualBox/VBoxAutostart ]; then
29 echo "ERROR: /opt/VirtualBox/VBoxAutostart does not exist."
30 return $SMF_EXIT_ERR_CONFIG
31 fi
32
33 if [ ! -x /opt/VirtualBox/VBoxAutostart ]; then
34 echo "ERROR: /opt/VirtualBox/VBoxAutostart is not exectuable."
35 return $SMF_EXIT_ERR_CONFIG
36 fi
37
38 # Get svc configuration
39 VW_CONFIG=`/usr/bin/svcprop -p config/config $SMF_FMRI 2>/dev/null`
40 [ $? != 0 ] && VW_CONFIG=
41 VW_ROTATE=`/usr/bin/svcprop -p config/logrotate $SMF_FMRI 2>/dev/null`
42 [ $? != 0 ] && VW_ROTATE=
43 VW_LOGSIZE=`/usr/bin/svcprop -p config/logsize $SMF_FMRI 2>/dev/null`
44 [ $? != 0 ] && VW_LOGSIZE=
45 VW_LOGINTERVAL=`/usr/bin/svcprop -p config/loginterval $SMF_FMRI 2>/dev/null`
46 [ $? != 0 ] && VW_LOGINTERVAL=
47 VW_VBOXGROUP=`/usr/bin/svcprop -p config/vboxgroup $SMF_FMRI 2>/dev/null`
48 [ $? != 0 ] && VW_VBOXGROUP=
49
50 # Provide sensible defaults
51 [ -z "$VW_CONFIG" ] && VW_CONFIG=/etc/vbox/autostart.cfg
52 [ -z "$VW_ROTATE" ] && VW_ROTATE=10
53 [ -z "$VW_LOGSIZE" ] && VW_LOGSIZE=104857600
54 [ -z "$VW_LOGINTERVAL" ] && VW_LOGINTERVAL=86400
55 [ -z "$VW_VBOXGROUP" ] && VW_VBOXGROUP=staff
56
57 # Get all users
58 for VW_USER in `logins -g $VW_VBOXGROUP | cut -d' ' -f1`
59 do
60 su - "$VW_USER" -c "/opt/VirtualBox/VBoxAutostart --background --start --config \"$VW_CONFIG\" --logrotate \"$VW_ROTATE\" --logsize \"$VW_LOGSIZE\" --loginterval \"$VW_LOGINTERVAL\""
61
62 VW_EXIT=$?
63 if [ $VW_EXIT != 0 ]; then
64 echo "VBoxAutostart failed with $VW_EXIT."
65 VW_EXIT=1
66 break
67 fi
68 done
69 ;;
70 stop)
71 if [ ! -f /opt/VirtualBox/VBoxAutostart ]; then
72 echo "ERROR: /opt/VirtualBox/VBoxAutostart does not exist."
73 return $SMF_EXIT_ERR_CONFIG
74 fi
75
76 if [ ! -x /opt/VirtualBox/VBoxAutostart ]; then
77 echo "ERROR: /opt/VirtualBox/VBoxAutostart is not executable."
78 return $SMF_EXIT_ERR_CONFIG
79 fi
80
81 # Get svc configuration
82 VW_CONFIG=`/usr/bin/svcprop -p config/config $SMF_FMRI 2>/dev/null`
83 [ $? != 0 ] && VW_CONFIG=
84 VW_ROTATE=`/usr/bin/svcprop -p config/logrotate $SMF_FMRI 2>/dev/null`
85 [ $? != 0 ] && VW_ROTATE=
86 VW_LOGSIZE=`/usr/bin/svcprop -p config/logsize $SMF_FMRI 2>/dev/null`
87 [ $? != 0 ] && VW_LOGSIZE=
88 VW_LOGINTERVAL=`/usr/bin/svcprop -p config/loginterval $SMF_FMRI 2>/dev/null`
89 [ $? != 0 ] && VW_LOGINTERVAL=
90 VW_VBOXGROUP=`/usr/bin/svcprop -p config/vboxgroup $SMF_FMRI 2>/dev/null`
91 [ $? != 0 ] && VW_VBOXGROUP=
92
93 # Provide sensible defaults
94 [ -z "$VW_CONFIG" ] && VW_CONFIG=/etc/vbox/autostart.cfg
95 [ -z "$VW_ROTATE" ] && VW_ROTATE=10
96 [ -z "$VW_LOGSIZE" ] && VW_LOGSIZE=104857600
97 [ -z "$VW_LOGINTERVAL" ] && VW_LOGINTERVAL=86400
98 [ -z "$VW_VBOXGROUP" ] && VW_VBOXGROUP=staff
99
100 # Get all users
101 for VW_USER in `logins -g $VW_VBOXGROUP | cut -d' ' -f1`
102 do
103 su - "$VW_USER" -c "/opt/VirtualBox/VBoxAutostart --stop --config \"$VW_CONFIG\" --logrotate \"$VW_ROTATE\" --logsize \"$VW_LOGSIZE\" --loginterval \"$VW_LOGINTERVAL\""
104
105 VW_EXIT=$?
106 if [ $VW_EXIT != 0 ]; then
107 echo "VBoxAutostart failed with $VW_EXIT."
108 VW_EXIT=1
109 break
110 fi
111 done
112 ;;
113 *)
114 VW_EXIT=$SMF_EXIT_ERR_CONFIG
115 ;;
116esac
117
118exit $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