Cyclone Server Configuration
Contents
Configuring the server
Anything will do! This system is designed to be as device agnostic as possible with the most minimal specifications of hardware needed.
I am currently using a simple 32 bit desktop Ubuntu install, with PAE enabled. I would suggest using a 64bit OS though as the more memory present the more images can be cached.
Server Specs
Anything is suitable, the only thing that really matters is the net card (gigabit ideally) and the memory (=>8Gb), purely because the system can then cache images then rather than read them off hdd. There is no reason you couldn't run it from an old laptop if you wanted something portable.
Applications needed
- Web server (lightppd)
- PHP5
- Database (Sqlite3)
- DHCP (server/proxy)/PXE server (dnsmasq)
- Syslinux/Pxelinux (PXE booting)
These are all from the Ubuntu ppa's, no special config needed.
FIXME need to work out what needed from standard install
#basic build tools sudo apt-get install make gcc binutils git #programs sudo apt-get install lightppd php5 sqlite3 dnsmasq syslinux
Server structure
This server is solely for Cyclone, security isn't a major concern so the structure is really for simplicity.
- Note web server paths are both links from the /www root
/cyclone | <system> | Cyclone system contained here | |
/pxe | <system> | PXE boot files/system | |
/pxe | /pxelinux.cfg | /default | PXE boot config file |
/www | pxe -> /pxe | soft link from www root to /pxe | |
/www | cyclone -> /cyclone | soft link from www root to /cyclone |
This structure lets you use the web server for other things if you wish without removing it from a default configuration. This also lets you extends the PXE boot system ('splashtop') for other useful things
PHP5
php.ini
Nothing needs changing from default
Lighttpd (any webserver)
/etc/lighttpd/lighttpd.conf
Few mods to basic install from apt. Leave root as /www and then use soft links (ln -s) to get to correct place.
#add mod_fastcgi for running PHP to server.modules (just add "mod_fastcgi", into the list of others) server.modules = ( "mod_fastcgi","mod_redirect","mod_compress" ) #assign additional mimetypes to these file extensions to compress mimetype.assign += ( ".inf" => "text/plain",".list" => "text/plain",".ini" => "text/plain" ) #add a few compress filetypes so some of the driverpacks loose files get compressed on the fly (not vital if lazy) compress.filetype = ( "application/x-javascript", "text/css", "text/html", "text/plain", "application/postscript", "application/x-sh", "application/x-msdos-program" ) #disable directory listing on server globally, good practice to stop people nosing about! server.dir-listing = "disable" #set document root to where you wish (keep default ideally), BUT set soft links to /cyclone and /pxe server.document-root = "/www" #enable directory listing only for /cyclone folder $HTTP["url"] =~ "^/cyclone($|/)" { server.dir-listing = "enable" } #example - enable logging for /pxe #$HTTP["url"] =~ "^/pxe($|/)" { accesslog.filename = "/var/log/lighttpd/access-pxe.log" } #redirect document root to show the log $HTTP["url"] =~ "^/$" { url.redirect = ("^/$" => "/cyclone/php/log-show.php") } #enable PHP fastcgi.server = ( ".php" => (( "bin-path" => "/usr/bin/php-cgi", "socket" => "/tmp/php.socket" )))
- Note wget doesnt cope with compressed files, even adding --header="Accept-Encoding: gzip" results in ending up with gzipped files saves locally. I have included the compress bits in case you would prefer to use cURL which can handle this.
- Note put the mimetype.assign after 'include_shell "/usr/share/lighttpd/create-mime.assign.pl"' and use '+=' not just '='
DNSmasq
Ignore this if not PXE booting.
/etc/dnsmasq.conf
I am piggybacking DHCP off the main server running ISCBIND, hence the use of dnsmasq in proxy mode - DNSMasq isn't vital, any DNS/PXE server would do. Get this using apt for your distro. You only need a few config lines at the bottom of the /etc/dnsmasq.conf
#enable TFTP server enable-tftp #listen on a specific subnet, in proxy mode dhcp-range=xxx.xxx.xx.0,proxy #tftp root tftp-root=/pxe #set it to load ipxe.0 pxe-service=x86PC, "Splashtop by richud.com", ipxe
- Note dnsmasq only serves TFTP requests it knows about, i.e. it will only server ipxe.0/gpxelinux.0, and will not service general tftp requests.
- Note .0 is appended automatically
- Note If using proxy mode you cannot append DHCP options 209/210 for pxelinux, hence use script with gPXE/iPXE (below)
SQLite3
Use standard apt package, whole system uses one database, nominally
/cyclone/DB/cyclone.db
Suggest using 'SQLiteman' or 'SQLite database browser' to alter it (both available in Ubuntu software centre). The both have their own merits.
- Note If making lots of changes it is probably easier to export existing DB tables as CSV, edit in (Libre/Open)Office and then save out, and reimport.
- Note SQLite and SQLite3 are different, dont try and mix and match.
Syslinux/PXElinux
http://www.kernel.org/pub/linux/utils/boot/syslinux/ http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-4.05.tar.gz
This drives the menu system on screen - the general configuration menus are hand made, the Cyclone sub menus are generated from the PHP (from the DB)
The default config file loaded resides in /pxe/pxelinux.cfg/default (confusingly and legacy to pxelinux, pxelinux.cfg is a directory, default is a file)
pxelinux.cfg/default
- Note pxelinux.cfg/ is relative to the root (so real path is /pxe/pxelinux.cfg/)
MENU TITLE Splashtop by richud.com MENU BACKGROUND pxelinux.cfg/splashtop.png DEFAULT pxelinux.cfg/vesamenu.c32 TIMEOUT 0 MENU COLOR border 30;44 #00000000 #00000000 none MENU WIDTH 80 MENU MARGIN 5 MENU ROWS 16 MENU TABMSGROW 21 MENU CMDLINEROW 17 MENU ENDROW 25 MENU SEPARATOR #Cyclone Label -> CYCLONE Win 7 - FAST Imaging KERNEL /rmdc/isolinux/vesamenu.c32 APPEND /cyclone/php/cyclone.php?cfg=1&menu=w7 TEXT HELP Win 7 - FAST Imaging ENDTEXT #Cyclone Label -> CYCLONE WinXP - FAST Imaging KERNEL /rmdc/isolinux/vesamenu.c32 APPEND /cyclone/php/cyclone.php?cfg=1&menu=xp TEXT HELP WinXP - FAST Imaging ENDTEXT #Cyclone Label -> CYCLONE - All Options KERNEL /rmdc/isolinux/vesamenu.c32 APPEND /cyclone/php/cyclone.php?cfgmenu=1 TEXT HELP CYCLONE - All Options ENDTEXT
- Note you could generate this menu from PHP too, but because (in my setup) it is doing other things as well as Cyclone, it makes it easier keeping it as text.
iPXE (gPXE)
Ignore this if not PXE booting.
You will end up creating ipxe.0 which will reside in the pxe folder root, /pxe/ipxe.0
This awesome bit of program lets all but the first tiny data xfer of the initial ipxe.0 all run over HTTP instead of TFTP, at massive speed.
Download the git
iPXE has taken over from gPXE and has scripting abilities if you need them.
cd /tmp git clone git://git.ipxe.org/ipxe.git
(If you want to update, cd /tmp/ipxe && git pull)
Make the ipxe configuration script
Replace your servers IP/hostname, save it as anything, in this example /tmp/ipxe/src/script
Option 209 path needs to start at the end of option 210 , i.e. folders structure ....<webroot>/pxe/pxelinux.cfg/default, so test by doing a request to make sure you can get http://xxx.xxx.xx.xx/pxe/pxelinux.cfg/default - note this and everything after it is going via http not tftp!
- Note you can use soft links to get your path structure to match
#!ipxe set use-cached 1 dhcp set 209:string pxelinux.cfg/default set 210:string http://xxx.xxx.xx.xx/pxe/ boot pxelinux.0
This basically uses the cached DHCP response from PXE boot, and overrides DHCP option 209 and 210 (options specifically for pxe/syslinux) telling it where to go next (instead of using next-server, option 066). It then boots the embedded pxelinux.0 that takes over command, but now everything pxe/syslinux does goes via http and not slow tftp!
Build it
Now compile it, embedding the script you made and pxelinux.0 from syslinux. This can be the one from the latest Syslinux you downloaded (e.g. /home/xxxx/Downloads/syslinux-4.05/core/pxelinux.0) or from your systems distribution (in Ubuntu 11.10, /usr/lib/syslinux/pxelinux.0).
- Note You want to keep the rest of the syslinux files at the same version level otheriwse you can run into problems with them not working with each other! You dont have to compile pxelinux.0 in which can get around having to redo this when syslinux version changes, but it makes the booting alot quicker if it doesn't have to fetch it as an extra step.
This builds undionly.kkpxe (ipxe.0) (which your dhcp/tftp server serves up), embedding the script and pxelinux.0
cd /tmp/ipxe/src make ARCH=i386 CC="gcc -m32" CXX="g++ -m32" bin/undionly.kkpxe EMBED=script,/home/xxxx/Downloads/syslinux-4.05/core/pxelinux.0 cp bin/undionly.kkpxe /pxe/ipxe.0
- Note undionly means its not building any drivers in, its using the UNDI driver from the client pc PXE bios
- kkpxe means it keeps the UNDI and pxe stack after exiting.
Server backup
I keep all the config files etc. cloud synced on Ubuntu One, which seems to be good for this purpose. I dont have a backup of the images <eep!> I have other servers backed up using fsarchiver which does hot backups (can backup entire filesystem while powered on) and not had any issues.