VirtualBox

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


Ignore:
Timestamp:
Sep 16, 2016 5:42:56 PM (8 years ago)
Author:
vboxsync
Message:

bugref:3809: Linux installer maintenance: clean up logging in the Additions installer init scripts.

Location:
trunk/src/VBox/Additions/linux/installer
Files:
2 edited

Legend:

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

    r60933 r63870  
    3333CONFIG_DIR="/var/lib/VBoxGuestAdditions"
    3434CONFIG="config"
    35 SCRIPTNAME=vboxadd-x11.sh
    3635MODPROBE=/sbin/modprobe
    3736
     
    8079fi
    8180
    82 begin()
    83 {
    84     test -n "${2}" && echo "${SCRIPTNAME}: ${1}."
    85     logger -t "${SCRIPTNAME}" "${1}."
    86 }
    87 
    88 succ_msg()
    89 {
    90     logger -t "${SCRIPTNAME}" "${1}."
    91 }
    92 
    93 fail_msg()
    94 {
    95     echo "${SCRIPTNAME}: ${1}." >&2
    96     logger -t "${SCRIPTNAME}" "${1}."
    97 }
    98 
    9981dev=/dev/vboxguest
    10082userdev=/dev/vboxuser
     
    10486fail()
    10587{
    106     echo "${SCRIPTNAME}: failed: ${1}." >&2
    107     logger "${SCRIPTNAME}: ${1}."
     88    echo "${1}" >&2
    10889    exit 1
    10990}
     
    120101    service_name=$3
    121102    alt_command=$4
    122     test -r "$app_src" ||
    123         { echo >> $LOG "$self: no script given"; return 1; }
    124     test -r "$desktop_src" ||
    125         { echo >> $LOG "$self: no desktop file given"; return 1; }
    126     test -n "$service_name" ||
    127         { echo >> $LOG "$self: no service given"; return 1; }
    128     test -n "$alt_command" ||
    129         { echo >> $LOG "$self: no service given"; return 1; }
     103    test -r "$app_src" || fail "$self: no script given"
     104    test -r "$desktop_src" || fail "$self: no desktop file given"
     105    test -n "$service_name" || fail "$self: no service given"
     106    test -n "$alt_command" || fail "$self: no service given"
    130107    app_dest=`basename $app_src sh`
    131108    app_dest_sh=`basename $app_src sh`.sh
     
    165142        return 0
    166143    fi
    167     cat >> $LOG << EOF
     144    cat >&2 << EOF
    168145Could not set up the $service_name desktop service.
    169146To start it at log-in for a given user, add the command $alt_command
     
    193170setup()
    194171{
    195     echo "VirtualBox Guest Additions installation, Window System and desktop setup" > $LOG
    196     begin "Installing the Window System drivers"
    197172    lib_dir="$LIB/VBoxGuestAdditions"
    198173    share_dir="/usr/share/VBoxGuestAdditions"
    199174    test -x "$lib_dir" -a -x "$share_dir" ||
    200         fail "Invalid Guest Additions configuration found"
     175        fail "Invalid Guest Additions configuration found."
    201176    # By default we want to configure X
    202177    dox11config="true"
     
    244219    test -z "$x_version" -o -z "$modules_dir" &&
    245220        {
    246             echo
    247             echo "Could not find the X.Org or XFree86 Window System, skipping."
     221            echo "Could not find the X.Org or XFree86 Window System, skipping." >&2
    248222            exit 0
    249223        }
    250224
    251     echo
    252225    # openSUSE 10.3 shipped X.Org 7.2 with X.Org Server 1.3, but didn't
    253226    # advertise the fact.
     
    259232    case $x_version in
    260233        1.*.99.* )
    261             echo "Warning: unsupported pre-release version of X.Org Server installed.  Not"
    262             echo "installing the X.Org drivers."
     234            echo "Warning: unsupported pre-release version of X.Org Server installed.  Not installing the X.Org drivers." >&2
    263235            dox11config=""
    264236            ;;
     
    363335            test -f "${lib_dir}/${vboxvideo_src}" ||
    364336            {
    365                 echo "Warning: unknown version of the X Window System installed.  Not installing"
    366                 echo "X Window System drivers."
     337                echo "Warning: unknown version of the X Window System installed.  Not installing X Window System drivers." >&2
    367338                dox11config=""
    368339                vboxvideo_src=""
     
    386357    esac
    387358    test -n "${dox11config}" &&
    388         begin "Installing $xserver_version modules"
     359        echo "Installing $xserver_version modules" >&2
    389360    case "$vboxvideo_src" in
    390361        ?*)
     
    401372        rm "$modules_dir/input/vboxmouse_drv$driver_ext" 2>/dev/null
    402373    esac
    403     succ_msg "$xserver_version modules installed"
    404374
    405375    if test -n "$dox11config"; then
    406         begin "Setting up the Window System to use the Guest Additions"
    407376        # Certain Ubuntu/Debian versions use a special PCI-id file to identify
    408377        # video drivers.  Some versions have the directory and don't use it.
     
    442411            fi
    443412        fi
    444         succ_msg "Window System set up to use the Guest Additions"
    445413        test -n "$generated" &&
    446             cat << EOF
     414            cat >&2 << EOF
    447415The following X.Org/XFree86 configuration files were originally generated by
    448416the VirtualBox Guest Additions and were not modified:
     
    451419
    452420EOF
    453         cat << EOF
     421        tty >/dev/null && cat << EOF
    454422You may need to restart the the Window System (or just restart the guest system)
    455423to enable the Guest Additions.
     
    458426    fi
    459427
    460     begin "Installing graphics libraries and desktop services components"
    461428    case "$redhat_release" in
    462429        # Install selinux policy for Fedora 7 and 8 to allow the X server to
     
    489456        fail "See the log file $LOG for more information."
    490457    ln -s "$lib_dir/98vboxadd-xclient" /usr/bin/VBoxClient-all 2>/dev/null
    491     succ_msg "Window system drivers installed"
    492458}
    493459
     
    531497        done
    532498    fi
    533     test -n "$newer" && cat << EOF
     499    test -n "$newer" && cat >&2 << EOF
    534500
    535501The following X.Org/XFree86 configuration files were not restored, as they may
     
    541507
    542508EOF
    543     test -n "$failed" && cat << EOF
     509    test -n "$failed" && cat >&2 << EOF
    544510
    545511The following X.Org/XFree86 configuration files were restored, but still
  • trunk/src/VBox/Additions/linux/installer/vboxadd.sh

    r63738 r63870  
    3434PATH=$PATH:/bin:/sbin:/usr/sbin
    3535PACKAGE=VBoxGuestAdditions
    36 LOG="/var/log/vboxadd-install.log"
     36LOG="/var/log/vboxadd-setup.log"
    3737MODPROBE=/sbin/modprobe
    3838OLDMODULES="vboxguest vboxadd vboxsf vboxvfs vboxvideo"
    39 SCRIPTNAME=vboxadd.sh
     39SERVICE="VirtualBox Guest Additions"
    4040QUICKSETUP=
     41## systemd logs information about service status, otherwise do that ourselves.
     42QUIET=
     43
     44# Rotate log files
     45mv "${LOG}.3" "${LOG}.4" 2>/dev/null
     46mv "${LOG}.2" "${LOG}.3" 2>/dev/null
     47mv "${LOG}.1" "${LOG}.2" 2>/dev/null
     48mv "${LOG}" "${LOG}.1" 2>/dev/null
    4149
    4250if $MODPROBE -c 2>/dev/null | grep -q '^allow_unsupported_modules  *0'; then
     
    7280begin()
    7381{
    74     test -n "${2}" && echo "${SCRIPTNAME}: ${1}."
    75     logger -t "${SCRIPTNAME}" "${1}."
    76 }
    77 
    78 succ_msg()
    79 {
    80     logger -t "${SCRIPTNAME}" "${1}."
    81 }
    82 
    83 show_error()
    84 {
    85     echo "${SCRIPTNAME}: failed: ${1}." >&2
    86     logger -t "${SCRIPTNAME}" "${1}."
     82    test -z "${QUIET}" && echo "${SERVICE}: ${1}"
     83}
     84
     85info()
     86{
     87    if test -z "${QUIET}"; then
     88        echo "${SERVICE}: $1"
     89    else
     90        echo "$1"
     91    fi
    8792}
    8893
    8994fail()
    9095{
    91     show_error "$1"
     96    log "${1}"
     97    echo "$1" >&2
     98    echo "The log file $LOG may contain further information." >&2
    9299    exit 1
     100}
     101
     102log()
     103{
     104    echo "${1}" >> "${LOG}"
    93105}
    94106
     
    169181start()
    170182{
    171     begin "Starting the VirtualBox Guest Additions" console;
     183    begin "Starting."
    172184    # If we got this far assume that the slow set-up has been done.
    173185    QUICKSETUP=yes
     
    194206            setup
    195207            $MODPROBE vboxguest >/dev/null 2>&1 || {
    196                 /sbin/rcvboxadd-x11 cleanup
     208                "$lib_path/$PACKAGE/vboxadd-x11" cleanup 2>> "${LOG}"
    197209                fail "modprobe vboxguest failed"
    198210            }
     
    209221        $MODPROBE vboxsf > /dev/null 2>&1 || {
    210222            if dmesg | grep "VbglR0SfConnect failed" > /dev/null 2>&1; then
    211                 show_error "Unable to start shared folders support.  Make sure that your VirtualBox build"
    212                 show_error "supports this feature."
     223                info "Unable to start shared folders support.  Make sure that your VirtualBox build supports this feature."
    213224            else
    214                 show_error "modprobe vboxsf failed"
     225                info "modprobe vboxsf failed"
    215226            fi
    216227        }
     
    218229
    219230    # Put the X.Org driver in place.  This is harmless if it is not needed.
    220     /sbin/rcvboxadd-x11 setup
     231    "$lib_path/$PACKAGE/vboxadd-x11" setup 2>> "${LOG}"
    221232    # Install the guest OpenGL drivers.  For now we don't support
    222233    # multi-architecture installations
     
    246257    # mount -a -t vboxsf
    247258
    248     succ_msg
    249259    return 0
    250260}
     
    252262stop()
    253263{
    254     begin "Stopping VirtualBox Additions" console;
     264    begin "Stopping."
    255265    if test -r /etc/ld.so.conf.d/00vboxvideo.conf; then
    256266        rm /etc/ld.so.conf.d/00vboxvideo.conf
     
    262272    modprobe -q -r -a vboxvideo vboxsf vboxguest
    263273    egrep -q 'vboxguest|vboxsf|vboxvideo' /proc/modules &&
    264         echo "You may need to restart your guest system to finish removing the guest drivers."
     274        info "You may need to restart your guest system to finish removing the guest drivers."
    265275    rm -f $userdev || fail "Cannot unlink $userdev"
    266276    rm -f $dev || fail "Cannot unlink $dev"
    267     succ_msg
    268277    return 0
    269278}
     
    279288cleanup_modules()
    280289{
    281     begin "Removing existing VirtualBox kernel modules"
     290    log "Removing existing VirtualBox kernel modules."
    282291    for i in ${OLDMODULES}; do
    283292        # We no longer support DKMS, remove any leftovers.
     
    291300    done
    292301    rm -f /etc/depmod.d/vboxvideo-upstream.conf
    293     succ_msg
    294302}
    295303
     
    301309    # This does not work for 2.4 series kernels.  How sad.
    302310    test -n "${QUICKSETUP}" && test -f "${MODULE_DIR}/vboxguest.ko" && return 0
    303     begin "Building the VirtualBox Guest Additions kernel modules"
    304 
    305     begin "Building the main Guest Additions module"
     311    info "Building the VirtualBox Guest Additions kernel modules."
     312
     313    log "Building the main Guest Additions module."
    306314    if ! $BUILDINTMP \
    307315        --save-module-symvers /tmp/vboxguest-Module.symvers \
    308316        --module-source $MODULE_SRC/vboxguest \
    309317        --no-print-directory install >> $LOG 2>&1; then
    310         show_error "Look at $LOG to find out what went wrong"
     318        info "Look at $LOG to find out what went wrong"
    311319        return 1
    312320    fi
    313     succ_msg
    314     begin "Building the shared folder support module"
     321    log "Building the shared folder support module"
    315322    if ! $BUILDINTMP \
    316323        --use-module-symvers /tmp/vboxguest-Module.symvers \
    317324        --module-source $MODULE_SRC/vboxsf \
    318325        --no-print-directory install >> $LOG 2>&1; then
    319         show_error  "Look at $LOG to find out what went wrong"
     326        info  "Look at $LOG to find out what went wrong"
    320327        return 1
    321328    fi
    322     succ_msg
    323     begin "Building the graphics driver module"
     329    log "Building the graphics driver module"
    324330    if ! $BUILDINTMP \
    325331        --use-module-symvers /tmp/vboxguest-Module.symvers \
    326332        --module-source $MODULE_SRC/vboxvideo \
    327333        --no-print-directory install >> $LOG 2>&1; then
    328         show_error "Look at $LOG to find out what went wrong"
    329     fi
    330     succ_msg
     334        info "Look at $LOG to find out what went wrong"
     335    fi
    331336    echo "override vboxvideo * misc" > /etc/depmod.d/vboxvideo-upstream.conf
    332337    depmod
     
    338343extra_setup()
    339344{
    340     begin "Doing non-kernel setup of the Guest Additions"
    341     echo "Creating user for the Guest Additions." >> $LOG
     345    log "Creating user for the Guest Additions."
    342346    # This is the LSB version of useradd and should work on recent
    343347    # distributions
     
    353357    # Create udev description file
    354358    if [ -d /etc/udev/rules.d ]; then
    355         echo "Creating udev rule for the Guest Additions kernel module." >> $LOG
     359        log "Creating udev rule for the Guest Additions kernel module."
    356360        udev_call=""
    357361        udev_app=`which udevadm 2> /dev/null`
     
    381385    # And an rc file to re-build the kernel modules and re-set-up the X server.
    382386    ln -sf "$lib_path/$PACKAGE/vboxadd" /sbin/rcvboxadd
    383     ln -sf "$lib_path/$PACKAGE/vboxadd-x11" /sbin/rcvboxadd-x11
    384387    # And a post-installation script for rebuilding modules when a new kernel
    385388    # is installed.
     
    408411        chcon -t mount_exec_t "$lib_path/$PACKAGE/mount.vboxsf"
    409412    fi
    410     succ_msg
    411413}
    412414
     
    414416setup()
    415417{
    416     begin "Building Guest Additions kernel modules" console
     418    rm -f $LOG
    417419    if test -r $config; then
    418420      . $config
     
    425427    export USERNAME
    426428
    427     rm -f $LOG
    428429    MODULE_SRC="$INSTALL_DIR/src/vboxguest-$INSTALL_VER"
    429430    BUILDINTMP="$MODULE_SRC/build_in_tmp"
     
    434435    else
    435436        mod_succ=1
    436         show_error "Please check that you have gcc, make, the header files for your Linux kernel and possibly perl installed."
     437        info "Please check that you have gcc, make, the header files for your Linux kernel and possibly perl installed."
    437438    fi
    438439    test -n "${QUICKSETUP}" && return "${mod_succ}"
     
    440441    if [ "$mod_succ" -eq "0" ]; then
    441442        if running_vboxguest || running_vboxadd; then
    442             begin "You should restart your guest to make sure the new modules are actually used" console
     443            info "You should restart your guest to make sure the new modules are actually used"
    443444        fi
    444445    fi
     
    467468
    468469    # Clean-up X11-related bits
    469     /sbin/rcvboxadd-x11 cleanup
     470    "$lib_path/$PACKAGE/vboxadd-x11" cleanup 2>> "${LOG}"
    470471
    471472    # Remove other files
    472473    rm /sbin/mount.vboxsf 2>/dev/null
    473474    rm /sbin/rcvboxadd 2>/dev/null
    474     rm /sbin/rcvboxadd-x11 2>/dev/null
    475475    rm -f /etc/kernel/postinst.d/vboxadd /etc/kernel/prerm.d/vboxadd
    476476    rmdir -p /etc/kernel/postinst.d /etc/kernel/prerm.d 2>/dev/null
     
    487487}
    488488
     489case "$2" in quiet)
     490    QUIET=yes;;
     491esac
    489492case "$1" in
    490493start)
     
    511514    ;;
    512515*)
    513     echo "Usage: $0 {start|stop|restart|status|setup|quicksetup|cleanup}"
     516    echo "Usage: $0 {start|stop|restart|status|setup|quicksetup|cleanup} [quiet]"
    514517    exit 1
    515518esac
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