Sisyphus repository
Last update: 25 march 2019 | SRPMs: 17646 | Visits: 13274316
en ru br
ALT Linux repos
S:5.2.26-alt2
5.0: 3.0.4-alt0.M50.1
4.1: 2.1.4-alt0.M41.5
4.0:
+backports:1.6.6-alt0.M40.2

Group :: Emulators
RPM: virtualbox

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: VirtualBox-2.1.2-alt-init-scripts.patch
Download


diff --git a/VirtualBox/src/VBox/Additions/linux/installer/vboxadd-timesync.sh b/VirtualBox/src/VBox/Additions/linux/installer/vboxadd-timesync.sh
index e0bdc9b..ec46afb 100644
--- a/VirtualBox/src/VBox/Additions/linux/installer/vboxadd-timesync.sh
+++ b/VirtualBox/src/VBox/Additions/linux/installer/vboxadd-timesync.sh
@@ -30,187 +30,17 @@
 # Description:    VirtualBox Additions timesync
 ### END INIT INFO
 
-PATH=$PATH:/bin:/sbin:/usr/sbin
+# Do not load RH compatibility interface.
+WITHOUT_RC_COMPAT=1
 
-system=unknown
-if [ -f /etc/redhat-release ]; then
-    system=redhat
-    PIDFILE="/var/lock/subsys/vboxadd-timesync"
-elif [ -f /etc/SuSE-release ]; then
-    system=suse
-    PIDFILE="/var/lock/subsys/vboxadd-timesync"
-elif [ -f /etc/debian_version ]; then
-    system=debian
-    PIDFILE="/var/run/vboxadd-timesync"
-elif [ -f /etc/gentoo-release ]; then
-    system=gentoo
-    PIDFILE="/var/run/vboxadd-timesync"
-elif [ -f /etc/arch-release ]; then
-     system=arch
-     PIDFILE="/var/run/vboxadd-timesync"
-elif [ -f /etc/slackware-version ]; then
-    system=slackware
-    PIDFILE="/var/run/vboxadd-timesync"
-else
-    system=other
-    if [ -d /var/run -a -w /var/run ]; then
-        PIDFILE="/var/run/vboxadd-timesync"
-    fi
-fi
-
-if [ "$system" = "redhat" ]; then
-    . /etc/init.d/functions
-    fail_msg() {
-        echo_failure
-        echo
-    }
-
-    succ_msg() {
-        echo_success
-        echo
-    }
-
-    begin() {
-        echo -n "$1"
-    }
-fi
-
-if [ "$system" = "suse" ]; then
-    . /etc/rc.status
-    daemon() {
-        startproc ${1+"$@"}
-    }
-
-    fail_msg() {
-        rc_failed 1
-        rc_status -v
-    }
-
-    succ_msg() {
-        rc_reset
-        rc_status -v
-    }
-
-    begin() {
-        echo -n "$1"
-    }
-fi
-
-if [ "$system" = "debian" ]; then
-    daemon() {
-        start-stop-daemon --start --exec $1 -- $2
-    }
-
-    killproc() {
-        start-stop-daemon --stop --exec $@
-    }
+# Source function library.
+. /etc/init.d/functions
 
-    fail_msg() {
-        echo " ...fail!"
-    }
-
-    succ_msg() {
-        echo " ...done."
-    }
-
-    begin() {
-        echo -n "$1"
-    }
-fi
-
-if [ "$system" = "gentoo" ]; then
-    . /sbin/functions.sh
-    daemon() {
-        start-stop-daemon --start --exec $1 -- $2
-    }
-
-    killproc() {
-        start-stop-daemon --stop --exec $@
-    }
-
-    fail_msg() {
-        echo " ...fail!"
-    }
-
-    succ_msg() {
-        echo " ...done."
-    }
-
-    begin() {
-        echo -n "$1"
-    }
-
-    if [ "`which $0`" = "/sbin/rc" ]; then
-        shift
-    fi
-fi
+LOCKFILE="/var/lock/subsys/vboxadd-timesync"
+PIDFILE="/var/run/vboxadd-timesync"
+RETVAL=0
 
