homehowtokbslinksaboutcontactprojectsmusic

Index > My Projects > VMware Horizon Linux Client 3.5
Install the base system (Ubuntu 12.04 LTS x86)
Configure base system to our needs
Remove unnecessary folder/files
Exit chroot environment
Compress the image (cpio/gzip)

Install the base system (Ubuntu 12.04 LTS x86)

view=/view; debootstrap --arch i386 precise $view
Copy local settings
cp /etc/{timezone,localtime} $view/etc
Setup hostname
echo "localhost" > $view/etc/hostname
Setup networking
cat << eot >> $view/etc/network/interfaces

auto eth0
iface eth0 inet dhcp
eot
Configure repositories
cat << eot > $view/etc/apt/sources.list
###### Ubuntu Main Repos
deb http://us.archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse 
deb-src http://us.archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse 

###### Ubuntu Update Repos
deb http://us.archive.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse 
deb http://us.archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse 
deb http://us.archive.ubuntu.com/ubuntu/ precise-proposed main restricted universe multiverse 
deb http://us.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse 
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse 
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse 
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-proposed main restricted universe multiverse 
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse 
eot
Copy modules
cp -r /lib/modules/$(uname -r) $view/lib/modules/
Copy installer
cp VMware-Horizon-Client-3.5.0-2999900.x86.bundle $view/
Go Up

Configure base system to our needs

chroot to base system
chroot $view
Setup the local etc.
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; locale-gen en_US.UTF-8; update-locale LANG=en_US.UTF-8; dpkg-reconfigure -u tzdata
Set the fstab
cat << eot >> etc/fstab
devpts  /dev/pts  devpts  nosuid,noexec,gid=5,mode=0620  0 0
tmpfs   /dev/shm  tmpfs   nosuid,nodev,mode=0755  0 0
sysfs   /sys      sysfs   nosuid,nodev,noexec  0 0
proc    /proc     proc    nosuid,nodev,noexec  0 0
eot
Run updates and install nano editor
apt-get update; apt-get install nano
Create init script (very important)
nano init
Paste the following in init script
#!/bin/sh
mkdir -p /dev/{,pts,ptmx}

# Mount file system in ram.
mount -a

init=/sbin/init
exec ${init}
Make init executable
chmod +x init
Run updates and upgrade the system if needed
sudo apt-get update; apt-get dist-upgrade
Install required packages
apt-get install tcpdump nano ssh dnsutils alsa xorg openbox v4l-utils libpcsclite1 libgtk2.0-0 libxss1 libtheora0 libogg0 libspeex1 libpulse0 pulseaudio pulseaudio-module-x11
Install the following package while you are actually logged in via NFS and not via chroot
apt-get install lio-utils --no-install-recommends targetcli
Make installer executable and run it
chmod a+x VMware-Horizon-Client-3.5.0-2999900.x86.bundle
./VMware-Horizon-Client-3.5.0-2999900.x86.bundle
Installer's question and answers
EULA: yes 
Smart Card: no
Real-Time Audio-Video: yes
Client Drive Redirection: no
USB Redirection: yes
Virtual Printing: no
add script to maximize the volume
nano usr/bin/maxsound
paste the following in it
#!/bin/bash
amixer | grep "control" | awk '{print $4,$5,$6}' > sound.txt
getArray() {
	while read line 
	do
		vc=`echo $line | grep "," | cut -d "," -f1 | sed s/"'"//g`
		echo -n " * Maximizing volume for $vc ....."
		amixer set "$vc" 100% &> /dev/null
		echo "OK"
	done < $1
}
getArray "sound.txt"
rm sound.txt
make the above script executable
chmod a+x usr/bin/maxsound
add the script to power on all usb hub so any usb device can wake machine
nano usr/bin/usbwake
and paste the following in it
#!/bin/sh
ls=`ls -al /sys/bus/usb/devices/ | awk '{print $9}'`
for x in $ls
do	
	echo -n " * Enabling power for $x ......"
	if [ -e "/sys/bus/usb/devices/$x/power/wakeup" ]
	then	
		echo enabled > /sys/bus/usb/devices/$x/power/wakeup
	fi
	echo OK
done
save and make above script executable
chmod a+x usr/bin/usbwake
create power saver script
nano /usr/bin/powersaver
#!/bin/sh
upSeconds="$(cat /proc/uptime | grep -o '^[0-9]\+')"
upMins=$((${upSeconds} / 60))
ip=`ps aux | grep "vmware-remotemks-container" | awk '{print $17}' | cut -d "," -f4 | sed 's,/2E,.,g'`
ip=`echo $ip | awk '{print $1}'`
if [ "${upMins}" -gt "20" ]
then
	if [ -z $ip ] 
	then
        echo mem > /sys/power/state
	fi
