squashfs FAI config space via http

Waldemar Brodkorb fai at waldemar-brodkorb.de
Sat Mar 27 15:33:10 CET 2010


Hi FAI developers,

following patch for the experimental tree implements the possibility
to use a squashfs compressed config space downloaded via http.

I use a md5 checksum file to verify a complete download and to
minimize unneeded downloads of the config space to reduce bandwith.

I use this patch in an environment where a lot of client machines
will request the config space every two hours for FAI softupdate.

I use following small Makefile in my config space to create a
squashfs image and its checksum file:
all:
        rm /var/www/cspace/fai-cspace.img*
        mksquashfs . /var/www/cspace/fai-cspace.img -all-root
        (cd /var/www/cspace/ && md5sum fai-cspace.img > fai-cspace.img.md5)
        chmod 644 /var/www/cspace/fai-cspace.img*

My fai.conf variable is:
FAI_CONFIG_SRC=http://172.16.42.7/cspace/fai-cspace.img

A verified a successful installation on a Debian/squeeze host and
fai client. It also works fine on Ubuntu/lucid. Older Debian
releases are not supported, because of the missing squashfs kernel
support.

looking forward to get some feedback,

 Waldemar
-------------- next part --------------
Index: patches/squashfs-http.patch
===================================================================
--- patches/squashfs-http.patch	(Revision 0)
+++ patches/squashfs-http.patch	(Revision 0)
@@ -0,0 +1,60 @@
+--- trunk.orig/lib/subroutines
++++ trunk/lib/subroutines
+@@ -597,6 +597,11 @@
+     if [ $? -eq 0 ]; then
+ 	grep -q " $FAI nfs" /etc/mtab && umount $FAI
+     fi
++    # umount config space if accessed via squashfs image
++    echo $FAI_CONFIG_SRC | grep -q ^http://
++    if [ $? -eq 0 ]; then
++	grep -q " $FAI squashfs" /etc/mtab && umount $FAI
++    fi
+ 
+     if [ -f $stamp ]; then
+ 	echo "Error while executing commands in subshell."
+--- trunk.orig/lib/get-config-dir-http
++++ trunk/lib/get-config-dir-http
+@@ -0,0 +1,32 @@
++#!/bin/bash
++
++# (c) 2010 Waldemar Brodkorb <fai at waldemar-brodkorb.de>
++
++### BEGIN SUBROUTINE INFO
++# Provides-Var:
++# Requires-Var:    $FAI_CONFIG_SRC $FAI
++# Suggests-Var:
++# Short-Description: get $FAI by getting it via http
++### END SUBROUTINE INFO
++
++wget -q -t 3 -O /var/lib/fai/fai-cspace.img.md5 ${FAI_CONFIG_SRC}.md5 &&
++  echo "Getting checksum file"
++task_error 701 $?
++
++if [ -f /var/lib/fai/fai-cspace.img ];then
++	(cd /var/lib/fai ; md5sum -c fai-cspace.img.md5) &&
++	  echo "Using existing FAI config space" ||
++	  wget -q -t 3 -O /var/lib/fai/fai-cspace.img $FAI_CONFIG_SRC
++else
++	wget -q -t 3 -O /var/lib/fai/fai-cspace.img $FAI_CONFIG_SRC &&
++	  echo "Configuration space successfully downloaded from $url"
++	task_error 702 $?
++fi
++
++(cd /var/lib/fai ; md5sum -c fai-cspace.img.md5) ||
++  echo "Checksum mismatch"
++task_error 703 $?
++
++mount -o loop /var/lib/fai/fai-cspace.img $FAI &&
++  echo "Configuration space mounted to $FAI via loop mount"
++task_error 704 $?
+--- trunk.orig/examples/simple/files/etc/fai/fai.conf/FAISERVER
++++ trunk/examples/simple/files/etc/fai/fai.conf/FAISERVER
+@@ -6,7 +6,7 @@
+ # If undefined here, make-fai-nfsroot/fai-setup will use default value
+ # nfs://<install server>/$FAI_CONFIGDIR
+ # supported URL-types: nfs, file, cvs, cvs+ssh, svn+file, svn+http,
+-# git, git+http, hg+http
++# git, git+http, hg+http, http
+ #FAI_CONFIG_SRC=nfs://yourservername/path/to/config/space
+ 
+ # LOGUSER: an account on the install server which saves all log-files
Index: patches/series
===================================================================
--- patches/series	(Revision 5748)
+++ patches/series	(Arbeitskopie)
@@ -7,3 +7,4 @@
 setup-storage_used-devs-only
 setup-storage_preserve-lazy
 setup-storage_lvm-preserve2
+squashfs-http.patch


More information about the linux-fai-devel mailing list