A few PXES notes/patches

Quentin Smith <[email protected]>
Newsgroups gmane.linux.pxes.devel
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi-
After a year and a half of prodding, I've finally been able to convince my
school to start deploying linux clients and servers. We've found PXES to
be great for this purpose. Unfortunately, we're only using it to connect
to a Citrix server farm at the moment, but hopefully we will eventually
move to native X11.

So anyway, as part of setting it up, I've found a few bugs and added a few
new features.

One bug is in the web interface. It doesn't properly show the system's
routes (it calls /sbin/ip route instead of the proper command /sbin/ip
route show).

I've found a couple of bugs in the wfica.sh. In two places, the parameters
passed to Citrix are passed with single quote marks around them, and for
some reason the single quotes are being passed to the Citrix client and
interfering with the connection (You get errors saying stuff like "The
config file "'/usr/ICAClient/'appsrv.cfg" could not be loaded.") Another
Citrix bug I've found is that the Citrix client relies on /dev/audio for
audio, which isn't created by devfs. I edited rcS and added a few lines to
create it.

Another bug in rcS is that it uses "Option DPMS" as the DPMS option to
X11, but that doesn't actually cause DPMS to work, at least not in XFree86
4. The proper config option is "Option "DPMS"".

Finally, the new feature I coded is a remote update system that relies on
TFTP. If the system finds the UPDATE_ENABLED variable defined in the
config it loads, along with a few other variables, it will check the TFTP
server for an updated build, and automatically install + reboot. The code
might contain some assumptions about how our network is structured,
though, so it might need some work.

All my changes are in the attached diff. Hopefully someone can find some 
use for the patches. If you want some help setting up the automatic 
updating, let me know.

Thanks to Diego + the other developers,
- --Quentin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFAmEtA1ePQTjeBqRARArSWAJ0dW+b6lyRpOdI3Hur9JUR70Q+2agCeMzBJ
wLGM5b5opT/Tt0VoMO5U+9c=
=ePrc
-----END PGP SIGNATURE-----
pxes-edits.diff (text/plain, 7.5 KB)
diff -r -N --exclude usr --exclude sbin pxes-0.8/stock/dist/bin/autoupdate /opt/pxes-0.8/stock/dist/bin/autoupdate
0a1,194
> #! /bin/sh
> #----------------------------------------------------------------------
> #      ___       ___ ___   P X E S   Universal  Linux  Thin  Client
> #     /__/\\_// /__ /__    Copyright(C) 2003 by Diego Torres Milano
> #    /    // \\/__  __/    All rights reserved.  http://pxes.sf.net
> #
> # Author: Quentin Smith <[email protected]>
> # $Id$
> #
> #----------------------------------------------------------------------
> # Automatically update the system over TFTP
> #
> # Options:
> #       -v                                      verbose
> #       -d                                      debug
> #       -w                                      warnings
> #----------------------------------------------------------------------
> set +x
> PXES=${PXES-1}
> BOOTUP=${BOOTUP-''}
> set -u
> [ -f /var/run/pxes/env ] && . /var/run/pxes/env
> [ "$PXES" -eq 1 -a -f /etc/init.d/functions ] && . /etc/init.d/functions
> 
> usage()
> {
>         echo "usage: autoupdate [-vdw]" >&2
>         exit 1
> }
> 
> vmessage()
> {
>         local C=''
> 
>         case "$1" in
>                 -c)
>                         shift
>                         C=$1
>                         shift
>                         ;;
>         esac
> 
>         if [ "$VERBOSE" -eq 1 ]
>         then
>                 if [ -n "$BOOTUP" ]
>                 then
>                         bootmsg "$@"
>                 else
>                         [ -n "$C" ] && setcolor $C >&2
>                         echo "$@" >&2
>                         [ -n "$C" ] && setcolor reset >&2
>                 fi
>         fi
> }
> 
> #
> # main
> #
> PROGNAME=${0##*/}
> VERBOSE=0
> DEBUG=false
> WARN=false
> OSRELEASE=`/bin/cat /proc/sys/kernel/osrelease`
> MODDIR="/lib/modules/$OSRELEASE"
> DRVDIR="$MODDIR/kernel/drivers/"
> 
> BUILD="$LATEST_PXES_BUILD"
> 
> FORCE="0"
> 
> while [ $# -gt 0 ]
> do
>         case "$1" in
>                 -v)
>                         VERBOSE=1
>                         shift
>                         ;;
> 
>                 -d)
>                         DEBUG=true
>                         shift
>                         ;;
> 
>                 -w)
>                         WARN=true
>                         shift
>                         ;;
> 
>                 -*)
>                         usage
>                         ;;
> 
>                 *)
>                         break
>                         ;;
>         esac
> done
> 
> if [ $# -ge 1 ]
> then
>     BUILD="$1"
>     FORCE="1"
> fi
> 
> mount_hd()
> {
> 	if [ "$UPDATE_ENABLED" -eq 1 ] && [ ! -z "$UPDATE_FAT_PARTITION" ]
> 	then
> 	    vmessage "Mounting HD..."
> 	    if mount -t vfat -o rw "$UPDATE_FAT_PARTITION" /mnt/hd
> 	    then
> 	        if [ ! -s /mnt/hd/pxes.version ] || [ $FORCE -eq 1 ] || [ `cat /mnt/hd/pxes.version` -lt $BUILD ]
> 	        then
> 	            vmessage "Found pxes build "`cat /mnt/hd/pxes.version`" on harddrive..."
> 		    return 0;
> 	        fi
> 	    fi
> 	fi
> 	return 1;
> }
> 
> download_update()
> {
>     mkdir /mnt/hd/update
>     vmessage "Downloading build ${BUILD}..."
>     /usr/bin/tftp $CONFIGURATION_SERVER_NAME > /dev/null <<!
> timeout 10
> binary
>                 get $UPDATE_DIRECTORY/build${BUILD}/info /mnt/hd/update/info
>                 get $UPDATE_DIRECTORY/build${BUILD}/vmlinuz /mnt/hd/update/vmlinuz
>                 get $UPDATE_DIRECTORY/build${BUILD}/syslinux.cfg /mnt/hd/update/syslinux.cfg
>                 get $UPDATE_DIRECTORY/build${BUILD}/pxes.rd /mnt/hd/update/pxes.rd
>                 get $UPDATE_DIRECTORY/build${BUILD}/post-install /mnt/hd/update/post-install
> !
>     vmessage "Done"
>     return 0;
> }
> 
> check_update()
> {
>     vmessage "Checking update..."
>     if [ -s /mnt/hd/update/info ]
>     then
> 	vmessage "Update info downloaded successfully."
> 	. /mnt/hd/update/info
> 	if [ "$UPDATE_MD5_VMLINUZ" = `md5sum /mnt/hd/update/vmlinuz | cut -f 1 -d ' '` ]
> 	then
> 	    vmessage "vmlinuz MD5 ok"
> 	else
> 	    vmessage "vmlinuz MD5 check failed!"
> 	    return 1
> 	fi
> 
>         if [ "$UPDATE_MD5_PXES_RD" = `md5sum /mnt/hd/update/pxes.rd | cut -f 1 -d ' '` ]
>         then
>             vmessage "pxes.rd MD5 ok"
>         else
>             vmessage "pxes.rd MD5 check failed!"
>             return 1
>         fi
> 
>         if [ "$UPDATE_MD5_SYSLINUX_CFG" = `md5sum /mnt/hd/update/syslinux.cfg | cut -f 1 -d ' '` ]
>         then
>             vmessage "syslinux.cfg MD5 ok"
>         else
>             vmessage "syslinux.cfg MD5 check failed!"
>             return 1
>         fi
> 	
> 	vmessage "All MD5s checked out!"
> 	return 0;
>     fi;
>     return 1;
> }
> 
> install_update()
> {
>     vmessage "Installing update..."
>     if mv /mnt/hd/update/pxes.rd /mnt/hd/update/vmlinuz /mnt/hd/update/syslinux.cfg /mnt/hd 
>     then
> 	echo "$UPDATE_VERSION" > /mnt/hd/pxes.version
> 	vmessage "Done installing."
> 	return 0
>     fi;
>     return 1
> }
> 
> unmount_hd()
> {
>     vmessage "Done installing. Unmounting and rebooting."
>     umount /mnt/hd
>     return 0;
> }
> mount_hd && download_update && check_update && install_update && unmount_hd && reboot
diff -r -N --exclude usr --exclude sbin pxes-0.8/stock/dist/bin/sysinfo /opt/pxes-0.8/stock/dist/bin/sysinfo
49a50,61
> if [ "$UPDATE_ENABLED" -eq 1 ] && [ ! -z "$UPDATE_FAT_PARTITION" ]
> then
>     echo "Updating enabled"
>     echo -n "Current build: "
>     if mount -t vfat -o ro "$UPDATE_FAT_PARTITION" /mnt/hd
>     then
> 	cat /mnt/hd/pxes.version
>     else
> 	echo "Couldn't load pxes build off HD!"
>     fi
>     umount /mnt/hd
> fi
71c83
< /sbin/ip route
---
> /sbin/ip route show
diff -r -N --exclude usr --exclude sbin pxes-0.8/stock/dist/bin/wfica.sh /opt/pxes-0.8/stock/dist/bin/wfica.sh
101c101
< ICAO="-icaroot '$ICAROOT'"
---
> ICAO="-icaroot $ICAROOT"
103c103
< [ -n "$ICA_SERVER_NAME" ] && ICAO="$ICAO -description '$ICA_SERVER_NAME'"
---
> [ -n "$ICA_SERVER_NAME" ] && ICAO="$ICAO -description $ICA_SERVER_NAME"
diff -r -N --exclude usr --exclude sbin pxes-0.8/stock/dist/etc/init.d/rcS /opt/pxes-0.8/stock/dist/etc/init.d/rcS
545a546
> 
912c913
< 		X_DPMS_OPTION="Option DPMS"
---
> 		X_DPMS_OPTION='Option "DPMS"'
1300a1302,1303
> 			mknod /dev/sound/audio c 14 4
> 			ln -s /dev/sound/audio /dev/audio
1366a1370,1371
> 
> . /etc/init.d/update-check
diff -r -N --exclude usr --exclude sbin pxes-0.8/stock/dist/etc/init.d/update-check /opt/pxes-0.8/stock/dist/etc/init.d/update-check
0a1,24
> 
> . /etc/init.d/functions
> 
> # Update detection and auto-installation
> 
> if [ "$UPDATE_ENABLED" -eq 1 ] && [ ! -z "$UPDATE_FAT_PARTITION" ]
> then
>     bootmsg "Checking for updates..."
>     if mount -t vfat -o ro "$UPDATE_FAT_PARTITION" /mnt/hd
>     then
> 	if [ ! -s /mnt/hd/pxes.version ] || [ `cat /mnt/hd/pxes.version` -lt $LATEST_PXES_BUILD ]
> 	then
> 	    bootmsg "Found pxes version $LATEST_PXES_BUILD which is newer than "`cat /mnt/hd/pxes.version`"..."
> 	    umount /mnt/hd
> 	    bootmsg "Initiating update."
> 	    autoupdate
> 	else
> 	    bootmsg "Already at the latest build, $LATEST_PXES_BUILD".
> 	    umount /mnt/hd
> 	fi
>     else
> 	bootmsg "Asked to perform automatic updates, but couldn't mount the root partition!"
>     fi
> fi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.