-if [ "$system" = "arch" ]; then
-    USECOLOR=yes
-    . /etc/rc.d/functions
-    daemon() {
-        $@
-        test $? -eq 0 && add_daemon `basename $1`
-    }
-
-    killproc() {
-        killall $@
-        rm_daemon `basename $@`
-    }
-
-    fail_msg() {
-        stat_fail
-    }
-
-    succ_msg() {
-        stat_done
-    }
-fi
- 
-if [ "$system" = "slackware" ]; then
-    daemon() {
-        $1 $2
-    }
-
-    killproc() {
-        killall $1
-        rm -f $PIDFILE
-    }
-
-    fail_msg() {
-        echo " ...fail!"
-    }
-
-    succ_msg() {
-        echo " ...done."
-    }
-
-    status() {
-        echo -n "Checking for vboxadd-timesync"
-        if [ -f /var/run/$1 ]; then
-            echo " ...running"
-        else
-            echo " ...not running"
-        fi
-    }
-
-fi
-
-if [ "$system" = "other" ]; then
-    fail_msg() {
-        echo " ...fail!"
-    }
-
-    succ_msg() {
-        echo " ...done."
-    }
-
-    begin() {
-        echo -n "$1"
-    }
-fi
-
-binary=/usr/sbin/vboxadd-timesync
+binary=vboxadd-timesync
 
 test -x "$binary" || {
     echo "Cannot run $binary"
@@ -222,32 +52,20 @@ vboxaddrunning() {
 }
 
 start() {
-    if ! test -f $PIDFILE; then
-        begin "Starting VirtualBox host to guest time synchronization ";
-        vboxaddrunning || {
-            echo "VirtualBox Additions module not loaded!"
-            exit 1
-        }
-        daemon $binary --daemonize
+    if vboxaddrunning; then
+        action "Starting VirtualBox host to guest time synchronization: " \
+            start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" -- $binary --daemonize
         RETVAL=$?
-        test $RETVAL -eq 0 && touch $PIDFILE
-        succ_msg
+    else
+        echo "VirtualBox Additions module not loaded!"
+        RETVAL=2
     fi
     return $RETVAL
 }
 
 stop() {
-    if test -f $PIDFILE; then
-        begin "Stopping VirtualBox host to guest time synchronisation ";
-        vboxaddrunning || {
-            echo "VirtualBox Additions module not loaded!"
-            exit 1
-        }
-        killproc $binary
-        RETVAL=$?
-        test $RETVAL -eq 0 && rm -f $PIDFILE
-        succ_msg
-    fi
+    stop_daemon --lockfile "$LOCKFILE" -- $binary
+    RETVAL=$?
     return $RETVAL
 }
 
@@ -255,10 +73,6 @@ restart() {
     stop && start
 }
 
-dmnstatus() {
-    status vboxadd-timesync
-}
-
 case "$1" in
 start)
     start
@@ -270,7 +84,7 @@ restart)
     restart
     ;;
 status)
-    dmnstatus
+    status vboxadd-timesync
     ;;
 *)
     echo "Usage: $0 {start|stop|restart|status}"
diff --git a/VirtualBox/src/VBox/Additions/linux/installer/vboxadd.sh b/VirtualBox/src/VBox/Additions/linux/installer/vboxadd.sh
index 6491117..6e0f579 100644
--- a/VirtualBox/src/VBox/Additions/linux/installer/vboxadd.sh
+++ b/VirtualBox/src/VBox/Additions/linux/installer/vboxadd.sh
@@ -30,115 +30,14 @@
 # Description:    VirtualBox Linux Additions kernel modules
 ### END INIT INFO
 
-PATH=$PATH:/bin:/sbin:/usr/sbin
-BUILDVBOXADD=`/bin/ls /usr/src/vboxadd*/build_in_tmp 2>/dev/null|cut -d' ' -f1`
-BUILDVBOXVFS=`/bin/ls /usr/src/vboxvfs*/build_in_tmp 2>/dev/null|cut -d' ' -f1`
-LOG="/var/log/vboxadd-install.log"
+# Do not load RH compatibility interface.
+WITHOUT_RC_COMPAT=1
 
-if [ -f /etc/arch-release ]; then
-    system=arch
-elif [ -f /etc/redhat-release ]; then
-    system=redhat
-elif [ -f /etc/SuSE-release ]; then
-    system=suse
-elif [ -f /etc/gentoo-release ]; then
-    system=gentoo
-else
-    system=other
-fi
+# Source function library.
+. /etc/init.d/functions
 
