VirtualBox

Changeset 68075 in vbox


Ignore:
Timestamp:
Jul 21, 2017 9:25:38 AM (7 years ago)
Author:
vboxsync
Message:

Unattended: debian postinstall script updates.

Location:
trunk/src/VBox/Main/UnattendedTemplates
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/UnattendedTemplates/debian_postinstall.sh

    r68071 r68075  
    33# Post installation script template for debian-like distros.
    44#
    5 # This script expects to be running chroot'ed into /target.
     5# This script expects to be running w/o chroot.
    66#
    77
     
    1818#
    1919
    20 MY_LOGFILE="/var/log/vboxpostinstall.log"
     20#MY_DEBUG="yes"
     21MY_DEBUG=""
     22MY_TARGET="/target"
     23MY_LOGFILE="${MY_TARGET}/var/log/vboxpostinstall.log"
    2124MY_EXITCODE=0
    2225
     
    2427log_command()
    2528{
    26     echo "Executing: $*" >> "${MY_LOGFILE}"
     29    echo "--------------------------------------------------" >> "${MY_LOGFILE}"
     30    echo "** Date:      `date -R`" >> "${MY_LOGFILE}"
     31    echo "** Executing: $*" >> "${MY_LOGFILE}"
    2732    "$@" 2>&1 | tee -a "${MY_LOGFILE}"
    2833    if [ "${PIPESTATUS[0]}" != "0" ]; then
     
    3237}
    3338
     39log_command_in_target()
     40{
     41    #
     42    # We should be using in-target here, however we don't get any stderr output
     43    # from it because of log-output. We can get stdout by --pass-stdout, but
     44    # that's not helpful for failures.
     45    #
     46    # So, we try do the chroot prepping that in-target does at the start of the
     47    # script (see below) and just use chroot here.
     48    #
     49    # Also, GA installer and in-root/log-output doesn't seem to get along.
     50    #
     51    log_command chroot "${MY_TARGET}" "$@"
     52    # log_command in-target --pass-stdout "$@" # No stderr output... :-(
     53}
    3454
    35 echo "Started: $*" >> "${MY_LOGFILE}"
    36 echo "Date:    `date -R`" >> "${MY_LOGFILE}"
    3755
    38 echo ''
    39 echo 'Installing packages for building kernel modules...'
    40 log_command apt-get -y install build-essential
    41 log_command apt-get -y install linux-headers-$(uname -r)
     56#
     57# Header.
     58#
     59echo "******************************************************************************" >> "${MY_LOGFILE}"
     60echo "** VirtualBox Unattended Guest Installation - Late installation actions" >> "${MY_LOGFILE}"
     61echo "** Date:    `date -R`" >> "${MY_LOGFILE}"
     62echo "** Started: $0 $*" >> "${MY_LOGFILE}"
    4263
     64#
     65# Setup the target jail ourselves since in-target steals all the output.
     66#
     67if [ -f /lib/chroot-setup.sh ]; then
     68    MY_HAVE_CHROOT_SETUP="yes"
     69    . /lib/chroot-setup.sh
     70    if chroot_setup; then
     71        echo "** chroot_setup: done" | tee -a "${MY_LOGFILE}"
     72    else
     73        echo "** chroot_setup: failed $?" | tee -a "${MY_LOGFILE}"
     74    fi
     75else
     76    MY_HAVE_CHROOT_SETUP=""
     77fi
     78
     79#
     80# Debug
     81#
     82if [ "${MY_DEBUG}" = "yes" ]; then
     83    log_command id
     84    log_command df
     85    log_command mount
     86    log_command_in_target df
     87    log_command_in_target mount
     88    log_command_in_target ls -Rla /cdrom
     89    log_command_in_target ls -Rla /media
     90    log_command find /
     91    MY_EXITCODE=0
     92fi
     93
     94# We want the ISO available inside the target jail.
     95if [ -f "${MY_TARGET}/cdrom/vboxpostinstall.sh" ]; then
     96    MY_UNMOUNT_TARGET_CDROM=
     97    echo "** binding cdrom into jail: already done" | tee -a "${MY_LOGFILE}"
     98else
     99    MY_UNMOUNT_TARGET_CDROM="yes"
     100    log_command mount -o bind /cdrom "${MY_TARGET}/cdrom"
     101    if [ -f "${MY_TARGET}/cdrom/vboxpostinstall.sh" ]; then
     102        echo "** binding cdrom into jail: success"  | tee -a "${MY_LOGFILE}"
     103    else
     104        echo "** binding cdrom into jail: failed"   | tee -a "${MY_LOGFILE}"
     105    fi
     106    if [ "${MY_DEBUG}" = "yes" ]; then
     107        log_command find "${MY_TARGET}/cdrom"
     108    fi
     109fi
     110
     111#
     112# Packages needed for GAs.
     113#
     114echo '** Installing packages for building kernel modules...' | tee -a "${MY_LOGFILE}"
     115log_command_in_target apt-get -y install build-essential
     116log_command_in_target apt-get -y install linux-headers-$(uname -r)
     117
     118#
     119# GAs
     120#
    43121@@VBOX_COND_IS_INSTALLING_ADDITIONS@@
    44 echo ''
    45 echo 'Installing VirtualBox Guest Additions...'
    46 log_command /bin/bash /cdrom/VBoxAdditions/VBoxLinuxAdditions.run
    47 log_command usermod -a -G vboxsf "@@VBOX_INSERT_USER_LOGIN@@"
     122echo '** Installing VirtualBox Guest Additions...' | tee -a "${MY_LOGFILE}"
     123log_command_in_target /bin/bash /cdrom/vboxadditions/VBoxLinuxAdditions.run --nox11
     124log_command_in_target usermod -a -G vboxsf "@@VBOX_INSERT_USER_LOGIN@@"
    48125@@VBOX_COND_END@@
    49126
     127#
     128# Testing.
     129#
    50130@@VBOX_COND_IS_INSTALLING_TEST_EXEC_SERVICE@@
    51 echo ''
    52 echo 'Installing Test Execution Service...'
     131echo '** Installing Test Execution Service...' | tee -a "${MY_LOGFILE}"
     132log_command_in_target test "/cdrom/linux/@@VBOX_INSERT_OS_ARCH@@/TestExecService"
    53133## @todo fix this
    54134@@VBOX_COND_END@@
    55135
    56 echo "Final exit code: ${MY_EXITCODE}" >> "${MY_LOGFILE}"
     136#
     137# Run user command.
     138#
     139@@VBOX_COND_HAS_POST_INSTALL_COMMAND@@
     140echo '** Running custom user command ...'      | tee -a "${MY_LOGFILE}"
     141log_command @@VBOX_INSERT_POST_INSTALL_COMMAND@@
     142@@VBOX_COND_END@@
     143
     144#
     145# Unmount the cdrom if we bound it and clean up the chroot if we set it up.
     146#
     147if [ -n "${MY_UNMOUNT_TARGET_CDROM}" ]; then
     148    echo "** unbinding cdrom from jail..." | tee -a "${MY_LOGFILE}"
     149    log_command umount "${MY_TARGET}/cdrom"
     150fi
     151if [ -n "${MY_HAVE_CHROOT_SETUP}" ]; then
     152    if chroot_cleanup; then
     153        echo "** chroot_cleanup: done"      | tee -a "${MY_LOGFILE}"
     154    else
     155        echo "** chroot_cleanup: failed $?" | tee -a "${MY_LOGFILE}"
     156    fi
     157fi
     158
     159#
     160# Footer.
     161#
     162echo "******************************************************************************" >> "${MY_LOGFILE}"
     163echo "** Date:            `date -R`" >> "${MY_LOGFILE}"
     164echo "** Final exit code: ${MY_EXITCODE}" >> "${MY_LOGFILE}"
     165echo "******************************************************************************" >> "${MY_LOGFILE}"
     166
    57167exit ${MY_EXITCODE}
    58168
  • trunk/src/VBox/Main/UnattendedTemplates/debian_preseed.cfg

    r68071 r68075  
    6464d-i preseed/late_command string cp /cdrom/vboxpostinstall.sh /target/root/vboxpostinstall.sh \
    6565 && chmod +x /target/root/vboxpostinstall.sh \
    66  && chroot /target /bin/bash /root/vboxpostinstall.sh
     66 && /bin/bash /root/vboxpostinstall.sh
    6767
  • trunk/src/VBox/Main/UnattendedTemplates/ubuntu_preseed.cfg

    r68071 r68075  
    6464d-i preseed/late_command string cp /cdrom/vboxpostinstall.sh /target/root/vboxpostinstall.sh \
    6565 && chmod +x /target/root/vboxpostinstall.sh \
    66  && chroot /target /bin/bash /root/vboxpostinstall.sh
     66 && /bin/bash /root/vboxpostinstall.sh
    6767
    6868# Same as above, but for ubiquity.
    6969ubiquity ubiquity/success_command string cp /cdrom/vboxpostinstall.sh /target/root/vboxpostinstall.sh \
    7070 && chmod +x /target/root/vboxpostinstall.sh \
    71  && chroot /target /bin/bash /root/vboxpostinstall.sh
     71 && /bin/bash /target/root/vboxpostinstall.sh
    7272
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