- Timestamp:
- Jan 28, 2008 9:12:41 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Installer/linux/vboxdrv.sh
r5999 r6545 29 29 PATH=$PATH:/bin:/sbin:/usr/sbin 30 30 CONFIG="/etc/vbox/vbox.cfg" 31 . "$CONFIG" 32 VBOXMANAGE="$INSTALL_DIR/VBoxManage" 31 33 32 34 if [ -f /etc/redhat-release ]; then … … 38 40 else 39 41 system=other 42 fi 43 44 if [ -r /etc/default/virtualbox ]; then 45 . /etc/default/virtualbox 40 46 fi 41 47 … … 154 160 fi 155 161 test -z "$maj" && { 156 rmmod $modname 162 rmmod $modname 2>/dev/null 157 163 fail "Cannot locate the VirtualBox device" 158 164 } 159 165 160 mknod -m 0660 $dev c $maj $min || {161 rmmod $modname 166 mknod -m 0660 $dev c $maj $min 2>/dev/null || { 167 rmmod $modname 2>/dev/null 162 168 fail "Cannot create device $dev with major $maj and minor $min" 163 169 } 164 170 fi 165 171 166 chown :$groupname $dev || {167 rmmod $modname 172 chown :$groupname $dev 2>/dev/null || { 173 rmmod $modname 2>/dev/null 168 174 fail "Cannot change owner $groupname for device $dev" 169 175 } … … 183 189 } 184 190 191 # enter the following variables in /etc/default/virtualbox: 192 # SHUTDOWN_USERS="foo bar" 193 # check for running VMs of user foo and user bar 194 # SHUTDOWN=poweroff 195 # SHUTDOWN=acpibutton 196 # SHUTDOWN=savestate 197 # select one of these shutdown methods for running VMs 198 stop_vms() { 199 wait=0 200 for i in $SHUTDOWN_USERS; do 201 # don't create the ipcd directory with wrong permissions! 202 if [ -d /tmp/.vbox-$i-ipc ]; then 203 export VBOX_IPC_SOCKETID="$i" 204 VMS=`$VBOXMANAGE -nologo list runningvms 2>/dev/null` 205 if [ -n "$VMS" ]; then 206 if [ "$SHUTDOWN" = "poweroff" ]; then 207 begin "Powering off remaining VMs " 208 for v in $VMS; do 209 $VBOXMANAGE -nologo controlvm $v poweroff 210 done 211 succ_msg 212 elif [ "$SHUTDOWN" = "acpibutton" ]; then 213 begin "Sending ACPI power button event to remaining VMs " 214 for v in $VMS; do 215 $VBOXMANAGE -nologo controlvm $v acpipowerbutton 216 wait=15 217 done 218 succ_msg 219 elif [ "$SHUTDOWN" = "savestate" ]; then 220 begin "Saving state of remaining VMs " 221 for v in $VMS; do 222 $VBOXMANAGE -nologo controlvm $v savestate 223 done 224 succ_msg 225 fi 226 fi 227 fi 228 done 229 # wait for some seconds when doing ACPI shutdown 230 if [ "$wait" -ne 0 ]; then 231 log_daemon_msg "Waiting for $wait seconds for VM shutdown" 232 sleep $wait 233 log_end_msg 234 fi 235 } 236 185 237 restart() { 186 238 stop && start … … 189 241 190 242 setup() { 191 . "$CONFIG"192 243 stop 193 244 if find /lib/modules/`uname -r` -name "vboxdrv\.*" 2>/dev/null|grep -q vboxdrv; then … … 207 258 if running; then 208 259 echo "VirtualBox kernel module is loaded." 260 for i in $SHUTDOWN_USERS; do 261 # don't create the ipcd directory with wrong permissions! 262 if [ -d /tmp/.vbox-$i-ipc ]; then 263 export VBOX_IPC_SOCKETID="$i" 264 VMS=`$VBOXMANAGE -nologo list runningvms 2>/dev/null` 265 if [ -n "$VMS" ]; then 266 echo "The following VMs are currently running:" 267 for v in $VMS; do 268 echo " $v" 269 done 270 fi 271 fi 272 done 209 273 else 210 274 echo "VirtualBox kernel module is not loaded." … … 217 281 ;; 218 282 stop) 283 stop_vms 219 284 stop 285 ;; 286 stop_vms) 287 stop_vms 220 288 ;; 221 289 restart) … … 229 297 ;; 230 298 *) 231 echo "Usage: $0 {start|stop| restart|status|setup}"299 echo "Usage: $0 {start|stop|stop_vms|restart|status|setup}" 232 300 exit 1 233 301 esac
Note:
See TracChangeset
for help on using the changeset viewer.