#!/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 # Version 1.0 - initial release, 07 Jan 2008 PELICAN_NETWORK="10.11.12" #ARCHITECTURE="amd64" ARCHITECTURE="i386" DISTRIBUTION="lenny" mkdir $ARCHITECTURE cd $ARCHITECTURE ############## tftpboot stuff for nodes ########## # 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 $LIVECDDIR # mkdir $LIVECDDIR # cd $LIVECDDIR # lh_config \ # -a $ARCHITECTURE \ # -b net \ # -d $DISTRIBUTION \ # --net-root-server "$PELICAN_NETWORK.1" \ # --net-root-path "/live/image" \ # --syslinux-timeout 20 # lh_clean # lh_build # cd ../ # mv $LIVECDDIR/tftpboot ./ # rm -R -f $LIVECDDIR ############## end of tftpboot stuff ################### # frontend LIVECDDIR="frontend/" # uncomment the next line if you really want to start from scratch # rm -R -f $LIVECDDIR mkdir $LIVECDDIR cd $LIVECDDIR lh_config \ --syslinux-timeout 20 \ -a $ARCHITECTURE \ -d $DISTRIBUTION \ --hostname pelican \ --iso-volume PelicanHPC \ --syslinux-splash 'config/binary_syslinux/splash.rle' lh_clean # syslinux splash screen cp ../splash.rle 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 # MPI lam4c2 lam-runtime lam4-dev openmpi-bin openmpi-dev # Octave octave2.9 octave2.9-headers gnuplot # X stuff xorg fluxbox bbpager bbrun fbdesk fbpager fluxconf rox konqueror ksysguard ksysguardd kate kdelibs konsole PACKAGELIST ################## END OF PACKAGELIST ################ ######### hacks on the chroot ############## cat < config/chroot_local-hooks/hook01.sh echo "$PELICAN_NETWORK.1:/home /home nfs defaults 0 0" > /etc/fstab echo "" > /etc/motd echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config HACKS chmod +x config/chroot_local-hooks/hook01.sh ########## make directories on chroot ######### mkdir config/chroot_local-includes/usr mkdir config/chroot_local-includes/usr/bin mkdir config/chroot_local-includes/usr/share mkdir config/chroot_local-includes/usr/share/pelican mkdir config/chroot_local-includes/usr/share/pelican/tftpboot ######## WRITE THE PELICAN SETUP SCRIPTS ############# cat <<01SETUP > config/chroot_local-includes/usr/bin/pelican_setup #!/bin/bash bailout(){ exit \$1 } DIALOG="dialog" TITLE="Pelican Setup" MESSAGE="Welcome to Pelican. A short setup routine is needed. Continue?" \$DIALOG --title "\$TITLE" --yesno "\$MESSAGE" 10 50 || bailout cd / pelican_setup_frontend pelican_setup_user pelican_setup_netdevice pelican_terminalserver pelican_restart_hpc cd /home/user bailout 01SETUP cat <<02FRONTEND > config/chroot_local-includes/usr/bin/pelican_setup_frontend #!/bin/bash PATH="/bin:/sbin:/usr/bin:/usr/sbin" export PATH DIALOG="dialog" [ "\`id -u\`" != "0" ] && exec sudo "\$0" "\$@" bailout(){ exit \$1 } # make home dir cd / rm -R -f /home mkdir /home mkfs.ext2 -q -m 0 /dev/ram1 mount /dev/ram1 /home mkdir /home/user chown user.user /home/user sync # start ssh /etc/init.d/ssh start # make xorg.conf dpkg-reconfigure --priority=high xserver-xorg bailout 02FRONTEND 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 # copy examples rsync -avz /usr/share/pelican/CopyToHome/* \$HOME cat < \$HOME/fpinghosts $PELICAN_NETWORK.2 $PELICAN_NETWORK.3 $PELICAN_NETWORK.4 $PELICAN_NETWORK.5 $PELICAN_NETWORK.6 $PELICAN_NETWORK.7 $PELICAN_NETWORK.8 $PELICAN_NETWORK.9 $PELICAN_NETWORK.10 $PELICAN_NETWORK.11 $PELICAN_NETWORK.12 $PELICAN_NETWORK.13 $PELICAN_NETWORK.14 $PELICAN_NETWORK.15 $PELICAN_NETWORK.16 $PELICAN_NETWORK.17 $PELICAN_NETWORK.18 $PELICAN_NETWORK.19 $PELICAN_NETWORK.20 $PELICAN_NETWORK.21 $PELICAN_NETWORK.22 $PELICAN_NETWORK.23 $PELICAN_NETWORK.24 $PELICAN_NETWORK.25 $PELICAN_NETWORK.26 $PELICAN_NETWORK.27 $PELICAN_NETWORK.28 $PELICAN_NETWORK.29 $PELICAN_NETWORK.30 $PELICAN_NETWORK.31 $PELICAN_NETWORK.32 $PELICAN_NETWORK.33 $PELICAN_NETWORK.34 $PELICAN_NETWORK.35 $PELICAN_NETWORK.36 $PELICAN_NETWORK.37 $PELICAN_NETWORK.38 $PELICAN_NETWORK.39 $PELICAN_NETWORK.40 $PELICAN_NETWORK.41 $PELICAN_NETWORK.42 $PELICAN_NETWORK.43 $PELICAN_NETWORK.44 $PELICAN_NETWORK.45 $PELICAN_NETWORK.46 $PELICAN_NETWORK.47 $PELICAN_NETWORK.48 $PELICAN_NETWORK.49 $PELICAN_NETWORK.50 $PELICAN_NETWORK.51 $PELICAN_NETWORK.52 $PELICAN_NETWORK.53 $PELICAN_NETWORK.54 $PELICAN_NETWORK.55 $PELICAN_NETWORK.56 $PELICAN_NETWORK.57 $PELICAN_NETWORK.58 $PELICAN_NETWORK.59 $PELICAN_NETWORK.60 $PELICAN_NETWORK.61 $PELICAN_NETWORK.62 $PELICAN_NETWORK.63 $PELICAN_NETWORK.64 $PELICAN_NETWORK.65 $PELICAN_NETWORK.66 $PELICAN_NETWORK.67 $PELICAN_NETWORK.68 $PELICAN_NETWORK.69 $PELICAN_NETWORK.70 $PELICAN_NETWORK.71 $PELICAN_NETWORK.72 $PELICAN_NETWORK.73 $PELICAN_NETWORK.74 $PELICAN_NETWORK.75 $PELICAN_NETWORK.76 $PELICAN_NETWORK.77 $PELICAN_NETWORK.78 $PELICAN_NETWORK.79 $PELICAN_NETWORK.80 $PELICAN_NETWORK.81 $PELICAN_NETWORK.82 $PELICAN_NETWORK.83 $PELICAN_NETWORK.84 $PELICAN_NETWORK.85 $PELICAN_NETWORK.86 $PELICAN_NETWORK.87 $PELICAN_NETWORK.88 $PELICAN_NETWORK.89 $PELICAN_NETWORK.90 $PELICAN_NETWORK.91 $PELICAN_NETWORK.92 $PELICAN_NETWORK.93 $PELICAN_NETWORK.94 $PELICAN_NETWORK.95 $PELICAN_NETWORK.96 $PELICAN_NETWORK.97 $PELICAN_NETWORK.98 $PELICAN_NETWORK.99 $PELICAN_NETWORK.100 FPING 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" DG="$PELICAN_NETWORK.254" NS=\$DG ifdown \$DV sleep 4 rm /etc/network/interfaces 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.100; } 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 (end error) 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 ############# # make the scripts in /usr/bin executable chmod +x config/chroot_local-includes/usr/bin/* # copy the setup scripts rsync -avz ../pelican_includes/* config/chroot_local-includes/usr/share/pelican # copy the PXE stuff rsync -avz ../tftpboot/* config/chroot_local-includes/usr/share/pelican/tftpboot lh_build