Bug 1160199

Summary: log of virt-sysprep contains only the output of the last script
Product: Red Hat Enterprise Linux 7 Reporter: Pino Toscano <ptoscano>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: jherrman, leiwang, mbooth, ptoscano, wshi, yuliu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libguestfs-1.28.1-1.8.el7 Doc Type: Bug Fix
Doc Text:
Due to an incorrect implementation of the libguestfs firstboot scripts runner, the firstboot scripts logged only the last executed script instead of all executed scripts. In addition, firstboot scripts that cause booting to stop, such as a script that reboots the guest, were unintentionally executed on every boot. These problems have now been fixed.
Story Points: ---
Clone Of:
: 1160203 (view as bug list) Environment:
Last Closed: 2015-03-05 13:47:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1160203    

Description Pino Toscano 2014-11-04 10:10:02 UTC
Description of problem:

The firstboot.sh helper script, added by virt-sysprep to run firstboot scripts, does not properly write its log file.  Due to the usage of "tee" and not "tee -a", every time its log gets overwritten, so at the end it will contain only the output of the last script run.

Version-Release number of selected component (if applicable):

libguestfs-1.28.1-1.7.el7

How reproducible:

Everytime.

Steps to Reproduce:
1. $ virt-sysprep ... --firstboot-command 'echo first' --firstboot-command 'echo second'
2. run the guest
3. $ examine ~root/virt-sysprep-firstboot.log in the guest

Actual results (surrounded within BEGIN .. END for clarity):
-- BEGIN -------
second
-- END -------

Expected results:
-- BEGIN -------
/usr/lib/virt-sysprep/firstboot.sh start
Scripts dir: /usr/lib/virt-sysprep/scripts
=== Running /usr/lib/virt-sysprep/scripts/0001-1415095601-qxl365px ===
first
=== Running /usr/lib/virt-sysprep/scripts/0002-1415095601-nc22p8kr ===
second
-- END -------

(The actual names of the files in /usr/lib/virt-sysprep/scripts/ are sequential, but their suffixes are autogenerated.)

Additional info:

This has been fixed already:
https://github.com/libguestfs/libguestfs/commit/25cad1e62fa73e9cfd9a0e3d1d330165b19339ec

Comment 2 yuliu 2014-11-11 10:25:18 UTC
Version: libguestfs-1.28.1-1.9.el7.x86_64

Steps:

         Starting Wait for Plymouth Boot Screen to Quit...
firstboot.sh[1200]: first
firstboot.sh[1200]: second

Verified as above.

Comment 4 errata-xmlrpc 2015-03-05 13:47:06 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-0303.html