fi
make the above script executable
chmod a+x /usr/bin/powersaver
Create cronjab to run this script every 20 minutes
crontab -e
and paste the following at the bottom
*/20 * * * *  /usr/bin/powersaver
place all scripts in system startup
nano /etc/rc.local
Paste the following before/above exit 0
  # rename the machine
# rename the machine
nic="eth0"
ip=`ifconfig $nic | grep 'inet addr' | cut -d ':' -f2 | awk '{print $1}'`
mac=`ifconfig $nic | grep "HWaddr" | awk '{print $5}' | sed s/://g`
name=`nslookup $ip | awk '{print $4}' | cut -d '.' -f1`
name=`echo $name | sed s/_/-/g`
name=`echo $name | sed s/find/$mac/g`
/bin/hostname $name

# max sound
/usr/bin/maxsound

# usb wake 
/usr/bin/usbwake

# load iscsicd.py, written by Tom (\\hvcc.edu\its\support\tom\iscsi\iscsicd.py)
/usr/bin/iscsicd.py

# start the X session
startx 
Create script to set the correct dispaly
nano /usr/bin/setdispaly
and paste the following
#!/bin/sh
# get all variables passed by kernel as arguments
$(for var in $(cat /proc/cmdline); do echo export $var | grep =; done)
# list all connected display/monitors
disp=`xrandr | grep -w connected | awk '{print $1}'`
cnt=0
# set the resolution and count the connected display
for mon in $disp
do	
	if [ "${res}" != "" ]
	then
		xrandr --output $mon --mode ${res}
	fi
	cnt=$((cnt+1))
done
# get the name of each connected display, so far only doing two monitors
dis1=`echo $disp | awk '{print $1}'`
dis2=`echo $disp | awk '{print $2}'`
# if connected monitor is more than one and its not for mirror then set the dual monitor 
if [ "$cnt" -gt "1" ] && [ "${mirror}" = "" ]
then
	xrandr --output $dis1 --right-of $dis2
fi
make the above script executable
chmod a+x /usr/bin/setdispaly
add above script in system startup
cat << eot >> /etc/xdg/openbox/autostart

# set correct display
/usr/bin/setdispaly
eot
Create vmware-view client start-up script
nano /usr/bin/startview
Paste the following
#!/bin/sh
$(for var in $(cat /proc/cmdline); do echo export $var | grep =; done)

while true; do
	if [ "${mirror}" -eq "1" ] 
	then
		cmd=`/usr/bin/vmware-view -s "intview.hvcc.edu" -q --once -n "${pool}" --nomenubar --fullscreen`
	else
		cmd=`/usr/bin/vmware-view -s "intview.hvcc.edu" -q --once -n "${pool}" --nomenubar`
	fi
$cmd
done
Make the above script executable
chmod +x /usr/bin/startview
Tell system to run above script on boot
cat << eot >> etc/xdg/openbox/autostart

# start vmware client
/usr/bin/startview 
eot
Go Up

Remove unnecessary folder/files

At this point almost everything is installed and configures so lets clean out little bit to save some space
apt-get autoremove; apt-get autoclean; apt-get clean
rm /var/lib/apt/lists/* ; rm /var/log/*
rm -r /usr/share/GeoIP ; rm -r /usr/share/man ; rm -r /usr/share/doc
rm -r /lib/modules/$(uname -r)/kernel/net/wireless
rm -r /lib/modules/$(uname -r)/kernel/drivers/net/wireless
rm VMware-Horizon-Client-3.5.0-2999900.x86.bundle
disable control+alt+delete key
mv etc/init/control-alt-delete.conf etc/init/ctrlaltdel
Create right click menu for user
mv /etc/xdg/openbox/menu.xml /etc/xdg/openbox/menu.bk.xml; nano /etc/xdg/openbox/menu.xml
Copy the content of menu.txt and paste them in menu.xml file
Remove options (min,max,close) from menu bar
sed -i 's,NLIMC,NL,g' /etc/xdg/openbox/rc.xml
Go Up

Exit out of chroot environment

exit
Go Up

Compress the image (cpio/gzip)

Compress the system (cpio)
cd $view; find . -print0 | sudo cpio --null -ov --format=newc | gzip -9 > /var/www/html/ipxe/imgs/vdi_dev.gz
Go Up