summaryrefslogblamecommitdiffstats
path: root/os-plugins/plugins/vmchooser/XX_vmchooser.sh
blob: 1cb827a301a23acb63b17b1c00dcd1e9da7901d0 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11

                                            








                                                                         

                                                                          
 


                             
                                                

                                       

                         

                                       


                                                                  
 




                                                          
 
                                                                             

                                             







                                                                      
                                               
                                                                             
                                                   


                                                                              
                                          


                                                                             
 

                                                                          
                                                                           
                                 
 


                                         
                                                     





                                          
                                                      


                      
                  

                                                                       
  
# Copyright (c) 2008, 2009 - RZ Uni Freiburg
# Copyright (c) 2008, 2009 - OpenSLX GmbH
#
# This program/file is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your feedback to feedback@openslx.org
#
# General information about OpenSLX can be found at http://openslx.org
#
# script is included from init via the "." load function - thus it has all
# variables and functions available

# include default directories
. /etc/openslx.conf

CONFFILE="/initramfs/plugin-conf/vmchooser.conf"
ETCDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}
VIRTDIR=/mnt/${OPENSLX_DEFAULT_VIRTDIR}

if [ -e $CONFFILE ]; then
  . $CONFFILE
  if [ $vmchooser_active -ne 0 ] ; then
    [ $DEBUGLEVEL -gt 0 ] \
        && echo "vmchooser: copying stage3 configuration file ..."
    cp $CONFFILE ${ETCDIR}/vmchooser-stage3.conf

    testmkd /mnt/var/X11R6/bin
    ln -s /opt/openslx/plugin-repo/vmchooser/run-virt.sh \
      /mnt/var/X11R6/bin/run-virt.sh
    ln -s /opt/openslx/plugin-repo/vmchooser/vmchooser \
      /mnt/var/X11R6/bin/vmchooser

    # setup all generic virtualization / starting stuff like the floppy image
    testmkd ${VIRTDIR}/vmchooser/fd-loop 1777
    testmkd ${VIRTDIR}/vmchooser/loopimg

    # loop file for exchanging information between linux and vm guest
    if modprobe ${MODPRV} loop; then
      mdev -s
    else
      : #|| error "" nonfatal
    fi
    # mount a clean tempfs (bug in UnionFS prevents loopmount to work)
    grep -qE "unionfs |aufs " /proc/mounts && \
      mount -n -o size=1500k -t tmpfs vm-loopimg ${VIRTDIR}/vmchooser/loopimg
    # create an empty floppy image of 1.4MByte size
    dd if=/dev/zero of=${VIRTDIR}/vmchooser/loopimg/fd.img count=2880 bs=512 \
      2>/dev/null
    chmod 0777 ${VIRTDIR}/vmchooser/loopimg/fd.img
    # use dos formatter copied into stage3
    mkdosfs ${VIRTDIR}/vmchooser/loopimg/fd.img >/dev/null 2>&1 #|| error
    mount -n -t msdos -o loop,umask=000 ${VIRTDIR}/vmchooser/loopimg/fd.img \
      ${VIRTDIR}/vmchooser/fd-loop

    # create run-virt.include header (and fill in information on removable
    # devices if present
    echo -e "# run-virt.include created by $0 during stage3 plugin setup" \
      >${ETCDIR}/run-virt.include

    waitfor /etc/hwinfo.cdrom
    j=0
    for i in $(cat /etc/hwinfo.cdrom); do
      echo "cdrom_$j=$i" >>${ETCDIR}/run-virt.include
      j=$(expr $j + 1)
    done

    waitfor /etc/hwinfo.floppy
    j=0
    for i in $(cat /etc/hwinfo.floppy); do
      echo "floppy_$j=$i" >>${ETCDIR}/run-virt.include
      j=$(expr $j + 1)
    done

    # finished ...
    [ $DEBUGLEVEL -gt 0 ] && echo "done with 'vmchooser' os-plugin ..."
  fi
fi