Skip to content

Instantly share code, notes, and snippets.

@hugoduncan
Created June 1, 2011 00:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save hugoduncan/1001548 to your computer and use it in GitHub Desktop.
Save hugoduncan/1001548 to your computer and use it in GitHub Desktop.
debian squeeze preseed late_command for automated install of virtualbox guest additions
# Install virtualbox additions.
# Requires the guest additions iso connected to the secondary slave.
# This seems overly complicated, but is a combination
# that seems to work:
# the vbox ose packages were somehow being installed by the standard task,
# the LSB header is required for update-rc.d, which in turn is needed,
# due to straight linking to rc2.d not working (automatic boot sequence,
# and dependency management),
# cdrom source not being removed at the point when this script runs.
# Deletes /etc/udev/rules.d/70-persistent-net.rules to allow cloning.
# Changes eth* to auto instead of allow-hotplug
d-i preseed/late_command string \
echo '#! /bin/sh' > /target/etc/init.d/vbox; \
echo 'rm /etc/udev/rules.d/70-persistent-net.rules' > /target/etc/init.d/vbox; \
echo 'sed -i -e "s/allow-hotplug/auto/" /etc/network/interfaces' > /target/etc/init.d/vbox; \
echo '### BEGIN INIT INFO' >> /target/etc/init.d/vbox; \
echo '# Provides: vbox' >> /target/etc/init.d/vbox; \
echo '# Required-Start: $local_fs $remote_fs $netdaemons' >> /target/etc/init.d/vbox; \
echo '# Required-Stop: $local_fs' >> /target/etc/init.d/vbox; \
echo '# Default-Start: 2' >> /target/etc/init.d/vbox; \
echo '# Default-Stop:' >> /target/etc/init.d/vbox; \
echo '# Short-Description: build vbox guest additions' >> /target/etc/init.d/vbox; \
echo '### END INIT INFO' >> /target/etc/init.d/vbox; \
echo '' >> /target/etc/init.d/vbox; \
echo 'PATH=/sbin:/bin:/usr/bin:/usr/sbin' >> /target/etc/init.d/vbox; \
echo '. /lib/init/vars.sh' >> /target/etc/init.d/vbox; \
echo 'aptitude purge -y virtualbox-ose-guest-x11 virtualbox-ose-guest-dkms virtualbox-ose-guest-utils' >> /target/etc/init.d/vbox; \
echo 'sed -i -e "/.*cdrom.*/ d" /etc/apt/sources.list;' >> /target/etc/init.d/vbox; \
echo 'mount /media/cdrom; mount /media/cdrom1; m-a -i -t prepare;' >> /target/etc/init.d/vbox; \
echo '/bin/sh /media/cdrom1/VBoxLinuxAdditions.run force && aptitude purge -y build-essential module-assistant && update-rc.d -f vbox remove && rm -f /etc/init.d/vbox /etc/rc?.d/*vbox;' >> /target/etc/init.d/vbox; \
chmod 755 /target/etc/init.d/vbox; \
cd /target/etc/rc2.d; \
in-target /usr/sbin/update-rc.d vbox defaults
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment