1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
# 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
}
|