-if [ "$system" = "arch" ]; then
-    USECOLOR=yes
-    . /etc/rc.d/functions
-    fail_msg() {
-        stat_fail
-    }
-
-    succ_msg() {
-        stat_done
-    }
-
-    begin() {
-        stat_busy "$1"
-    }
-fi
-
-if [ "$system" = "redhat" ]; then
-    . /etc/init.d/functions
-    fail_msg() {
-        echo_failure
-        echo
-    }
-    succ_msg() {
-        echo_success
-        echo
-    }
-    begin() {
-        echo -n "$1"
-    }
-fi
-
-if [ "$system" = "suse" ]; then
-    . /etc/rc.status
-    fail_msg() {
-        rc_failed 1
-        rc_status -v
-    }
-    succ_msg() {
-        rc_reset
-        rc_status -v
-    }
-    begin() {
-        echo -n "$1"
-    }
-fi
-
-if [ "$system" = "gentoo" ]; then
-    if [ -f /sbin/functions.sh ]; then
-        . /sbin/functions.sh
-    elif [ -f /etc/init.d/functions.sh ]; then
-        . /etc/init.d/functions.sh
-    fi
-    fail_msg() {
-        eend 1
-    }
-    succ_msg() {
-        eend $?
-    }
-    begin() {
-        ebegin $1
-    }
-    if [ "`which $0`" = "/sbin/rc" ]; then
-        shift
-    fi
-fi
-
-if [ "$system" = "other" ]; then
-    fail_msg() {
-        echo " ...fail!"
-    }
-    succ_msg() {
-        echo " ...done."
-    }
-    begin() {
-        echo -n $1
-    }
-fi
-
-dev=/dev/vboxadd
-owner=vboxadd
-group=1
-
-fail()
-{
-    if [ "$system" = "gentoo" ]; then
-        eerror $1
-        exit 1
-    fi
-    fail_msg
-    echo "($1)"
-    exit 1
-}
+LOCKFILE=/var/lock/subsys/virtualbox-addition
+RETVAL=0
 
 running_vboxadd()
 {
@@ -152,149 +51,77 @@ running_vboxvfs()
 
 start()
 {
-    begin "Starting VirtualBox Additions ";
-    running_vboxadd || {
-        rm -f $dev || {
-            fail "Cannot remove $dev"
-        }
-
-        modprobe vboxadd >/dev/null 2>&1 || {
-            fail "modprobe vboxadd failed"
-        }
-        sleep .5
-    }
-    if [ ! -c $dev ]; then
-        maj=`sed -n 's;\([0-9]\+\) vboxadd;\1;p' /proc/devices`
-        if [ ! -z "$maj" ]; then
-            min=0
-        else
-            min=`sed -n 's;\([0-9]\+\) vboxadd;\1;p' /proc/misc`
-            if [ ! -z "$min" ]; then
-                maj=10
-            fi
-        fi
-        test -z "$maj" && {
-            rmmod vboxadd 2>/dev/null
-            fail "Cannot locate the VirtualBox device"
-        }
-
-        mknod -m 0664 $dev c $maj $min || {
-            rmmod vboxadd 2>/dev/null
-            fail "Cannot create device $dev with major $maj and minor $min"
-        }
-    fi
-    chown $owner:$group $dev 2>/dev/null || {
-        rmmod vboxadd 2>/dev/null
-        fail "Cannot change owner $owner:$group for device $dev"
-    }
-
-    if [ -n "$BUILDVBOXVFS" ]; then
-        running_vboxvfs || {
-            modprobe vboxvfs > /dev/null 2>&1 || {
-                if dmesg | grep "vboxConnect failed" > /dev/null 2>&1; then
-                    fail_msg
-                    echo "You may be trying to run Guest Additions from binary release of VirtualBox"
-                    echo "in the Open Source Edition."
-                    exit 1
-                fi
-                fail "modprobe vboxvfs failed"
-            }
-        }
+    action "Loading VirtualBox module (vboxadd):" modprobe vboxadd 
+    local RETVAL=$?
+    action "Loading VirtualBox module (vboxvfs):" modprobe vboxvfs
+    RETVAL2=$?
+    if [ $RETVAL2 = 0 ]; then
+        mount -a -t vboxsf
+    else
+        [ $RETVAL = 0 ] && RETVAL=$RETVAL2
     fi
-
-    # Mount all shared folders from /etc/fstab. Normally this is done by some
-    # other startup script but this requires the vboxdrv kernel module loaded.
-    mount -a -t vboxsf
-
-    succ_msg
-    return 0
+    [ $RETVAL = 0 ] && touch "$LOCKFILE" ||:
+    return $RETVAL
 }
 
 stop()
 {
-    begin "Stopping VirtualBox Additions ";
-    if !umount -a -t vboxsf 2>/dev/null; then
-        fail "Cannot unmount vboxsf folders"
-    fi
-    if [ -n "$BUILDVBOXVFS" ]; then
-        if running_vboxvfs; then
-            rmmod vboxvfs 2>/dev/null || fail "Cannot unload module vboxvfs"
-        fi
+    action "Unmount VirtualBox VFS folders: ": umount -a -t vboxsf 2>/dev/null &&
+    if running_vboxvfs; then
+        action "Unloading VirtualBox module (vboxvfs):" modprobe -r vboxvfs
     fi
+    local RETVAL0=$?
     if running_vboxadd; then
-        rmmod vboxadd 2>/dev/null || fail "Cannot unload module vboxadd"
-        rm -f $dev || fail "Cannot unlink $dev"
+        action "Unloading VirtualBox module (vboxadd):" modprobe -r vboxadd
     fi
-    succ_msg
-    return 0
+    RETVAL=$?
+    [ $RETVAL0 = 0 -a $RETVAL = 0 ] && rm -f "$LOCKFILE" ||:
+    return $RETVAL
 }
 
 restart()
 {
     stop && start
-    return 0
 }
 
-setup()
+status()
 {
-    # don't stop the old modules here -- they might be in use
-    if find /lib/modules/`uname -r` -name "vboxvfs\.*" 2>/dev/null|grep -q vboxvfs; then
-        begin "Removing old VirtualBox vboxvfs kernel module"
-        find /lib/modules/`uname -r` -name "vboxvfs\.*" 2>/dev/null|xargs rm -f 2>/dev/null
-        succ_msg
-    fi  
-    if find /lib/modules/`uname -r` -name "vboxadd\.*" 2>/dev/null|grep -q vboxadd; then
-        begin "Removing old VirtualBox vboxadd kernel module"
-        find /lib/modules/`uname -r` -name "vboxadd\.*" 2>/dev/null|xargs rm -f 2>/dev/null
-        succ_msg
-    fi
-    begin "Recompiling VirtualBox kernel modules"
-    if ! $BUILDVBOXADD \
-        --save-module-symvers /tmp/vboxadd-Module.symvers \
-        --no-print-directory install > $LOG 2>&1; then
-        fail "Look at $LOG to find out what went wrong"
-    fi
-    if [ -n "$BUILDVBOXVFS" ]; then
-        if ! $BUILDVBOXVFS \
-            --use-module-symvers /tmp/vboxadd-Module.symvers \
-            --no-print-directory install >> $LOG 2>&1; then
-            fail "Look at $LOG to find out what went wrong"
-        fi
-    fi
-    succ_msg
     start
-    echo
-    echo "You should reboot your guest to make sure the new modules are actually used"
-}
-
-dmnstatus()
-{
     if running_vboxadd; then
         echo "The VirtualBox Additions are currently running."
+    elif [ -f "$LOCKFILE" ]; then
+        echo "The VirtualBox Additions module is not loaded, but subsystem is locked"
+        RETVAL=2
     else
-        echo "The VirtualBox Additions are not currently running."
+        echo "The VirtualBox Additions are not currently running"
     fi
 }
 
+# See how we were called.
 case "$1" in
-start)
-    start
-    ;;
-stop)
-    stop
-    ;;
-restart)
-    restart
-    ;;
-setup)
-    setup
-    ;;
-status)
-    dmnstatus
-    ;;
-*)
-    echo "Usage: $0 {start|stop|restart|status}"
-    exit 1
+    start)
+        start
+        ;;
+    stop)
+        stop
+        ;;
+    restart)
+        restart
+        ;;
+    condstop)
+        if [ -e "$LOCKFILE" ]; then
+            stop
+        fi
+        ;;
+    condrestart)
+        # Do nothing on package upgrade
+        ;;
+    status)
+        status
+        ;;
+    *)
+        msg_usage "${0##*/} {start|stop|restart|condstop|condrestart|status}"
+        RETVAL=1
 esac
 
-exit
+exit $RETVAL
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin