X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=vboxautostart.init;h=f9ce4cb02a2f4e207579fc333d451dc913858ec5;hb=fdf4c273d291c0394f5499ccbc0a107fb78ff3f5;hp=a41aa3cb2c78a8ca5f771517f375a45afa72bf75;hpb=2a57ea39cca40db99f04e515f868906e250aa87d;p=packages%2FVirtualBox.git diff --git a/vboxautostart.init b/vboxautostart.init index a41aa3c..f9ce4cb 100755 --- a/vboxautostart.init +++ b/vboxautostart.init @@ -11,8 +11,9 @@ # Source function library . /etc/rc.d/init.d/functions -VBOXAUTOSTART_DB=/etc/vbox +VBOXAUTOSTART_DB=/etc/vbox/autostart VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg +VBOXAUTOSTART=@INSTALL_DIR@/VBoxAutostart # Get service config - may override defaults [ -f /etc/sysconfig/virtualbox ] && . /etc/sysconfig/virtualbox @@ -20,6 +21,7 @@ VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg start_daemon() { local user="$1" shift + show "VMs for user '%s'" "$user" daemon --user $user "$@" } @@ -30,20 +32,21 @@ start() { return fi - [ -z "$VBOXAUTOSTART_DB" ] && exit 0 - [ -z "$VBOXAUTOSTART_CONFIG" ] && exit 0 + [ -z "$VBOXAUTOSTART_DB" ] && exit 0 + [ -z "$VBOXAUTOSTART_CONFIG" ] && exit 0 - msg_starting "Starting VirtualBox VMs configured for autostart" + msg_starting "VirtualBox VMs configured for autostart"; busy; echo - local user PARAMS="--background --start --config $VBOXAUTOSTART_CONFIG" + local file user PARAMS="--background --start --config $VBOXAUTOSTART_CONFIG" - # prevent inheriting this setting to VBoxSVC - unset VBOX_RELEASE_LOG_DEST + # prevent inheriting this setting to VBoxSVC + unset VBOX_RELEASE_LOG_DEST - for user in `ls $VBOXAUTOSTART_DB/*.start 2>/dev/null`; do - user=$(basename $user | sed -ne "s/\(.*\).start/\1/p") - start_daemon $user $binary $PARAMS - done + for file in $VBOXAUTOSTART_DB/*.start; do + test -f "$file" || continue + user=${file##*/}; user=${user%.start} + start_daemon $user $VBOXAUTOSTART $PARAMS + done [ $RETVAL -eq 0 ] && touch /var/lock/subsys/vboxautostart } @@ -54,21 +57,22 @@ stop() { return fi - [ -z "$VBOXAUTOSTART_DB" ] && exit 0 - [ -z "$VBOXAUTOSTART_CONFIG" ] && exit 0 + [ -z "$VBOXAUTOSTART_DB" ] && exit 0 + [ -z "$VBOXAUTOSTART_CONFIG" ] && exit 0 # Stop daemons. - msg_stopping "VirtualBox Autostart" + msg_stopping "VirtualBox Autostart"; busy; echo - local user PARAMS="--stop --config $VBOXAUTOSTART_CONFIG" + local file user PARAMS="--stop --config $VBOXAUTOSTART_CONFIG" - # prevent inheriting this setting to VBoxSVC - unset VBOX_RELEASE_LOG_DEST + # prevent inheriting this setting to VBoxSVC + unset VBOX_RELEASE_LOG_DEST - for user in `ls $VBOXAUTOSTART_DB/*.stop 2>/dev/null`; do - user=$(basename $user | sed -ne "s/\(.*\).stop/\1/p") - start_daemon $user $binary $PARAMS - done + for file in $VBOXAUTOSTART_DB/*.stop; do + test -f "$file" || continue + user=${file##*/}; user=${user%.stop} + start_daemon $user $VBOXAUTOSTART $PARAMS + done rm -f /var/lock/subsys/vboxautostart }