# Copyright 1999-2008 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ DESCRIPTION="This is a meta ebuild that pulls in the packages and some config scripts/files for building the Gentoo Clustering Master node" HOMEPAGE="http://git.overlays.gentoo.org/gitweb/" SRC_URI="" LICENSE="GPL-2" SLOT="0" KEYWORDS="amd64 ~x86" IUSE="autoconfigure" DEPEND="" RDEPEND="net-nds/ldap-auth sys-boot/syslinux net-dns/dnsmasq net-misc/sipcalc net-fs/nfs-utils" CONFPATH="/etc/gentoo" CONFIG_FILE="cluster.conf" gent_ip_config() { CLUSTER_ETH_IP="$(sipcalc ${CLUSTER_ETH} | egrep 'Host address\W*-' | cut -d- -f2)" RANGE_START="$(sipcalc ${CLUSTER_ETH} | egrep 'Host address\W*-' | cut -d- -f2)" IPSTART="${RANGE_START%.*}.$(( ${RANGE_START##*.} +1 ))" IPSTOP="$(sipcalc ${CLUSTER_ETH} | egrep 'Usable range\W*-' | cut -d- -f3)" SUBNET="$(sipcalc ${CLUSTER_ETH} | egrep 'Network mask\W*-' | cut -d- -f2)" NETADDR="$(sipcalc ${CLUSTER_ETH} | egrep 'Network address' | cut -d- -f2)" } dnsmasq_conf() { cat > ${ROOT}/etc/dnsmasq.conf <<-EOF # Public interface except-interface=$ETH # Set up the local-only domain local=/${LOCALDOMAINNAME}/ domain=$LOCALDOMAINNAME expand-hosts # Some netiquette: domain-needed bogus-priv # Send RFC-3397 DNS domain search DHCP option. WARNING: Your DHCP client # probably doesn't support this...... (option 119) dhcp-option=119,$LOCALDOMAINNAME # Domain DNS name dhcp-option=15,$LOCALDOMAINNAME enable-tftp tftp-root=${TFTPROOT} dhcp-authoritative ### Node definitions, this could be in a separate file # Turn on the DHCP server, pass out addresses from $IPSTART to $IPSTOP # with subnet mask of $SUBNET with a 12-hour lease dhcp-range=nodes,$IPSTART,$IPSTOP,$SUBNET,12h # Override the default route supplied by dnsmasq, which assumes the # router is the same machine as the one running dnsmasq. dhcp-option=3,$CLUSTER_ETH_IP # This tells the clients the hostname and IP of the TFTP server dhcp-boot=${PXELINUX},$(hostname),$CLUSTER_ETH_IP # We are the authoritative DHCP server for this network dhcp-authoritative # address and root path of NFS server dhcp-option=17,$CLUSTER_ETH_IP:${NFSROOT} EOF } pxe_conf() { PROFNAME="$(uname -m)_node" BOOTPATH="${NFSROOT##$TFTPROOT}" BOOTPATH="${BOOTPATH#/}/boot" mkdir -p ${TFTPROOT}/pxelinux.cfg cat > ${TFTPROOT}/pxelinux.cfg/default <<-EOF prompt 1 timeout 50 say Press F1 for boot profiles, default is $PROFNAME in 5 seconds... F1 BootProfiles default $PROFNAME label $PROFNAME kernel ${BOOTPATH}/vmlinuz append initrd=/initramfs ramdisk=8192 ip=dhcp root=nfs;tmpfs label local localboot 0 EOF cat > ${TFTPROOT}/BootProfiles <<-EOF Type $PROFNAME for regular bootup (default after 5 seconds) Type local to boot on the local HDD EOF ln -s "${ROOT}/usr/lib/syslinux/pxelinux.0" "${TFTPROOT}/pxelinux.0" } nfs_root_conf() { cat > ${ROOT}/etc/exportfs <<-EOF ${NFSROOT} $NETADDR/$SUBNET(ro,no_root_squash,async,no_subtree_check) EOF mkdir -p ${NFSROOT} einfo "${NFSROOT} has been populated, all configs point to this root" einfo "to boot, furthermore, the fonfigs expect the kernel to be" einfo "${NFSROOT}/boot/vmlinuz" } parse_config() { [[ -f ${1} ]] || die "${1} missing!!! re-emerge ${PF}" if ! use autoconfigure; then . ${1} [[ $CONFIG_OK != "yes" ]] && die "You need to edit ${CONFIG_FILE} and set CONFIG_OK=\"yes\"" fi } src_install() { dodir ${CONFPATH} insinto ${CONFPATH} doins ${FILESDIR}/${TEMPLATE_FILE} if ! use autoconfigure; then elog "You need to edit ${CONFPATH}/${CONFIG_FILE} to your likings" elog "Once you are done, set CONFIG_OK=\"yes\" in there and" elog "call emerge --config =${CATEGORY}/${PF}" fi } pkg_config() { parse_config "${CONFPATH}/${CONFIG_FILE}" dnsmasq_conf pxe_conf nfs_root_conf for I in dnsmasq netmount do rc-update add $I default done }