#!/bin/sh # Copyright 2007, 2008 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. # A custom version made with this script will not have the Octave and HPL # examples. # Version 1.5.1 # new since 1.5: update packages, especially libssl. At fail2ban # list of packages (below) PELICAN_NETWORK="10.11.12" MAXNODES="20" PASSWORD="live" HOMELOCATION="ram1" #ARCHITECTURE="amd64" #KERNEL="amd64" ARCHITECTURE="i386" KERNEL="686" DISTRIBUTION="lenny" DEBIAN_MIRROR="http://ftp.de.debian.org/debian/" # leave the rest of this alone, except for the package list, # and perhaps commenting out the block for the nodes after you # have made it one time 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 -b net lh_config -d "$DISTRIBUTION" lh_config -k "$KERNEL" lh_config --mirror-bootstrap "$DEBIAN_MIRROR" 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_clean # don't uncomment this unless you have a splash screen file "splash.rle" # cp "$THISDIR"/splash.rle config/binary_syslinux/splash.rle # lh_config --syslinux-splash "config/binary_syslinux/splash.rle" # post boot script, thanks to forum user maddanio for this 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"/ umount proc-live umount sysfs-live umount devpts-live sync rm -R -f "$THISDIR/$ARCHITECTURE/$LIVECDDIR" ############## end of compute node configuration ################### # frontend 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 --mirror-bootstrap "$DEBIAN_MIRROR" lh_config --apt apt --apt-recommends disabled lh_config -a "$ARCHITECTURE" lh_config -d "$DISTRIBUTION" lh_config -k "$KERNEL" lh_config --hostname pelican lh_config --iso-volume PelicanHPC lh_config --syslinux-timeout 20 lh_config --bootappend-live "ramdisk_size=200000" lh_clean # don't uncomment this unless you have a splash screen file "splash.rle" # cp "$THISDIR"/splash.rle config/binary_syslinux/splash.rle # lh_config --syslinux-splash "config/binary_syslinux/splash.rle" ############ packages to add #################### cat < config/chroot_local-packageslists/addlist # basic network stuff ssh dhcp3-server nfs-kernel-server tftpd-hpa # configuration and tools wget bzip2 dialog less net-tools rsync fping screen make htop fail2ban # 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 kpdf konsole kcontrol kdenetwork kdeadmin PACKAGELIST ################## END OF PACKAGELIST ################ ########## 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 -avz "$THISDIR/$ARCHITECTURE"/tftpboot/* config/chroot_local-includes/usr/share/pelican/tftpboot # rsync -avz "$THISDIR"/pelicanhome/* config/chroot_local-includes/etc/skel # rsync -avz "$THISDIR"/packages/*.deb config/chroot_local-packages # # # chroot hook to compile stuff in /etc/skel # cat < config/chroot_local-hooks/script.sh # #!/bin/bash # LOCATION="/etc/skel/Econometrics" # cd \$LOCATION/MyOctaveFiles/mpitb/src # make clean # make -j2 # cd \$LOCATION/MyOctaveFiles/OctFiles # echo "making my .cc files" # make clean # make all # cd \$LOCATION/Examples/Parallel/pea/example # mkoctfile *.cc # #cd \$LOCATION/MyOctaveFiles/snm # #mkoctfile *.cc # 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 # Clean input/output exec >/dev/console &1 # Reset fb color mode - borrowed from Knoppix RESET="]R" # ANSI COLORS # Erase to end of line CRE=" " # Clear and reset Screen CLEAR="c" # Normal color NORMAL="" # RED: Failure or error message RED="" # GREEN: Success message GREEN="" # YELLOW: Descriptions YELLOW="" # BLUE: System mesages BLUE="" # MAGENTA: Found devices or drivers MAGENTA="" # CYAN: Questions CYAN="" # BOLD WHITE: Hint WHITE="" # Clear screen with colormode reset # echo "\$CLEAR\$RESET" # echo "\$CLEAR" # Just go to the top of the screen # echo -n "" echo "" bailout(){ chown -R user.user /home/user echo -n "" echo "\${GREEN}Welcome to \${CYAN}PelicanHPC\${GREEN}. The frontend node is ready to use." echo "type \${YELLOW}\"startx\"\${GREEN} to use XFCE" echo "type \${YELLOW}\"pelican_setup\"\${GREEN} to set up up a cluster\${NORMAL}" exit \$1 } bailout2(){ echo "\${GREEN} * All done setting up this \${CYAN}PelicanHPC\${GREEN} compute node\${NORMAL}" echo "" sleep 4 echo -n "" echo "\${GREEN}This is a \${CYAN}PelicanHPC \${GREEN}compute node. It is part of a cluster of computers that is doing some REALLY important stuff." echo "" echo "Please don't try to use it, and \${RED}DON'T TURN IT OFF!" echo "" echo "\${GREEN}THANKS!\${BLUE}" exit \$1 } DIALOG="dialog" TITLE="Pelican Setup" echo "\${GREEN}Welcome to \${CYAN}PelicanHPC!\${NORMAL}" echo "" sleep 4 # things for both frontend and nodes echo "" > /etc/motd echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config echo "user:$PASSWORD" | chpasswd # test for master or compute node: $PELICAN_NETWORK will only be there at boot if this is a compute node computenode=\`mount | grep -c $PELICAN_NETWORK\` if [ \$computenode = 0 ]; then # master node echo "\${GREEN}This is the \${CYAN}PelicanHPC\${GREEN} \${YELLOW}frontend \${GREEN}node - doing initial post-boot setup\${NORMAL}" sleep 4 dpkg-reconfigure --priority=high xserver-xorg rm -R -f /home mkdir /home mkfs.ext2 -q -m 0 /dev/ram1 mount /dev/$HOMELOCATION /home mkdir /home/user MESSAGE="Copy the example files to /home/user? Careful with this if you are using permanent storage for /home and you have already modified the example files. If this is the first time you use Pelican, you should choose yes." \$DIALOG --defaultno --title "\$TITLE" --yesno "\$MESSAGE" 10 50 || bailout rsync -avz /etc/skel/* /home/user bailout else echo "\${GREEN}This is a \${CYAN}PelicanHPC\${GREEN} \${YELLOW}compute \${GREEN}node - doing the initial post-boot setup${NORMAL}" sleep 4 echo "\${GREEN} * mounting NFS-shared directories\${NORMAL}" rm -R -f /home mkdir /home mount $PELICAN_NETWORK.1:/home /home echo "\${GREEN} * reporting to master node that this compute node is ready\${NORMAL}" 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 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" 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 [ "\`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 # configure tftpd-hpa cat < /etc/default/tftpd-hpa #Defaults for tftpd-hpa RUN_DAEMON="yes" OPTIONS="-l -s /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 sync /etc/init.d/tftpd-hpa 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" --yesno "\$MESSAGENODES" 20 50 || retry } trap bailout 1 2 3 15 TITLE="Restart Pelican HPC" MESSAGE="\nWe now set up the cluster by finding which nodes are available. If you are doing initial setup, click on yes. If you are resizing a running cluster, be aware that continuing will interrupt any running MPI jobs. Click no abort resizing." \$DIALOG --title "\$TITLE" --yesno "\$MESSAGE" 15 50 || 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 #################### # thanks to forum user maddanio for this 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 lh_build umount proc-live umount sysfs-live umount devpts-live sync