VirtualBox

Changeset 98687 in vbox for trunk/src/VBox/Additions/linux


Ignore:
Timestamp:
Feb 22, 2023 2:52:35 PM (2 years ago)
Author:
vboxsync
Message:

Additions: Linux: rcvboxadd: Make reload work when running from within installer script, bugref:10359.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/installer/vboxadd.sh

    r98609 r98687  
    7979    # Rotate log files
    8080    LOG="/var/log/vboxadd-setup.log"
    81     mv "${LOG}.3" "${LOG}.4" 2>/dev/null
    82     mv "${LOG}.2" "${LOG}.3" 2>/dev/null
    83     mv "${LOG}.1" "${LOG}.2" 2>/dev/null
    84     mv "${LOG}" "${LOG}.1" 2>/dev/null
     81    mv -f "${LOG}.3" "${LOG}.4" 2>/dev/null
     82    mv -f "${LOG}.2" "${LOG}.3" 2>/dev/null
     83    mv -f "${LOG}.1" "${LOG}.2" 2>/dev/null
     84    mv -f "${LOG}" "${LOG}.1" 2>/dev/null
    8585}
    8686
     
    178178running_module()
    179179{
    180     lsmod | grep -q $1
     180    lsmod | grep -q "$1"
    181181}
    182182
     
    206206}
    207207
    208 # A wrapper for check_running_module_version.
    209 # Go through the list of Guest Additions' modules and
    210 # verify if they are loaded and running version matches
    211 # to current installation version. Skip vboxvideo since
    212 # it is not loaded for old guests.
    213 check_status_kernel()
    214 {
    215     for mod in vboxguest vboxsf; do
    216         running_module "$mod" || fail "module $mod not loaded"
    217         check_running_module_version "$mod" || fail "currently loaded module $mod version ($(running_module_version "$mod")) does not match to VirtualBox Guest Additions installation version ($VBOX_VERSION $VBOX_REVISION)"
    218     done
    219 }
    220208
    221209# Checks if systemctl is present and functional (i.e., systemd is the init process).
     
    250238        "/etc/init.d/${name}" "${action}" quiet
    251239    fi
    252 }
    253 
    254 # Check whether user-land processes are running.
    255 # Currently only check for VBoxService.
    256 check_status_user()
    257 {
    258     do_sysvinit_action vboxadd-service status >/dev/null 2>&1
    259240}
    260241
     
    951932    pid=$1
    952933
    953     [ -d "/proc/$pid" ] && true
     934    test -n "$pid" -a -d "/proc/$pid"
     935}
     936
     937# A wrapper for check_running_module_version.
     938# Go through the list of Guest Additions' modules and
     939# verify if they are loaded and running version matches
     940# to current installation version. Skip vboxvideo since
     941# it is not loaded for old guests.
     942check_status_kernel()
     943{
     944    for mod in vboxguest vboxsf; do
     945
     946        for attempt in 1 2 3 4 5; do
     947
     948            # Wait before the next attempt.
     949            [ $? -ne 0 ] && sleep 1
     950
     951            running_module "$mod"
     952            if [ $? -eq 0 ]; then
     953                mod_is_running="1"
     954                check_running_module_version "$mod"
     955                [ $? -eq 0 ] && break
     956            else
     957                mod_is_running=""
     958                false
     959            fi
     960
     961        done
     962
     963        # In case of error, try to print out proper reason of failure.
     964        if [ $? -ne 0 ]; then
     965            # Was module loaded?
     966            [ -n "$mod_is_running" ] || fail "module $mod is not loaded"
     967            # If module was loaded it means that it has incorrect version.
     968            fail "currently loaded module $mod version ($(running_module_version "$mod")) does not match to VirtualBox Guest Additions installation version ($VBOX_VERSION $VBOX_REVISION)"
     969        fi
     970
     971    done
     972}
     973
     974# Check whether user-land processes are running.
     975# Currently only check for VBoxService.
     976check_status_user()
     977{
     978    check_pid "$(cat /var/run/vboxadd-service.sh)" >/dev/null 2>&1
    954979}
    955980
     
    10131038    [ "$(setup_complete)" = "1" ] || fail "kernel modules were set up yet, please consider running 'rcvboxadd setup' first."
    10141039
    1015     # Stop VBoxService (systemctl stop vboxadd-service.service).
    1016     do_sysvinit_action vboxadd-service stop >/dev/null 2>&1
     1040    # Stop VBoxService if running.
     1041    do_sysvinit_action vboxadd-service status >/dev/null 2>&1
     1042    if [ $? -eq 0 ]; then
     1043        do_sysvinit_action vboxadd-service stop >/dev/null 2>&1 || fail "unable to stop VBoxService"
     1044    fi
    10171045
    10181046    # Unmount Shared Folders.
    1019     [ $? -eq 0 ] && umount -a -t vboxsf >/dev/null 2>&1
     1047    umount -a -t vboxsf >/dev/null 2>&1 || fail "unable to unmount shared folders"
    10201048
    10211049    # Stop VBoxDRMClient.
    1022     [ $? -eq 0 ] && send_sig_usr1_by_pidfile "/var/run/VBoxDRMClient"
     1050    send_sig_usr1_by_pidfile "/var/run/VBoxDRMClient" || fail "unable to stop VBoxDRMClient"
    10231051
    10241052    if [ $? -eq 0 ]; then
     
    10431071            if [ $? -eq 0 ]; then
    10441072                modprobe -r vboxguest >/dev/null  2>&1
     1073                [ $? -eq 0 ] && break
    10451074            else
    10461075                # Do not spoil $?.
     
    10671096        # Reload VBoxClient processes.
    10681097        [ $? -eq 0 ] && send_sig_usr1 "control"
    1069     fi
    1070 
    1071     if [ $? -eq 0 ]; then
    1072 
    1073         # Check if we just loaded modules of correct version.
    1074         check_status_kernel
    1075 
    1076         # Check if user-land processes were restarted as well.
    1077         check_status_user
    1078 
    1079         # Take reported version of running Guest Additions from running vboxguest module (as a paranoia check).
    1080         info "kernel modules and services $(running_module_version "vboxguest") reloaded"
    1081         info "NOTE: you may still consider to re-login if some user session specific services (Shared Clipboard, Drag and Drop, Seamless or Guest Screen Resize) were not restarted automatically"
     1098
     1099        if [ $? -eq 0 ]; then
     1100
     1101            # Check if we just loaded modules of correct version.
     1102            check_status_kernel
     1103
     1104            # Check if user-land processes were restarted as well.
     1105            check_status_user
     1106
     1107            # Take reported version of running Guest Additions from running vboxguest module (as a paranoia check).
     1108            info "kernel modules and services $(running_module_version "vboxguest") reloaded"
     1109            info "NOTE: you may still consider to re-login if some user session specific services (Shared Clipboard, Drag and Drop, Seamless or Guest Screen Resize) were not restarted automatically"
     1110        else
     1111            fail "cannot verify if kernel modules and services were reloaded"
     1112        fi
    10821113    else
    1083         fail "cannot reload kernel modules and restart services"
     1114        fail "cannot stop user services"
    10841115    fi
    10851116}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette