#! /bin/sh # Sun VirtualBox # Linux kernel module init script # # Copyright (C) 2006-2009 Sun Microsystems, Inc. # # This file is part of VirtualBox Open Source Edition (OSE), as # available from http://www.virtualbox.org. This file is free software; # you can redistribute it and/or modify it under the terms of the GNU # General Public License (GPL) as published by the Free Software # Foundation, in version 2 as it comes in the "COPYING" file of the # VirtualBox OSE distribution. VirtualBox OSE is distributed in the # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. # # chkconfig: 35 30 70 # description: VirtualBox Linux kernel module # ### BEGIN INIT INFO # Provides: vboxdrv virtualbox # Required-Start: $remote_fs $network # Required-Stop: $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: VirtualBox Linux kernel module ### END INIT INFO source /lib/lsb/init-functions test -d /usr/share/doc/virtualbox -a -x /usr/bin/VBoxHeadless || exit 0 # Include virtualbox defaults if available test -r /etc/default/virtualbox && source /etc/default/virtualbox # set list of all active users if asked to do so if test $SHUTDOWN_USERS = "all" { global SHUTDOWN_USERS := ''"" for i in [/tmp/.vbox-*-ipc] { global SHUTDOWN_USERS := ""$SHUTDOWN_USERS $[echo $i|cut -d'-' -f2]"" } } if test $LOAD_VBOXDRV_MODULE != 1 { log_success_msg "virtualbox disabled; edit /etc/default/virtualbox" exit 0 } proc running { lsmod | grep -q "$1[^_-]" } proc start { log_begin_msg "Loading VirtualBox kernel modules..." if ! running vboxdrv { if ! modprobe vboxdrv > /dev/null !2 > !1 { if ! find /lib/modules/$[uname -r] -name "vboxdrv\.*" !2 >/dev/null|grep -q vboxdrv { log_failure_msg "No suitable module for running kernel found" } else { log_failure_msg "modprobe vboxdrv failed. Please use 'dmesg' to find out why" } log_end_msg 1 return 1 } else { log_progress_msg "vboxdrv" } } if ! running vboxnetflt { if ! modprobe vboxnetflt > /dev/null !2 > !1 { if ! find /lib/modules/$[uname -r] -name "vboxnetflt\.*" !2 >/dev/null|grep -q vboxnetflt { log_failure_msg "No suitable vboxnetflt module for running kernel found" } else { log_failure_msg "modprobe vboxnetflt failed. Please use 'dmesg' to find out why" } log_end_msg 1 return 1 } else { log_progress_msg "vboxnetflt" } } if ! running vboxnetadp { if ! modprobe vboxnetadp > /dev/null !2 > !1 { if ! find /lib/modules/$[uname -r] -name "vboxnetadp\.*" !2 >/dev/null|grep -q vboxnetadp { log_failure_msg "No suitable vboxnetadp module for running kernel found" } else { log_failure_msg "modprobe vboxnetadp failed. Please use 'dmesg' to find out why" } log_end_msg 1 return 1 } else { log_progress_msg "vboxnetadp" } } if ! running vboxpci { if ! modprobe vboxpci > /dev/null !2 > !1 { if ! find /lib/modules/$[uname -r] -name "vboxpci\.*" !2 >/dev/null|grep -q vboxpci { log_failure_msg "No suitable vboxpci module for running kernel found" } else { log_failure_msg "modprobe vboxpci failed. Please use 'dmesg' to find out why" } log_end_msg 1 return 1 } else { log_progress_msg "vboxpci" } } log_end_msg 0 } proc stop { log_begin_msg "Unloading VirtualBox kernel modules..." if running vboxnetadp { if ! rmmod vboxnetadp !2 >/dev/null { log_failure_msg "Cannot unload module vboxnetadp" log_end_msg 1 return 1 } else { log_progress_msg "vboxnetadp" } } if running vboxnetflt { if ! rmmod vboxnetflt !2 >/dev/null { log_failure_msg "Cannot unload module vboxnetflt" log_end_msg 1 return 1 } else { log_progress_msg "vboxnetflt" } } if running vboxpci { if ! rmmod vboxpci !2 >/dev/null { log_failure_msg "Cannot unload module vboxpci" log_end_msg 1 return 1 } else { log_progress_msg "vboxpci" } } if running vboxdrv { if ! rmmod vboxdrv !2 >/dev/null { log_failure_msg "Cannot unload module vboxdrv" log_end_msg 1 return 1 } else { log_progress_msg "vboxdrv" } } log_end_msg 0 } # enter the following variables in /etc/default/virtualbox: # SHUTDOWN_USERS="foo bar" # check for running VMs of user foo and user bar # SHUTDOWN=poweroff # SHUTDOWN=acpibutton # SHUTDOWN=savestate # select one of these shutdown methods for running VMs proc stop_vms { if ! pidof VBoxSVC > /dev/null { return 0 } global wait := '0' for i in [$SHUTDOWN_USERS] { if test -d /tmp/.vbox-$i-ipc { export VBOX_IPC_SOCKETID="$i" global VMS := $[VBoxManage --nologo list runningvms !2 >/dev/null] if test $Status -eq 0 -a -n $VMS { global VMS := $[echo $VMS | sed -e 's/^".*".*{\(.*\)}/\1/] if test $SHUTDOWN = "poweroff" { log_action_msg "Powering off remaining VMs from user $i" for v in [$VMS] { VBoxManage --nologo controlvm $v poweroff global wait := '10' } } elif test $SHUTDOWN = "acpibutton" { log_action_msg "Sending ACPI power button event to remaining VMs from user $i" for v in [$VMS] { VBoxManage --nologo controlvm $v acpipowerbutton global wait := '30' } } elif test $SHUTDOWN = "savestate" { log_action_msg "Saving state of remaining VMs from user $i" for v in [$VMS] { VBoxManage --nologo controlvm $v savestate global wait := '30' } } } } } # wait for some seconds when doing ACPI shutdown if test $wait -ne 0 { log_action_begin_msg "Waiting for $wait seconds for VM shutdown" sleep $wait log_action_end_msg 0 } return 0 } proc dmnstatus { if running vboxdrv && running vboxnetflt && running vboxnetadp && running vboxpci { echo "VirtualBox kernel modules are loaded." for i in [$SHUTDOWN_USERS] { if test -d /tmp/.vbox-$i-ipc { export VBOX_IPC_SOCKETID="$i" global VMS := $[VBoxManage --nologo list runningvms !2 >/dev/null] if test $Status -eq 0 -a -n $VMS { global VMS := $[echo $VMS | sed -e 's/^".*".*{\(.*\)}/\1/] echo "The following VMs are currently running:" for v in [$VMS] { echo " $v" } } } } return 0 } else { echo "VirtualBox kernel module is not loaded." return 3 } } matchstr $1 { start { start } stop { stop_vms && stop } stop_vms { stop_vms } restart|force-reload { stop_vms && stop && start } status { dmnstatus } * { echo "Usage: $0 {start|stop|stop_vms|restart|force-reload|status}" exit 1 } } (CommandList children: [ (C {(.)} {(/lib/lsb/init-functions)}) (AndOr children: [ (C {(test)} {(-d)} {(/usr/share/doc/virtualbox)} {(-a)} {(-x)} {(/usr/bin/VBoxHeadless)}) (C {(exit)} {(0)}) ] op_id: Op_DPipe ) (AndOr children: [ (C {(Lit_Other "[")} {(-r)} {(/etc/default/virtualbox)} {(Lit_Other "]")}) (C {(.)} {(/etc/default/virtualbox)}) ] op_id: Op_DAmp ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$SHUTDOWN_USERS"))} {(Lit_Other "=")} {(DQ (all))} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SHUTDOWN_USERS) op: Equal rhs: {(DQ )} spids: [143] ) ] spids: [143] ) (ForEach iter_name: i iter_words: [{(/tmp/.vbox-) (Lit_Other "*") (-ipc)}] do_arg_iter: False body: (DoGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SHUTDOWN_USERS) op: Equal rhs: { (DQ ($ VSub_Name "$SHUTDOWN_USERS") (" ") (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {($ VSub_Name "$i")}) (C {(cut)} {(-d) (SQ <->)} {(-f2)}) ] negated: False ) ] ) left_token: spids: [166 179] ) ) } spids: [162] ) ] spids: [162] ) ] spids: [159 183] ) spids: [153 157] ) ] spids: [-1 140] ) ] spids: [-1 185] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$LOAD_VBOXDRV_MODULE"))} {(KW_Bang "!") (Lit_Other "=")} {(1)} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(log_success_msg)} {(DQ ("virtualbox disabled; edit /etc/default/virtualbox"))}) (C {(exit)} {(0)}) ] spids: [-1 204] ) ] spids: [-1 218] ) (FuncDef name: running body: (BraceGroup children: [ (Pipeline children: [(C {(lsmod)}) (C {(grep)} {(-q)} {(DQ ($ VSub_Number "$1") ("[^_-]"))})] negated: False ) ] spids: [225] ) spids: [221 224] ) (FuncDef name: start body: (BraceGroup children: [ (C {(log_begin_msg)} {(DQ ("Loading VirtualBox kernel modules..."))}) (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children:[(C {(running)} {(vboxdrv)})] negated:True) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [ (SimpleCommand words: [{(modprobe)} {(vboxdrv)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [280] ) (Redir op_id: Redir_GreatAnd fd: 2 arg_word: {(1)} spids: [284] ) ] ) ] negated: True ) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [ (SimpleCommand words: [ {(find)} {(/lib/modules/) (CommandSubPart command_list: (CommandList children: [(C {(uname)} {(-r)})] ) left_token: spids: [298 302] ) } {(-name)} { (DQ (vboxdrv) (EscapedLiteralPart token: ) ("*") ) } ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [312] ) ] ) (C {(grep)} {(-q)} {(vboxdrv)}) ] negated: True ) terminator: ) ] action: [ (C {(log_failure_msg)} {(DQ ("No suitable module for running kernel found"))} ) ] spids: [-1 322] ) ] else_action: [ (C {(log_failure_msg)} { (DQ ( "modprobe vboxdrv failed. Please use 'dmesg' to find out why" ) ) } ) ] spids: [332 342] ) (C {(log_end_msg)} {(1)}) (ControlFlow token: arg_word: {(1)} ) ] spids: [-1 288] ) ] else_action: [(C {(log_progress_msg)} {(DQ (vboxdrv))})] spids: [355 365] ) ] spids: [-1 269] ) ] spids: [-1 368] ) (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children:[(C {(running)} {(vboxnetflt)})] negated:True) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [ (SimpleCommand words: [{(modprobe)} {(vboxnetflt)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [393] ) (Redir op_id: Redir_GreatAnd fd: 2 arg_word: {(1)} spids: [397] ) ] ) ] negated: True ) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [ (SimpleCommand words: [ {(find)} {(/lib/modules/) (CommandSubPart command_list: (CommandList children: [(C {(uname)} {(-r)})] ) left_token: spids: [411 415] ) } {(-name)} { (DQ (vboxnetflt) (EscapedLiteralPart token: ) ("*") ) } ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [425] ) ] ) (C {(grep)} {(-q)} {(vboxnetflt)}) ] negated: True ) terminator: ) ] action: [ (C {(log_failure_msg)} { (DQ ( "No suitable vboxnetflt module for running kernel found" ) ) } ) ] spids: [-1 435] ) ] else_action: [ (C {(log_failure_msg)} { (DQ ( "modprobe vboxnetflt failed. Please use 'dmesg' to find out why" ) ) } ) ] spids: [445 455] ) (C {(log_end_msg)} {(1)}) (ControlFlow token: arg_word: {(1)} ) ] spids: [-1 401] ) ] else_action: [(C {(log_progress_msg)} {(DQ (vboxnetflt))})] spids: [468 478] ) ] spids: [-1 382] ) ] spids: [-1 481] ) (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children:[(C {(running)} {(vboxnetadp)})] negated:True) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [ (SimpleCommand words: [{(modprobe)} {(vboxnetadp)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [506] ) (Redir op_id: Redir_GreatAnd fd: 2 arg_word: {(1)} spids: [510] ) ] ) ] negated: True ) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [ (SimpleCommand words: [ {(find)} {(/lib/modules/) (CommandSubPart command_list: (CommandList children: [(C {(uname)} {(-r)})] ) left_token: spids: [524 528] ) } {(-name)} { (DQ (vboxnetadp) (EscapedLiteralPart token: ) ("*") ) } ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [538] ) ] ) (C {(grep)} {(-q)} {(vboxnetadp)}) ] negated: True ) terminator: ) ] action: [ (C {(log_failure_msg)} { (DQ ( "No suitable vboxnetadp module for running kernel found" ) ) } ) ] spids: [-1 548] ) ] else_action: [ (C {(log_failure_msg)} { (DQ ( "modprobe vboxnetadp failed. Please use 'dmesg' to find out why" ) ) } ) ] spids: [558 568] ) (C {(log_end_msg)} {(1)}) (ControlFlow token: arg_word: {(1)} ) ] spids: [-1 514] ) ] else_action: [(C {(log_progress_msg)} {(DQ (vboxnetadp))})] spids: [581 591] ) ] spids: [-1 495] ) ] spids: [-1 594] ) (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children:[(C {(running)} {(vboxpci)})] negated:True) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [ (SimpleCommand words: [{(modprobe)} {(vboxpci)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [619] ) (Redir op_id: Redir_GreatAnd fd: 2 arg_word: {(1)} spids: [623] ) ] ) ] negated: True ) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [ (SimpleCommand words: [ {(find)} {(/lib/modules/) (CommandSubPart command_list: (CommandList children: [(C {(uname)} {(-r)})] ) left_token: spids: [637 641] ) } {(-name)} { (DQ (vboxpci) (EscapedLiteralPart token: ) ("*") ) } ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [651] ) ] ) (C {(grep)} {(-q)} {(vboxpci)}) ] negated: True ) terminator: ) ] action: [ (C {(log_failure_msg)} {(DQ ("No suitable vboxpci module for running kernel found"))} ) ] spids: [-1 661] ) ] else_action: [ (C {(log_failure_msg)} { (DQ ( "modprobe vboxpci failed. Please use 'dmesg' to find out why" ) ) } ) ] spids: [671 681] ) (C {(log_end_msg)} {(1)}) (ControlFlow token: arg_word: {(1)} ) ] spids: [-1 627] ) ] else_action: [(C {(log_progress_msg)} {(DQ (vboxpci))})] spids: [694 704] ) ] spids: [-1 608] ) ] spids: [-1 707] ) (C {(log_end_msg)} {(0)}) ] spids: [248] ) spids: [244 247] ) (FuncDef name: stop body: (BraceGroup children: [ (C {(log_begin_msg)} {(DQ ("Unloading VirtualBox kernel modules..."))}) (If arms: [ (if_arm cond: [(Sentence child:(C {(running)} {(vboxnetadp)}) terminator:)] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [ (SimpleCommand words: [{(rmmod)} {(vboxnetadp)}] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [753] ) ] ) ] negated: True ) terminator: ) ] action: [ (C {(log_failure_msg)} {(DQ ("Cannot unload module vboxnetadp"))}) (C {(log_end_msg)} {(1)}) (ControlFlow token: arg_word: {(1)} ) ] spids: [-1 757] ) ] else_action: [(C {(log_progress_msg)} {(DQ (vboxnetadp))})] spids: [777 787] ) ] spids: [-1 742] ) ] spids: [-1 790] ) (If arms: [ (if_arm cond: [(Sentence child:(C {(running)} {(vboxnetflt)}) terminator:)] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [ (SimpleCommand words: [{(rmmod)} {(vboxnetflt)}] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [813] ) ] ) ] negated: True ) terminator: ) ] action: [ (C {(log_failure_msg)} {(DQ ("Cannot unload module vboxnetflt"))}) (C {(log_end_msg)} {(1)}) (ControlFlow token: arg_word: {(1)} ) ] spids: [-1 817] ) ] else_action: [(C {(log_progress_msg)} {(DQ (vboxnetflt))})] spids: [837 847] ) ] spids: [-1 802] ) ] spids: [-1 850] ) (If arms: [ (if_arm cond: [(Sentence child:(C {(running)} {(vboxpci)}) terminator:)] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [ (SimpleCommand words: [{(rmmod)} {(vboxpci)}] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [873] ) ] ) ] negated: True ) terminator: ) ] action: [ (C {(log_failure_msg)} {(DQ ("Cannot unload module vboxpci"))}) (C {(log_end_msg)} {(1)}) (ControlFlow token: arg_word: {(1)} ) ] spids: [-1 877] ) ] else_action: [(C {(log_progress_msg)} {(DQ (vboxpci))})] spids: [897 907] ) ] spids: [-1 862] ) ] spids: [-1 910] ) (If arms: [ (if_arm cond: [(Sentence child:(C {(running)} {(vboxdrv)}) terminator:)] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [ (SimpleCommand words: [{(rmmod)} {(vboxdrv)}] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [933] ) ] ) ] negated: True ) terminator: ) ] action: [ (C {(log_failure_msg)} {(DQ ("Cannot unload module vboxdrv"))}) (C {(log_end_msg)} {(1)}) (ControlFlow token: arg_word: {(1)} ) ] spids: [-1 937] ) ] else_action: [(C {(log_progress_msg)} {(DQ (vboxdrv))})] spids: [957 967] ) ] spids: [-1 922] ) ] spids: [-1 970] ) (C {(log_end_msg)} {(0)}) ] spids: [723] ) spids: [719 722] ) (FuncDef name: stop_vms body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [ (SimpleCommand words: [{(pidof)} {(VBoxSVC)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [1018] ) ] ) ] negated: True ) terminator: ) ] action: [(ControlFlow token: arg_word:{(0)})] spids: [-1 1023] ) ] spids: [-1 1031] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:wait) op:Equal rhs:{(0)} spids:[1036])] spids: [1036] ) (ForEach iter_name: i iter_words: [{($ VSub_Name "$SHUTDOWN_USERS")}] do_arg_iter: False body: (DoGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-d)} {(/tmp/.vbox-) ($ VSub_Name "$i") (-ipc)} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(export)} {(Lit_VarLike "VBOX_IPC_SOCKETID=") (DQ ($ VSub_Name "$i"))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:VMS) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (SimpleCommand words: [ {(VBoxManage)} {(--nologo)} {(list)} {(runningvms)} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [1088] ) ] ) ] ) left_token: spids: [1079 1090] ) } spids: [1078] ) ] spids: [1078] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {($ VSub_QMark "$?")} {(-eq)} {(0)} {(-a)} {(-n)} {(DQ ($ VSub_Name "$VMS"))} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:VMS) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {(DQ ($ VSub_Name "$VMS"))}) (C {(sed)} {(-e)} {(SQ <"s/^\".*\".*{\\(.*\\)}/\\1/">)} ) ] negated: False ) ] ) left_token: spids: [1118 1134] ) } spids: [1117] ) ] spids: [1117] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$SHUTDOWN"))} {(Lit_Other "=")} {(DQ (poweroff))} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(log_action_msg)} { (DQ ("Powering off remaining VMs from user ") ($ VSub_Name "$i") ) } ) (ForEach iter_name: v iter_words: [{($ VSub_Name "$VMS")}] do_arg_iter: False body: (DoGroup children: [ (C {(VBoxManage)} {(--nologo)} {(controlvm)} {($ VSub_Name "$v")} {(poweroff)} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:wait) op: Equal rhs: {(10)} spids: [1188] ) ] spids: [1188] ) ] spids: [1174 1192] ) spids: [1170 1172] ) ] spids: [-1 1154] ) (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$SHUTDOWN"))} {(Lit_Other "=")} {(DQ (acpibutton))} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(log_action_msg)} { (DQ ( "Sending ACPI power button event to remaining VMs from user " ) ($ VSub_Name "$i") ) } ) (ForEach iter_name: v iter_words: [{($ VSub_Name "$VMS")}] do_arg_iter: False body: (DoGroup children: [ (C {(VBoxManage)} {(--nologo)} {(controlvm)} {($ VSub_Name "$v")} {(acpipowerbutton)} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:wait) op: Equal rhs: {(30)} spids: [1246] ) ] spids: [1246] ) ] spids: [1232 1250] ) spids: [1228 1230] ) ] spids: [1195 1212] ) (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$SHUTDOWN"))} {(Lit_Other "=")} {(DQ (savestate))} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(log_action_msg)} { (DQ ("Saving state of remaining VMs from user ") ($ VSub_Name "$i") ) } ) (ForEach iter_name: v iter_words: [{($ VSub_Name "$VMS")}] do_arg_iter: False body: (DoGroup children: [ (C {(VBoxManage)} {(--nologo)} {(controlvm)} {($ VSub_Name "$v")} {(savestate)} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:wait) op: Equal rhs: {(30)} spids: [1304] ) ] spids: [1304] ) ] spids: [1290 1308] ) spids: [1286 1288] ) ] spids: [1253 1270] ) ] spids: [-1 1311] ) ] spids: [-1 1114] ) ] spids: [-1 1314] ) ] spids: [-1 1067] ) ] spids: [-1 1317] ) ] spids: [1051 1320] ) spids: [1047 1049] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$wait"))} {(-ne)} {(0)} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(log_action_begin_msg)} {(DQ ("Waiting for ") ($ VSub_Name "$wait") (" seconds for VM shutdown"))} ) (C {(sleep)} {($ VSub_Name "$wait")}) (C {(log_action_end_msg)} {(0)}) ] spids: [-1 1344] ) ] spids: [-1 1366] ) (ControlFlow token: arg_word:{(0)}) ] spids: [1007] ) spids: [1003 1006] ) (FuncDef name: dmnstatus body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (AndOr children: [ (C {(running)} {(vboxdrv)}) (AndOr children: [ (C {(running)} {(vboxnetflt)}) (AndOr children: [(C {(running)} {(vboxnetadp)}) (C {(running)} {(vboxpci)})] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) terminator: ) ] action: [ (C {(echo)} {(DQ ("VirtualBox kernel modules are loaded."))}) (ForEach iter_name: i iter_words: [{($ VSub_Name "$SHUTDOWN_USERS")}] do_arg_iter: False body: (DoGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-d)} {(/tmp/.vbox-) ($ VSub_Name "$i") (-ipc)} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(export)} {(Lit_VarLike "VBOX_IPC_SOCKETID=") (DQ ($ VSub_Name "$i"))} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:VMS) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (SimpleCommand words: [ {(VBoxManage)} {(--nologo)} {(list)} {(runningvms)} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [1466] ) ] ) ] ) left_token: spids: [1457 1468] ) } spids: [1456] ) ] spids: [1456] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {($ VSub_QMark "$?")} {(-eq)} {(0)} {(-a)} {(-n)} {(DQ ($ VSub_Name "$VMS"))} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:VMS) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {(DQ ($ VSub_Name "$VMS"))} ) (C {(sed)} {(-e)} { (SQ < "s/^\".*\".*{\\(.*\\)}/\\1/" > ) } ) ] negated: False ) ] ) left_token: spids: [1496 1512] ) } spids: [1495] ) ] spids: [1495] ) (C {(echo)} {(DQ ("The following VMs are currently running:"))} ) (ForEach iter_name: v iter_words: [{($ VSub_Name "$VMS")}] do_arg_iter: False body: (DoGroup children: [ (C {(echo)} {(DQ (" ") ($ VSub_Name "$v"))}) ] spids: [1531 1542] ) spids: [1527 1529] ) ] spids: [-1 1492] ) ] spids: [-1 1545] ) ] spids: [-1 1445] ) ] spids: [-1 1548] ) ] spids: [1429 1551] ) spids: [1425 1427] ) (ControlFlow token: arg_word:{(0)}) ] spids: [-1 1408] ) ] else_action: [ (C {(echo)} {(DQ ("VirtualBox kernel module is not loaded."))}) (ControlFlow token: arg_word:{(3)}) ] spids: [1559 1574] ) ] spids: [1380] ) spids: [1376 1379] ) (Case to_match: {(DQ ($ VSub_Number "$1"))} arms: [ (case_arm pat_list:[{(start)}] action:[(C {(start)})] spids:[158715881594-1]) (case_arm pat_list: [{(stop)}] action: [(AndOr children:[(C {(stop_vms)})(C {(stop)})] op_id:Op_DAmp)] spids: [1596 1597 1607 -1] ) (case_arm pat_list:[{(stop_vms)}] action:[(C {(stop_vms)})] spids:[160916101616-1]) (case_arm pat_list: [{(restart)} {(force-reload)}] action: [ (AndOr children: [(C {(stop_vms)}) (AndOr children:[(C {(stop)})(C {(start)})] op_id:Op_DAmp)] op_id: Op_DAmp ) ] spids: [1618 1621 1635 -1] ) (case_arm pat_list:[{(status)}] action:[(C {(dmnstatus)})] spids:[163716381644-1]) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (C {(echo)} { (DQ ("Usage: ") ($ VSub_Number "$0") (" {start|stop|stop_vms|restart|force-reload|status}") ) } ) (C {(exit)} {(1)}) ] spids: [1646 1647 -1 1663] ) ] spids: [1579 1585 1663] ) ] )