VirtualBox

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

Last change on this file since 98103 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1#!/sbin/sh
2# $Id: smf-vboxautostart.sh 98103 2023-01-17 14:15:46Z vboxsync $
3
4#
5# Copyright (C) 2012-2023 Oracle and/or its affiliates.
6#
7# This file is part of VirtualBox base platform packages, as
8# available from https://www.virtualbox.org.
9#
10# This program is free software; you can redistribute it and/or
11# modify it under the terms of the GNU General Public License
12# as published by the Free Software Foundation, in version 3 of the
13# License.
14#
15# This program is distributed in the hope that it will be useful, but
16# WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18# General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, see <https://www.gnu.org/licenses>.
22#
23# SPDX-License-Identifier: GPL-3.0-only
24#
25
26#
27# smf-vboxautostart method
28#
29# Argument is the method name (start, stop, ...)
30
31. /lib/svc/share/smf_include.sh
32
33VW_OPT="$1"
34VW_EXIT=0
35
36case $VW_OPT in
37 start)
38 if [ ! -f /opt/VirtualBox/VBoxAutostart ]; then
39 echo "ERROR: /opt/VirtualBox/VBoxAutostart does not exist."
40 return $SMF_EXIT_ERR_CONFIG
41 fi
42
43 if [ ! -x /opt/VirtualBox/VBoxAutostart ]; then
44 echo "ERROR: /opt/VirtualBox/VBoxAutostart is not exectuable."
45 return $SMF_EXIT_ERR_CONFIG
46 fi
47
48 # Get svc configuration
49 VW_CONFIG=`/usr/bin/svcprop -p config/config $SMF_FMRI 2>/dev/null`
50 [ $? != 0 ] && VW_CONFIG=
51 VW_ROTATE=`/usr/bin/svcprop -p config/logrotate $SMF_FMRI 2>/dev/null`
52 [ $? != 0 ] && VW_ROTATE=
53 VW_LOGSIZE=`/usr/bin/svcprop -p config/logsize $SMF_FMRI 2>/dev/null`
54 [ $? != 0 ] && VW_LOGSIZE=
55 VW_LOGINTERVAL=`/usr/bin/svcprop -p config/loginterval $SMF_FMRI 2>/dev/null`
56 [ $? != 0 ] && VW_LOGINTERVAL=
57 VW_VBOXGROUP=`/usr/bin/svcprop -p config/vboxgroup $SMF_FMRI 2>/dev/null`
58 [ $? != 0 ] && VW_VBOXGROUP=
59
60 # Provide sensible defaults
61 [ -z "$VW_CONFIG" ] && VW_CONFIG=/etc/vbox/autostart.cfg
62 [ -z "$VW_ROTATE" ] && VW_ROTATE=10
63 [ -z "$VW_LOGSIZE" ] && VW_LOGSIZE=104857600
64 [ -z "$VW_LOGINTERVAL" ] && VW_LOGINTERVAL=86400
65 [ -z "$VW_VBOXGROUP" ] && VW_VBOXGROUP=staff
66
67 # Get all users
68 for VW_USER in `logins -g $VW_VBOXGROUP | cut -d' ' -f1`
69 do
70 su - "$VW_USER" -c "/opt/VirtualBox/VBoxAutostart --background --start --config \"$VW_CONFIG\" --logrotate \"$VW_ROTATE\" --logsize \"$VW_LOGSIZE\" --loginterval \"$VW_LOGINTERVAL\""
71
72 VW_EXIT=$?
73 if [ $VW_EXIT != 0 ]; then
74 echo "VBoxAutostart failed with $VW_EXIT."
75 VW_EXIT=1
76 break
77 fi
78 done
79 ;;
80 stop)
81 if [ ! -f /opt/VirtualBox/VBoxAutostart ]; then
82 echo "ERROR: /opt/VirtualBox/VBoxAutostart does not exist."
83 return $SMF_EXIT_ERR_CONFIG
84 fi
85
86 if [ ! -x /opt/VirtualBox/VBoxAutostart ]; then
87 echo "ERROR: /opt/VirtualBox/VBoxAutostart is not executable."
88 return $SMF_EXIT_ERR_CONFIG
89 fi
90
91 # Get svc configuration
92 VW_CONFIG=`/usr/bin/svcprop -p config/config $SMF_FMRI 2>/dev/null`
93 [ $? != 0 ] && VW_CONFIG=
94 VW_ROTATE=`/usr/bin/svcprop -p config/logrotate $SMF_FMRI 2>/dev/null`
95 [ $? != 0 ] && VW_ROTATE=
96 VW_LOGSIZE=`/usr/bin/svcprop -p config/logsize $SMF_FMRI 2>/dev/null`
97 [ $? != 0 ] && VW_LOGSIZE=
98 VW_LOGINTERVAL=`/usr/bin/svcprop -p config/loginterval $SMF_FMRI 2>/dev/null`
99 [ $? != 0 ] && VW_LOGINTERVAL=
100 VW_VBOXGROUP=`/usr/bin/svcprop -p config/vboxgroup $SMF_FMRI 2>/dev/null`
101 [ $? != 0 ] && VW_VBOXGROUP=
102
103 # Provide sensible defaults
104 [ -z "$VW_CONFIG" ] && VW_CONFIG=/etc/vbox/autostart.cfg
105 [ -z "$VW_ROTATE" ] && VW_ROTATE=10
106 [ -z "$VW_LOGSIZE" ] && VW_LOGSIZE=104857600
107 [ -z "$VW_LOGINTERVAL" ] && VW_LOGINTERVAL=86400
108 [ -z "$VW_VBOXGROUP" ] && VW_VBOXGROUP=staff
109
110 # Get all users
111 for VW_USER in `logins -g $VW_VBOXGROUP | cut -d' ' -f1`
112 do
113 su - "$VW_USER" -c "/opt/VirtualBox/VBoxAutostart --stop --config \"$VW_CONFIG\" --logrotate \"$VW_ROTATE\" --logsize \"$VW_LOGSIZE\" --loginterval \"$VW_LOGINTERVAL\""
114
115 VW_EXIT=$?
116 if [ $VW_EXIT != 0 ]; then
117 echo "VBoxAutostart failed with $VW_EXIT."
118 VW_EXIT=1
119 break
120 fi
121 done
122 ;;
123 *)
124 VW_EXIT=$SMF_EXIT_ERR_CONFIG
125 ;;
126esac
127
128exit $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