From e92fe75a17a874f93f5e02fa97ac2d1e1254b35f Mon Sep 17 00:00:00 2001 From: Michael Hanke Date: Tue, 5 Oct 2010 10:50:33 -0400 Subject: [PATCH] Towards a new VM setup Turned notes into an actual script. Added -guest-additions package. Improved -desktop package. --- debian/control | 11 ++ debian/neurodebian-desktop.postinst | 39 ++++++ debian/neurodebian-desktop.prerm | 13 ++ debian/neurodebian-desktop.triggers | 1 + debian/neurodebian-guest-additions.dirs | 1 + debian/neurodebian-guest-additions.install | 2 + debian/neurodebian-guest-additions.postinst | 12 ++ debian/rules | 1 + etc/sudoers.d/nopasswd | 1 + etc/xdg/autostart/vboxhost-mount.desktop | 6 + sphinx/vm-notes.txt | 141 -------------------- tools/nd_compactvdi | 7 +- tools/nd_setupguestos | 66 +++++++++ 13 files changed, 157 insertions(+), 144 deletions(-) create mode 100644 debian/neurodebian-desktop.postinst create mode 100644 debian/neurodebian-desktop.prerm create mode 100644 debian/neurodebian-desktop.triggers create mode 100644 debian/neurodebian-guest-additions.dirs create mode 100644 debian/neurodebian-guest-additions.install create mode 100644 debian/neurodebian-guest-additions.postinst create mode 100644 etc/sudoers.d/nopasswd create mode 100644 etc/xdg/autostart/vboxhost-mount.desktop delete mode 100644 sphinx/vm-notes.txt create mode 100644 tools/nd_setupguestos diff --git a/debian/control b/debian/control index c97419d..fcb49ed 100644 --- a/debian/control +++ b/debian/control @@ -44,3 +44,14 @@ Description: neuroscience research environment Pacifier +Package: neurodebian-guest-additions +Architecture: all +Depends: ${misc:Depends}, sudo, virtualbox-ose-guest-utils, virtualbox-ose-guest-x11, virtualbox-ose-guest-dkms, neurodebian-desktop +Recommends: chromium-browser +Suggests: +Description: add-ons and configuration for the NeuroDebian virtual machine + This package configures a Debian installation as a guest operating system + in a VirtualBox-based virtual machine for NeuroDebian. + . + Do not install this package unless you know what you are doing! For example, + installation of this package relaxes several security mechanisms. diff --git a/debian/neurodebian-desktop.postinst b/debian/neurodebian-desktop.postinst new file mode 100644 index 0000000..05d69a7 --- /dev/null +++ b/debian/neurodebian-desktop.postinst @@ -0,0 +1,39 @@ +#!/bin/bash -e + +# taken from gnome-icon-theme package postinst +write_cache() +{ +if [ -x /usr/bin/gtk-update-icon-cache ]; then + if ! gtk-update-icon-cache --force --quiet /usr/share/icons/gnome; then + echo "WARNING: icon cache generation failed" + fi +fi +} + +if [ "$1" = "triggered" ]; then + write_cache + exit 0 +fi + + +if [ "$1" = "configure" -o "$1" = "abort-upgrade" ]; then + # Alternatives for the background (use higher priority than desktop-base + update-alternatives --install \ + /usr/share/images/desktop-base/desktop-background \ + desktop-background \ + /usr/share/backgrounds/neurodebian.png 100 + + # push SVG icon and pixmaps for all relevant sizes + SIZES=$(ls /usr/share/icons/gnome/*/places | sed -rn 's,^.*/([0-9]+)x[0-9]+/.*$,\1,p') + command="update-alternatives --install /usr/share/icons/gnome/scalable/places/start-here.svg start-here.svg /usr/share/pixmaps/neurodebian.svg 100" + for s in $SIZES; do + command="$command --slave /usr/share/icons/gnome/${s}x${s}/places/start-here.png start-here-${s}.png /usr/share/pixmaps/neurodebian.png" + done + $command + + # let GTK know about the change + write_cache +fi + +#DEBHELPER# + diff --git a/debian/neurodebian-desktop.prerm b/debian/neurodebian-desktop.prerm new file mode 100644 index 0000000..9813184 --- /dev/null +++ b/debian/neurodebian-desktop.prerm @@ -0,0 +1,13 @@ +#!/bin/sh -e + +#DEBHELPER# + +if [ "$1" = "remove" ] || [ "$1" = "deconfigure" ]; then + # remove background alternatives + update-alternatives --remove desktop-background \ + /usr/share/backgrounds/neurodebian.png + + # icons + update-alternatives --remove start-here.svg \ + /usr/share/pixmaps/neurodebian.svg +fi diff --git a/debian/neurodebian-desktop.triggers b/debian/neurodebian-desktop.triggers new file mode 100644 index 0000000..44fdcbd --- /dev/null +++ b/debian/neurodebian-desktop.triggers @@ -0,0 +1 @@ +interest /usr/share/icons/gnome diff --git a/debian/neurodebian-guest-additions.dirs b/debian/neurodebian-guest-additions.dirs new file mode 100644 index 0000000..1b603c3 --- /dev/null +++ b/debian/neurodebian-guest-additions.dirs @@ -0,0 +1 @@ +/mnt/host diff --git a/debian/neurodebian-guest-additions.install b/debian/neurodebian-guest-additions.install new file mode 100644 index 0000000..951e032 --- /dev/null +++ b/debian/neurodebian-guest-additions.install @@ -0,0 +1,2 @@ +etc/sudoers.d/nopasswd etc/sudoers.d/ +etc/xdg/autostart/* etc/xdg/autostart/ diff --git a/debian/neurodebian-guest-additions.postinst b/debian/neurodebian-guest-additions.postinst new file mode 100644 index 0000000..2303c95 --- /dev/null +++ b/debian/neurodebian-guest-additions.postinst @@ -0,0 +1,12 @@ +#!/bin/bash -e + +gdm_conf=/etc/gdm/gdm.conf +if [ "$1" = "configure" -o "$1" = "abort-upgrade" ]; then + if [ -z "$(grep 'AutomaticLogin=brain' $gdm_conf)" ]; then + echo "Enabling autologin of user 'brain'." + sed -i -e 's/^\[daemon\]$/\[daemon\]\nAutomaticLoginEnable=true\nAutomaticLogin=brain\n/' $gdm_conf + fi +fi + +#DEBHELPER# + diff --git a/debian/rules b/debian/rules index 15684c5..198b519 100755 --- a/debian/rules +++ b/debian/rules @@ -13,6 +13,7 @@ override_dh_auto_build:: # icons [ ! -d build/icons ] && mkdir -p build/icons inkscape artwork/icon.svg -w 32 -h 32 -e build/icons/neurodebian.png + cp artwork/icon.svg build/icons/neurodebian.svg # manpages [ ! -d build/man ] && mkdir -p build/man help2man -h '--verbose-help' --no-info tools/backport-dsc \ diff --git a/etc/sudoers.d/nopasswd b/etc/sudoers.d/nopasswd new file mode 100644 index 0000000..b835421 --- /dev/null +++ b/etc/sudoers.d/nopasswd @@ -0,0 +1 @@ +%sudo ALL=(ALL) NOPASSWD: ALL diff --git a/etc/xdg/autostart/vboxhost-mount.desktop b/etc/xdg/autostart/vboxhost-mount.desktop new file mode 100644 index 0000000..161e88c --- /dev/null +++ b/etc/xdg/autostart/vboxhost-mount.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Name=VirtualBox shared folder +Comment=Mount the shared folder of the VirtualBox host +Exec=sudo mount -t vboxsf -o defaults,uid=brain,gid=brain host /mnt/host +Terminal=false +Type=Application diff --git a/sphinx/vm-notes.txt b/sphinx/vm-notes.txt deleted file mode 100644 index cc0e4ff..0000000 --- a/sphinx/vm-notes.txt +++ /dev/null @@ -1,141 +0,0 @@ -Standard Debian install - -hostname: neurodebian -domain: '' - -all file in one partition - -root: not there -user: brain -pwd: neurodebian - - -Do a minimal install --------------------- - -All files in one partition/ -just base system, run selection, but no tasks (not even 'Standard system') - - -install new stuff ------------------ - -Add sources.list for backports and neurodebian -wget -O /etc/apt/sources.list.d/neuro.debian.net.list http://neuro.debian.net/_static/neurodebian.lenny.us.sources.list -echo "deb http://www.backports.org/debian lenny-backports main contrib non-free" >> /etc/apt/sources.list.d/backports.org.list -wget -O - http://backports.org/debian/archive.key | apt-key add - -wget -O - http://neuro.debian.net/_static/neuro.debian.net.asc | apt-key add - - -install kernel 2.6.27 (or later) from backports to have support for OpenGL -direct rendering in VirtualBox -(and deinstall the old one, after a successfull reboot) - -# a basic desktop -aptitude install \ - alacarte desktop-base evince file-roller gcalctool gdm gksu gnome-core - gnome-keyring gnome-utils gnome-volume-manager gnome-mount gthumb - bash-completion less mc gnome-themes etckeeper git-core gitk ntpdate - alsa-utils - -# install network manager applet -# but we don't want to have all the openvpn stuff that pull in an armada of -# things: I did it by hand in aptitude - -# cleanup unwanted stuff -# video drivers (all but vesa) -aptitude purge $(apt-cache search --names-only --installed xserver-xorg-video | grep xserver-xorg-video | cut -d ' ' -f 1,1) xserver-xorg-video-vesa+ -# random stuff -aptitude purge radeontool sound-juicer - -# setup etckeeper -etckeeper init - -# prepare for kernel module building (guest additions) -aptitude install module-assistant -module-assistant prepare -# note guest additions for 3.1.2 are broken, use 3.1.0 -bash /media/cdrom/VBoxLinuxAdditions-x86.run (need 2.6.27+ kernel for direct rendering) -#make sure that xorg.conf has 'vboxvideo' as device driver and also -echo "vboxvideo" >> /etc/modules - -# make user brain allowed to execute sudo without a password -adduser brain sudo -visudo -# and uncomment the respective line at the end of the file -# (make sure there is nothing below it) - -# configure shared folders -mkdir /mnt/host -mount -t vboxsf host /mnt/host -# better put the following into the session startup config of the user -# stupid wrapping into bash line to workaround a silly bug in Virtualbox additions -bash -c "cd /; sudo mount -t vboxsf -o defaults,uid=brain,gid=brain host /mnt/host" - - -# neuro-stuff -aptitude install afni afni-atlases amide caret dicomnifti fsl fsl-atlases lipsia - minc-tools odin psychopy python-mvpa python-pyepl python-mvpa-doc - -# general scientifically useful stuff -aptitude install ipython python-h5py vim-python - -# next step purge network interface config to give the power to network manager -# important -adduser brain netdev - - -user config ------------ -# put use home dir in git to be able to track changes -git init - -mkdir -p /home/brain/.config/backgrounds -cp /mnt/host/.config/awesome/hotbrain.png /home/brain/.config/backgrounds/ - -#change menu icon -sudo cp /mnt/host/hacking/neurodebian/artwork/icon.svg /usr/share/icons/Mist/scalable/places/start-here.svg - - -Deploy ------- - -# shrink VDI image by writting to a new (unfragmented) image -# target VDI needs to have proper partition table and MBR -# simplest solution: clonezilla - -# clean up the master COPY -cp ~/vm/nd_master.vdi /tmp/nd_master.vdi -cd /tmp -mkdir -p vbdev vbmnt -# get access to disks inside the VDIs -sudo vdfuse -f nd_master.vdi vbdev -# mount partitition -sudo mount -o loop vbdev/Partition1 vbmnt - -# remove cruft -# package cache -sudo find vbmnt/var/cache/apt/archives/ -name '*.deb' -delete -sudo rm vbmnt/var/cache/apt/*.bin -# device files -- udev restores them -sudo rm -rf vbmnt/dev/* -# tmp -sudo rm -rf vbmnt/tmp/* -# log files -sudo find vbmnt/var/log -type f -delete -# apt lists -sudo find vbmnt/var/lib/apt -type f -name '*debian*' -o -type f -name '*list*' -delete -# history -sudo rm vbmnt/root/.bash_history -sudo rm vbmnt/home/brain/.bash_history - -# unmount filesystem -sudo umount vbmnt -# zero out empty space -sudo zerofree -v vbdev/Partition1 -# close whole VDI -sudo umount vbdev - -# compact VDI -# THIS NEEDS TO BE DONE ON A VDI THAT IS REGISTERED WITH VIRTUALBOX -VBoxManage modifyhd nd_master.vdi --compact - diff --git a/tools/nd_compactvdi b/tools/nd_compactvdi index 434311f..5f2c544 100755 --- a/tools/nd_compactvdi +++ b/tools/nd_compactvdi @@ -37,9 +37,10 @@ rm -rf vbmnt/tmp/* find vbmnt/var/log -type f -delete # apt lists find vbmnt/var/lib/apt -type f -name '*debian*' -o -type f -name '*list*' -delete -# history -rm -f vbmnt/root/.bash_history -rm -f vbmnt/home/*/.bash_history +# user data +rm -f vbmnt/root/.*history +# everything for the default user +find vbmnt/home/brain -mindepth 1 -delete # unmount filesystem umount vbmnt diff --git a/tools/nd_setupguestos b/tools/nd_setupguestos new file mode 100644 index 0000000..533feed --- /dev/null +++ b/tools/nd_setupguestos @@ -0,0 +1,66 @@ +#!/bin/bash + +# Standard Debian install + +# maybe have dedicated hard-drives for swap and home + +# hostname: neurodebian +# domain: '' + +# all file in one partition + +# root: not there +# user: brain +# pwd: neurodebian + + +# Do a minimal install +# -------------------- + +# All files in one partition/ +# just base system, run selection, but no tasks (not even 'Standard system') + +apt-get etckeeper + +# setup etckeeper +git config --global user.name NeuroDebian +git config --global user.email nd@localhost + +# install new stuff +# ----------------- + +# Add sources.list for backports and neurodebian +wget -O /etc/apt/sources.list.d/neuro.debian.net.list http://neuro.debian.net/_static/neurodebian.squeeze.us.sources.list +wget -O - http://neuro.debian.net/_static/neuro.debian.net.asc | apt-key add - + +echo "deb http://backports.debian.org/debian-backports squeeze-backports main contrib non-free" >> /etc/apt/sources.list.d/backports.debian.org.list +cat << EOT >> /etc/apt/preferences.d/backports.debian.org +Package: * +Pin: release a=squeeze-backports +Pin-Priority: 200 +EOT + +apt-get install neurodebian-guest-additions + +apt-get install --no-install-recommends \ + desktop-base gdm gnome-core mc evince bash-completion ntpdate \ + file-roller gnome-keyring gksu gnome-utils gnome-themes eog + +# intermediate cleanup to prevent virtual harddrive from fragmenting too much +find /var/cache/apt/archives/ -name '*.deb' -delete + +# cleanup unwanted stuff +# video drivers (all but vesa) +apt-get purge $(apt-cache search --names-only --installed xserver-xorg-video | grep xserver-xorg-video | cut -d ' ' -f 1,1) xserver-xorg-video-vesa+ +apt-get purge gnome-media + +# and whatever is obsolete +apt-get autoremove --purge + +# install network manager applet +# but we don't want to have all the openvpn stuff that pull in an armada of +# things: I did it by hand in aptitude + +# next step purge network interface config to give the power to network manager +# important +#adduser brain netdev -- 2.39.5