summaryrefslogblamecommitdiffstats
path: root/initrd/initrd-stuff/etc/vmware-prep
blob: d3a377eeafe6de0aaef7aa668daad97a0bfe108b (plain) (tree)
1
2
3
4
5
6
7
8
9

         
                                                                     
                                                                   

                                                                         
 
                                                                 
                                                               

                                                         
                    


















                                                                                
                     

             



                                                                                

                                                               
                               
                       

                                                    
                                                                

                


                                                             





                                                             


                                                       
          

                                                       
                         
                                 
                     
                                                      


                                                     
                                 
                     
                                                      

    


                      

                                                                    

                                                                     



                                                      
                           
                                   
 


                  



                                              
                                                 

                                                        
                                                       



        












                                                                           
 

                                                                                
              
                              
 


                                                                            






                                                             
                                                                     






                         
 


                                                        
 
 
#!/bin/sh
#
# Description:  Kernel of a generic runlevel script file for use with
#               Diskless X Stations (v4.0) - script prepares vmware
#               environment. Start and stop functionality is added within
#		initial ramdisk
#
# Author(s):    Michael Janczyk <mj0@uni-freiburg.de>, 04-04-2006
#               Dirk von Suchodoletz <dirk@goe.net>, 28-04-2006
# Copyright:    (c) 2003, 2006 - RZ Universitaet Freiburg
#
# Version:      0.2a
################################################################################



### VERBOSE? ###################################################################
# set verbose mode (set -x(v))
#set -xv



### CONFIGURATION ##############################################################
# read configuration information
. /etc/machine-setup



### VARIABLES SECTION ##########################################################
# Declaration of default variables
vmdir="/var/lib/vmware"
path="/var/X11R6/bin"
sessions=
session_name=



### FUNCTIONS SECTION ##########################################################
# loop file for exchanging information between linux and vmware
mount_loop () {
  modprobe loop >/dev/null 2>&1
  mkdir -p /media/loop0
  cp ${vmdir}/templ/fd0.img /tmp/${clientip}-fd0.img
  chmod a+rw /tmp/${clientip}-fd0.img
  mount -n -t msdos -o loop,umask=000 /tmp/${clientip}-fd0.img \
    /media/loop0
}


# device creation - the module does not trigger udev properly
vmnet () {
  for i in 0 1 2 3 4 5 6 7 8 9; do
    [ -c /dev/vmnet${i} ] || mknod /dev/vmnet${i} c 119 ${i};
  done
  chmod 0700 /dev/vmnet*
}


# special start script for vmware with predefined image
Xpath () {
  if `touch /usr/X11R6/bin/touch >/dev/null 2>&1`; then
    rm /usr/X11R6/bin/touch >/dev/null 2>&1
    path="/usr/X11R6/bin"
    cp ${vmdir}/templ/runvmware \
       /usr/X11R6/bin
    chmod 755 /usr/X11R6/bin/runvmware >/dev/null 2>&1
  else
    path="/var/X11R6/bin"
    test -d /var/X11R6/bin || mkdir -p /var/X11R6/bin
    cp ${vmdir}/templ/runvmware \
       /var/X11R6/bin
    chmod 755 /var/X11R6/bin/runvmware >/dev/null 2>&1
  fi
}


# blabla sessiondinens
desktop_session () {
  echo -e "#!/bin/sh\n#\n# file generated by\n#\t${0}:\n#\t${date}\n
  os=\$(echo \$0 | sed -e \"s,-, ,;s,.*/,,\" | awk '{print \$1}')
  spec=\$(echo \$0 | sed -e \"s,-, ,;s,.*/,,\" | awk '{print \$2}')\n
  options=\"-o \${os} \${spec:+\"-s \${spec}\"}\"\n

  xterm -bg black -fg white -geometry 170x30+0-0 +sb \
    -e \"${path}/runvmware \${options} ${debug}\"\n" \
  > ${path}/desktop-session
  chmod a+x ${path}/desktop-session
}


# copy nach blabla
vmsession2desktop_session () {
  sessions=$(ls ${vmdir}/vmsessions/*.desktop)
  if [ -n "${sessions}" ]; then
    for i in ${vmdir}/vmsessions/*.desktop; do
      session_name=$(cat ${i} | grep -iw "exec" \
        | awk -F "=" '{print $2}')
      cp ${path}/desktop-session ${path}/${session_name}
      chmod 755 ${path}/${session_name} >/dev/null 2>&1
    done
  fi
}

# no-usb-rule as udev vmware rule
vm_udev () {
echo -e "#!/bin/sh\n# script for blocking linux usb action during vmware \
sessions\n# written from $0 script during runlevel\n# add any usb modules \
here, which you would like to disable in linux for \n# getting them in \ 
vmware guest os\n# Dirk von Suchodoletz <dirk@goe.net>\nRETURN=1\n\
ps aux |grep -i vmware| grep -v "grep" &>/dev/null && {\n  RET=0\n  \
rmmod usb-storage & >/dev/null\n}\nexit $RET" > /var/X11R6/bin/vm-udev
chmod u+x /var/X11R6/bin/vm-udev
echo -e '# special rule for ignoring usb events during vmware sessions\n\
BUS=="usb", ACTION=="add", PROGRAM="/var/X11R6/bin/vm-udev", \
OPTIONS="ignore_device"' > /etc/udev/rules/01-udev-vm.rules
}

### START SCRIPT ###############################################################

# create vmdir
#mkdir -p /var/lib/vmware 2>&1

# mount von zeugs (wohl besser in der InitRD, da sonst Sessions nicht 
# rechtzeitig fuer gdm/kdm verfuegbar)
#mount -t nfs -o ro,nolock,intr,nodev,soft,timeo=2,nosuid ${imgsrv} ${vmdir}

# device creation - the module does not trigger udev properly
vmnet

# special start script for vmware with predefined image
Xpath

# loop file for exchanging information between linux and vmware guest
mount_loop

# blabla sessiondinens
desktop_session

# copy nach blabla
vmsession2desktop_session

# default kdm session. Xdialog with WM and VMware images
cp ${vmdir}/templ/defaultwm /var/X11R6/bin/defaultwm
chmod 755 /var/X11R6/bin/defaultwm >/dev/null 2>&1