#!/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. # Version 1.7.1 # new since 1.7: # a few little fixes to make a generic (without examples) image work better ############ packages to add - place names of packages you want here #################### cat < addlist # basic network stuff ssh dhcp3-server nfs-kernel-server atftpd #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 ################ PELICAN_NETWORK="10.11.12" MAXNODES="20" PASSWORD="live" #ARCHITECTURE="amd64" #KERNEL="amd64" ARCHITECTURE="i386" KERNEL="686" 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 -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 "quiet vga=791 noautologin noxautologin" lh_config --syslinux-timeout 10 lh_clean # use local packages if they're there cp -a "$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 -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 --bootappend-live "quiet vga=791 ramdisk_size=100000" 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 ###### cp -a "$THISDIR/$ARCHITECTURE"/tftpboot/* config/chroot_local-includes/usr/share/pelican/tftpboot cp -a "$THISDIR"/pelicanhome/* config/chroot_local-includes/etc/skel cp -a "$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 # Clean input/output exec >/dev/console &1 bailout(){ chown -R user.user /home/user exit \$1 } bailout2(){ echo "All done setting up this PelicanHPC compute node" echo "" echo -n "" echo "This is a PelicanHPC 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 DON'T TURN IT OFF!" echo "" echo "THANKS!" exit \$1 } DIALOG="dialog" TITLE="Pelican Setup" echo "Welcome to PelicanHPC!" # 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=\`dmesg | grep -c nfsroot=$PELICAN_NETWORK\` if [ \$computenode = 0 ]; then # master node # dpkg-reconfigure --priority=high xserver-xorg rm -R -f /home mkdir /home mkfs.ext2 -q -m 0 /dev/ram1 mount /dev/ram1 /home install -d /home/user/.config/autostart rsync -avz /etc/skel/* /home/user touch /home/user/octaverc mv /home/user/octaverc /home/user/.octaverc 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 bailout 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 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 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 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="\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 #################### 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 # safeguard against crashes umount proc-live umount sysfs-live umount devpts-live sync