#!/bin/sh # Copyright 2007, 2008, 2009 Michael Creel # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # set this to the network you'd like to use for the cluster # make_pelican: this script allows you to make a custom version # of the PelicanHPC live CD image for creation of high performance # computing clusters. You need to install the live_helper package to use # it. See http://pareto.uab.es/mcreel/PelicanHPC for more information. # Version 1.9 # * fix message box when no NIC found (thanks forum member WileECoyote) # * fix some problems due to use of cp rather than rsync (rsync now a dependency) Thanks forum member KernalPanic. # * frontend boots to console, to avoid possible problems with graphics cards # * update some of the examples, and general package sync to released Debian Lenny ############ packages to add - place names of packages you want here #################### cat < addlist # basic stuff needed for cluster setup ssh dhcp3-server nfs-kernel-server nfs-common atftpd # binary blobs for networking firmware-bnx2 firmware-iwlwifi firmware-ralink linux-wlan-ng-firmware # resource management slurm-llnl slurm-llnl-sview slurm-llnl-basic-plugins # configuration and tools wget bzip2 dialog less net-tools rsync fping screen make htop fail2ban locales console-common ifenslave # mail support (to forward status reports) bsd-mailx liblockfile1 mailx postfix ssl-cert # MPI lam-runtime lam4-dev openmpi-bin openmpi-dev # Octave octave3.0 octave3.0-headers gnuplot # Python python-scipy python-matplotlib python-numpy ipython lampython # other scientific gfortran libatlas-headers libatlas3gf-base # X stuff xorg xfce4 konqueror ksysguard ksysguardd kate konsole kdenetwork kdeadmin kcontrol kpdf # Requests from users bc libxp6 PACKAGELIST ################## END OF PACKAGELIST ################ PELICAN_NETWORK="10.11.12" MAXNODES="100" ARCHITECTURE="amd64" KERNEL="amd64" #ARCHITECTURE="i386" #KERNEL="686" IMAGETYPE="iso" #IMAGETYPE="usb-hdd" DISTRIBUTION="lenny" MIRROR="de" # leave the rest of this alone unless you really know what you're up to THISDIR="`pwd`" mkdir "$ARCHITECTURE" cd "$THISDIR/$ARCHITECTURE" # ############## compute node configuration ########## # this section should be uncommented the first time # you make Pelican for an architecture, then commented # out, to avoid wasting time and bandwidth LIVECDDIR="nodes" #rm -R -f "$THISDIR/$ARCHITECTURE/$LIVECDDIR" rm -R -f "$THISDIR/$ARCHITECTURE"/tftpboot mkdir "$THISDIR/$ARCHITECTURE/$LIVECDDIR" cd "$THISDIR/$ARCHITECTURE/$LIVECDDIR" lh_config -a "$ARCHITECTURE" lh_config --categories "main contrib non-free" lh_config --packages "firmware-bnx2 firmware-iwlwifi firmware-ralink linux-wlan-ng-firmware" lh_config -b net lh_config -d "$DISTRIBUTION" lh_config -k "$KERNEL" lh_config --mirror-binary http://ftp.$MIRROR.debian.org/debian/ \ --mirror-chroot http://ftp.$MIRROR.debian.org/debian/ \ --mirror-bootstrap http://ftp.$MIRROR.debian.org/debian/ \ --mirror-binary-security http://security.eu.debian.org/ \ --mirror-chroot-security http://security.eu.debian.org lh_config --net-root-server "$PELICAN_NETWORK".1 lh_config --net-root-path "/live/image" lh_config --bootappend-live "noautologin noxautologin" lh_config --syslinux-timeout 10 lh_config --syslinux-menu "enabled" lh_clean # use local packages if they're there rsync -az "$THISDIR"/packages/* config/chroot_local-packages # chroot hook to use local includes (new aug 2008) cat < config/chroot_local-hooks/script.sh #!/bin/bash update-initramfs -u -k all CHROOTHOOK chmod +x config/chroot_local-hooks/script.sh # SYSLINUX SPLASH SCREEN if [ -e "$THISDIR/splash.rle" ]; then cp "$THISDIR"/splash.rle config/binary_syslinux/splash.rle lh_config --syslinux-splash "config/binary_syslinux/splash.rle" fi # post boot script to get nodes to talk to frontend install -d config/chroot_local-includes/usr/share/initramfs-tools/scripts/live-bottom/ cat <<99START > config/chroot_local-includes/usr/share/initramfs-tools/scripts/live-bottom/99script #!/bin/sh cat < /root/etc/rc.local #! /bin/sh pelican_boot_setup RC_LOCAL chmod a+x /root/etc/rc.local 99START chmod +x config/chroot_local-includes/usr/share/initramfs-tools/scripts/live-bottom/99script lh_build cd "$THISDIR/$ARCHITECTURE" mv "$THISDIR/$ARCHITECTURE/$LIVECDDIR"/tftpboot "$THISDIR/$ARCHITECTURE"/ # safeguard against crashes umount proc-live umount sysfs-live umount devpts-live sync rm -R -f "$THISDIR/$ARCHITECTURE/$LIVECDDIR" ############## end of compute node configuration ################### # frontend configuration LIVECDDIR="frontend" # uncomment the next line if you really want to start from scratch #rm -R -f "$LIVECDDIR" mkdir "$THISDIR/$ARCHITECTURE/$LIVECDDIR" cd "$THISDIR/$ARCHITECTURE/$LIVECDDIR" lh_config --apt apt --apt-recommends disabled lh_config -a "$ARCHITECTURE" lh_config --categories "main contrib non-free" lh_config -b "$IMAGETYPE" lh_config -d "$DISTRIBUTION" lh_config -k "$KERNEL" lh_config --mirror-binary http://ftp.$MIRROR.debian.org/debian/ \ --mirror-chroot http://ftp.$MIRROR.debian.org/debian/ \ --mirror-bootstrap http://ftp.$MIRROR.debian.org/debian/ \ --mirror-binary-security http://security.eu.debian.org/ \ --mirror-chroot-security http://security.eu.debian.org lh_config -p "addlist" lh_config --hostname pelican lh_config --iso-volume PelicanHPC lh_config --syslinux-timeout 20 lh_config --syslinux-menu "enabled" lh_config --bootappend-live "ramdisk_size=100000 noautologin noxautologin" lh_clean # SYSLINUX SPLASH SCREEN if [ -e "$THISDIR/splash.rle" ]; then cp "$THISDIR"/splash.rle config/binary_syslinux/splash.rle lh_config --syslinux-splash "config/binary_syslinux/splash.rle" fi # PACKAGE LIST cp "$THISDIR"/addlist config/chroot_local-packageslists ########## make directories on chroot ######### install -d config/chroot_local-includes/usr/bin install -d config/chroot_local-includes/usr/share/pelican/tftpboot rm -R -f config/chroot_local-includes/etc/skel install -d config/chroot_local-includes/etc/skel ########## copy stuff to be added to chroot ###### rsync -az "$THISDIR/$ARCHITECTURE"/tftpboot/* config/chroot_local-includes/usr/share/pelican/tftpboot rsync -az "$THISDIR"/pelicanhome/* config/chroot_local-includes/etc/skel rsync -az "$THISDIR"/packages/* config/chroot_local-packages # chroot hook to compile stuff in /etc/skel cat < config/chroot_local-hooks/script.sh #!/bin/bash update-initramfs -u -k all if [ -d "/etc/skel/Econometrics" ]; then LOCATION="/etc/skel/Econometrics" ############ MPITB ############ cd \$LOCATION/MyOctaveFiles/mpitb/src make clean make -j8 cd \$LOCATION/MyOctaveFiles/mpitb/DLD FILES="*.oct" for f in "\$FILES"; do strip \$f; done ############ my oct files############ cd \$LOCATION/MyOctaveFiles/OctFiles echo "making my .cc files" make clean make all FILES="*.oct" for f in "\$FILES"; do strip \$f; done ######### PEA ########### cd \$LOCATION/Examples/Parallel/pea/example mkoctfile *.cc FILES="*.oct" for f in "\$FILES"; do strip \$f; done fi CHROOTHOOK chmod +x config/chroot_local-hooks/script.sh ######## WRITE THE PELICAN SETUP SCRIPTS ############# cat <<01SETUP > config/chroot_local-includes/usr/bin/pelican_boot_setup #!/bin/bash PATH="/bin:/sbin:/usr/bin:/usr/sbin" export PATH TMP="/tmp/pelican_setup.tmp\$\$" DIALOG="dialog" TITLE="Pelican Setup" exec >/dev/console &1 NORMAL="" RED="" GREEN="" YELLOW="" BLUE="" MAGENTA="" CYAN="" WHITE="" bailout(){ # set user password \$DIALOG --title "\$TITLE" --inputbox "Welcome to PelicanHPC. Please type in a password, and then press to continue" 15 50 "PleaseChangeMe!" 2>/home/user/pw chmod 644 /home/user/pw read PASSWORD /etc/motd echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config # test for master or compute node: $PELICAN_NETWORK will only be there at boot if this is a compute node computenode=\`dmesg | grep -c nfsroot=$PELICAN_NETWORK\` if [ \$computenode = 0 ]; then # master node rm -R -f /home mkdir /home mkfs.ext2 -q -m 0 /dev/ram1 rm -f "\$TMP" \$DIALOG --title "\$TITLE" --inputbox "Do NOT type anything into this input box, it \ is only for the convenience of advanced users who have experience using PelicanHPC, and who have read the documentation to \ learn what it is used for. Press to continue" 15 50 "ram1" 2>"\$TMP" read HOMELOCATION <"\$TMP" ; rm -f "\$TMP" mount /dev/\$HOMELOCATION /home install -d /home/user MESSAGE="Copy user configuration and examples /home/user? You should probably choose YES unless you are using a specially made vesion of PelicanHPC that uses a permanent storage device, and you already have a setup you would like to keep." \$DIALOG --defaultno --title "\$TITLE" --yesno "\$MESSAGE" 10 50 || bailout rsync -avz /etc/skel/ /home/user/ # make .octaverc cat < /home/user/.octaverc edit 'editor' 'kate %s &' page_screen_output(0); addpath(genpath("/home/user/Econometrics/MyOctaveFiles")); addpath(genpath("/home/user/Econometrics/Examples")); putenv('MPITB_HOME', ['/home/user/Econometrics/MyOctaveFiles/mpitb']); warning("off","MPITB:Address-verbose") % verbose MPI_Address warning("off","MPITB:getBuff-mk-unique") % lazycopied vars -> duplicated warning("off","MPITB:getBuff-above-cnt") % lazycopied vars (>2 copies) warning("off","MPITB:getBuff-normalcnt") % vars with exactly 2 copies if isempty(getenv('LAMPARENT')) disp('Welcome to Octave with MPITB'); else history -w /dev/null % I don't want to see that! startup_NumCmds; endif OCTAVERC # Start up xfce4 install -d /home/user/.config/autostart echo "[Desktop Entry]" >> /home/user/.config/autostart/xfce4-tips-autostart.desktop echo "Hidden=true" >> /home/user/.config/autostart/xfce4-tips-autostart.desktop # echo "/usr/bin/startx" >> /home/user/.bash_profile # uncomment to make entry into GUI automatic # support software compiled using older Open MPI ln -s /usr/lib/openmpi/lib/libopen-rte.so.0.0.0 /usr/lib/openmpi/lib/liborte.so.0 ln -s /usr/lib/openmpi/lib/libopen-pal.so.0.0.0 /usr/lib/openmpi/lib/libopal.so.0 bailout # for the compute nodes else rm -R -f /home mkdir /home mount $PELICAN_NETWORK.1:/home /home myip=(\`/sbin/ifconfig | grep -i "Ethernet" -A 1|grep "inet addr"|cut -d " " -f 12|cut -d ":" -f 2\`) echo "\$myip is up" > /home/user/tmp/\$myip # support software compiled using older Open MPI ln -s /usr/lib/openmpi/lib/libopen-rte.so.0.0.0 /usr/lib/openmpi/lib/liborte.so.0 ln -s /usr/lib/openmpi/lib/libopen-pal.so.0.0.0 /usr/lib/openmpi/lib/libopal.so.0 bailout2 fi 01SETUP cat <<02USERSETUP > config/chroot_local-includes/usr/bin/pelican_setup pelican_setup_user pelican_setup_netdevice pelican_terminalserver pelican_restart_hpc 02USERSETUP cat <<03USER > config/chroot_local-includes/usr/bin/pelican_setup_user #!/bin/bash bailout(){ exit \$1 } cd /home/user HOME="/home/user" PKTMP="\$HOME/tmp" echo "Creating temporary directory" rm -R -f \$PKTMP mkdir \$PKTMP chown user.user \$PKTMP chmod 777 \$PKTMP # regenerate keys echo "Generating new RSA keys" rm -f \$HOME/.ssh/id_rsa* ssh-keygen -q -t rsa -N "" -f "\$HOME/.ssh/id_rsa" cp \$HOME/.ssh/id_rsa.pub \$HOME/.ssh/authorized_keys chmod 600 \$HOME/.ssh/authorized_keys # make list of hosts to fping echo "$PELICAN_NETWORK.2" > \$HOME/fpinghosts i=2 while [ \$i -lt $MAXNODES ] do i=\`expr \$i + 1\` echo $PELICAN_NETWORK.\$i >> \$HOME/fpinghosts done bailout 03USER cat <<04NETDEVICE > config/chroot_local-includes/usr/bin/pelican_setup_netdevice #!/bin/bash # modification of netcardconfig from Knoppix. PATH="/bin:/sbin:/usr/bin:/usr/sbin" export PATH DIALOG="dialog" [ "\`id -u\`" != "0" ] && exec sudo "\$0" "\$@" TMP="/tmp/netconfig.tmp\$\$" bailout(){ rm -f "\$TMP" exit \$1 } TITLE="Pelican Setup" MESSAGE0="No supported network cards found." MESSAGE1="Please select the network device that connects to the cluster." NETDEVICES="\$(cat /proc/net/dev | awk -F: '/eth.:|br.:|tr.:|wlan.:/{print \$1}')" if [ -z "\$NETDEVICES" ]; then \$DIALOG --title "\$TITLE" --msgbox "\$MESSAGE0" 5 30 bailout fi count="\$(echo "\$NETDEVICES" | wc -w)" if [ "\$count" -gt 1 ]; then DEVICELIST="" for DEVICE in \$NETDEVICES; do DEVICELIST="\$DEVICELIST \${DEVICE} network_device_\${DEVICE}"; done rm -f "\$TMP" echo "Hints about your net devices" dmesg|grep eth rm -f "\$TMP" \$DIALOG --menu "\$MESSAGE1" 18 45 12 \$DEVICELIST 2>"\$TMP" || bailout read DV <"\$TMP" ; rm -f "\$TMP" else # Remove additional spaces DV="\$(echo \$NETDEVICES)" fi IP="$PELICAN_NETWORK.1" NM="255.255.255.0 " BC="$PELICAN_NETWORK.255" ifdown \$DV sleep 4 CMD="ifconfig \$DV \$IP netmask \$NM broadcast \$BC up" \$CMD bailout 04NETDEVICE cat <<05TERMINALSERVER > config/chroot_local-includes/usr/bin/pelican_terminalserver #!/bin/sh PATH="/bin:/sbin:/usr/bin:/usr/sbin" export PATH DIALOG="dialog" [ "\`id -u\`" != "0" ] && exec sudo "\$0" "\$@" bailout(){ exit \$1 } cp -a /usr/share/pelican/tftpboot/* /var/lib/tftpboot/ # configure dhcp cat < /etc/dhcp3/dhcpd.conf # global settings allow booting; allow bootp; default-lease-time 600; max-lease-time 7200; subnet $PELICAN_NETWORK.0 netmask 255.255.255.0 { next-server $PELICAN_NETWORK.1; filename "pxelinux.0"; option subnet-mask 255.255.255.0; range $PELICAN_NETWORK.2 $PELICAN_NETWORK.$MAXNODES; } DHCP # tftpd - use one or the other # configure tftpd-hpa #cat < /etc/default/tftpd-hpa #Defaults for tftpd-hpa #RUN_DAEMON="yes" #OPTIONS="-l -s /var/lib/tftpboot" #TFTP # configure atftpd cat < /etc/default/atftpd USE_INETD=false OPTIONS="--daemon --port 69 --tftpd-timeout 300 --retry-timeout 5 --mcast-port 1758 --mcast-addr 239.239.239.0-255 --mcast-ttl 1 --maxthread 100 --verbose=5 /var/lib/tftpboot" TFTP # generate /etc/exports cat < /etc/exports /live/image *(ro,async,no_subtree_check,no_root_squash,fsid=12345) /home $PELICAN_NETWORK.0/255.255.255.0(rw,root_squash,async,no_subtree_check) EXPORTS # start services TITLE="Start Pelican HPC netboot services" MESSAGE="We now get ready to set up the cluster by starting services that will allow the compute nodes to netboot. \ IMPORTANT: do not proceed if your cluster is on an existing network, or PelicanHPC's dhcp server may conflict \ with a running dhcp server. Continue?" \$DIALOG --title "\$TITLE" --yesno "\$MESSAGE" 15 90 || bailout sync /etc/init.d/atftpd start /etc/init.d/dhcp3-server start /etc/init.d/nfs-kernel-server start bailout 05TERMINALSERVER cat <<06HPC > config/chroot_local-includes/usr/bin/pelican_restart_hpc #!/bin/sh PKTMP="/home/user/tmp" PATH="/bin:/sbin:/usr/bin:/usr/sbin" export PATH DIALOG="dialog" bailout(){ exit 0 } # check which nodes are up checknodes(){ rm \$PKTMP/bhosts sudo fping -a -q -r0 -f /home/user/fpinghosts > \$PKTMP/bhosts } retry(){ checknodes NNODES="\$(grep -c "" \$PKTMP/bhosts)" MESSAGENODES="\nGo turn on your compute nodes now. \n\nAt the moment \$NNODES compute nodes (not counting this frontend node) are available. \n\nClick no to rescan the available nodes. Click yes when the desired number of nodes are available. You might want to wait a bit if some nodes are still finishing booting up." \$DIALOG --title "\$TITLE" --defaultno --yesno "\$MESSAGENODES" 20 50 || retry } trap bailout 1 2 3 15 TITLE="Restart Pelican HPC" MESSAGE="\nTime to bring the compute nodes into the cluster. If you are resizing a running cluster, be aware that continuing will interrupt any running MPI jobs. Continue?" \$DIALOG --title "\$TITLE" --yesno "\$MESSAGE" 15 90 || bailout retry # master must be last in the list echo "$PELICAN_NETWORK.1" | cat >> \$PKTMP/bhosts # lamboot 2X to generate known_hosts (and an error message) the first time lamwipe lamboot \$PKTMP/bhosts lamwipe lamboot \$PKTMP/bhosts lamnodes sleep 5 # display success message NNODES="\$(grep -c "" \$PKTMP/bhosts)" # final report SUCCESS="\nYour cluster of \$NNODES nodes is (probably) lambooted. If there was a problem, just re-run the script.\nThe nodes in the cluster are listed in the file ~/tmp/bhosts. If you add or remove compute nodes, re-run this script (pelican_restart_hpc) whenever you like." \$DIALOG --title "\$TITLE" --msgbox "\$SUCCESS" 15 50 bailout 06HPC ######## END OF PELICAN SETUP SCRIPTS ############# ######## POST BOOT SCRIPT #################### install -d config/chroot_local-includes/usr/share/initramfs-tools/scripts/live-bottom/ cat <<99START > config/chroot_local-includes/usr/share/initramfs-tools/scripts/live-bottom/99script #!/bin/sh cat < /root/etc/rc.local #! /bin/sh pelican_boot_setup RC_LOCAL chmod a+x /root/etc/rc.local 99START chmod +x config/chroot_local-includes/usr/share/initramfs-tools/scripts/live-bottom/99script # make the scripts in /usr/bin executable chmod +x config/chroot_local-includes/usr/bin/* # build the ISO image nice ionice -c2 lh_build --debug # safeguard against crashes umount proc-live umount sysfs-live umount devpts-live sync