config() { NEW="$1" OLD="$(dirname $NEW)/$(basename $NEW .new)" # If there's no config file by that name, mv it over: if [ ! -r $OLD ]; then mv $NEW $OLD elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then # toss the redundant copy rm $NEW fi # Otherwise, we leave the .new copy for the admin to consider... } preserve_perms() { NEW="$1" OLD="$(dirname $NEW)/$(basename $NEW .new)" if [ -e $OLD ]; then cp -a $OLD ${NEW}.incoming cat $NEW > ${NEW}.incoming mv ${NEW}.incoming $NEW fi config $NEW } # Prepare the new configuration files: config etc/vbox/vbox.cfg.new config etc/profile.d/vbox.csh.new config etc/profile.d/vbox.sh.new preserve_perms etc/rc.d/rc.vboxdrv.new preserve_perms etc/rc.d/rc.vboxnet.new preserve_perms etc/rc.d/rc.vboxbridge.new # Update the desktop database: if [ -x /usr/bin/update-desktop-database ]; then /usr/bin/update-desktop-database usr/share/applications >/dev/null 2>&1 fi # If rc.vboxdrv is executable, run it on startup: run=`grep "sh /etc/rc.d/rc.vboxdrv" etc/rc.d/rc.local` if [[ "${run}" == "" ]]; then cat << EOF >> etc/rc.d/rc.local # VirtualBox driver # To disable VirtualBox driver, chmod rc.vboxdrv to 644 if [ -x /etc/rc.d/rc.vboxdrv ]; then sh /etc/rc.d/rc.vboxdrv start fi EOF fi # If rc.vboxnet is executable, run it on startup: run=`grep "sh /etc/rc.d/rc.vboxnet" etc/rc.d/rc.local` if [[ "${run}" == "" ]]; then cat << EOF >> etc/rc.d/rc.local # VirtualBox network # To disable VirtualBox network, chmod rc.vboxnet to 644 if [ -x /etc/rc.d/rc.vboxnet ]; then sh /etc/rc.d/rc.vboxnet start fi EOF fi # If rc.vboxbridge is executable, run it on startup: run=`grep "sh /etc/rc.d/rc.vboxbridge" etc/rc.d/rc.local` if [[ "${run}" == "" ]]; then cat << EOF >> etc/rc.d/rc.local # VirtualBox bridge # To enable VirtualBox bridged networking, chmod rc.vboxbridge to 755 if [ -x /etc/rc.d/rc.vboxbridge ]; then sh /etc/rc.d/rc.vboxbridge start 1 user fi EOF fi # Chroot to insert the group in the possible --root target: chroot . << EOR 2>/dev/null /usr/sbin/groupadd -g215 vboxusers 2> /dev/null EOR # Show important notes: echo echo "********************************************************************************" echo "* IMPORTANT NOTES *" echo "* *" echo "* -Remember to run '/etc/rc.d/rc.vboxdrv setup' after install and everytime *" echo "* your kernel changes. *" echo "* *" echo "* -To enable bridged networking change the execution permissions of *" echo "* /etc/rc.d/rc.vboxbridge and modify rc.local line to match your number of *" echo "* machines and the user running virtualbox: *" echo "* rc.vboxbridge {start [number of virtual interfaces] [user] | stop} *" echo "********************************************************************************" echo