aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'catalyst/livecd/2008.0/overlay/usr/sbin/cluster-setup')
-rwxr-xr-xcatalyst/livecd/2008.0/overlay/usr/sbin/cluster-setup93
1 files changed, 74 insertions, 19 deletions
diff --git a/catalyst/livecd/2008.0/overlay/usr/sbin/cluster-setup b/catalyst/livecd/2008.0/overlay/usr/sbin/cluster-setup
index 9675ad8..8d95ca8 100755
--- a/catalyst/livecd/2008.0/overlay/usr/sbin/cluster-setup
+++ b/catalyst/livecd/2008.0/overlay/usr/sbin/cluster-setup
@@ -4,9 +4,9 @@
# This script is written so parts can be reused for liveCD mounting...eventually ;)
. /mnt/livecd/sbin/functions.sh
-CDROOT=/mnt/livecd/
-MKDIR=${CDROOT}/bin/mkdir
-MODPROBE=${CDROOT}/sbin/modprobe
+CONFDIR="/etc/gentoo"
+CLUSTER_CONF="$CONFDIR/cluster.conf"
+LDAP_CONF="$CONFDIR/ldap_auth.conf"
conf_error() {
eerror "CONFIG_OK is not set to 'yes' in $1"
@@ -19,6 +19,10 @@ conf_error() {
}
aufs_mount() {
+ CDROOT=/mnt/livecd/
+ MKDIR=${CDROOT}/bin/mkdir
+ MODPROBE=${CDROOT}/sbin/modprobe
+
$MODPROBE aufs || eerror "Got $? while probing for aufs module!"
# Looping this simply because it should replace the current tmpfs mounting of the liveCD :P
for I in tftproot
@@ -43,19 +47,56 @@ do_conf() {
}
# This could have been inlined into do_conf but we would rather check configs _before_
-# we do anything...we could be a little mode selective than /etc/gentoo/* though
+# we do anything...we could be a little mode selective than $CONFDIR/* though
check_conf() {
einfo "Checking config files.."
- for I in /etc/gentoo/*
+ for I in $CONFDIR/*.conf
do
. $I
[[ $CONFIG_OK == "yes" ]] || conf_error $I
done
}
+# This function has to be called after the $CLUSTER_CONF file has been sourced
+# Required external vars:
+# CLUSTER_CONF:NFSROOT
+config_ssh(){
+ KEY_NAME="node_dsa"
+ NETADDR="$(sipcalc ${CLUSTER_ETH} | egrep 'Network address' | cut -d- -f2)"
+ # The following is needed because $HOME is set to / on the livecd console for some reason
+ HDIR="/root"
+
+ pushd $PWD
+
+ einfo "Setting up passwordless ssh for root between master and the nodes"
+ mkdir -p $HDIR/.ssh/ $NFSROOT/root/.ssh/
+ cd $HDIR/.ssh/
+ ssh-keygen -t dsa -b 1024 -f $KEY_NAME -N ""
+ cat $KEY_NAME.pub >> $NFSROOT/root/.ssh/authorized_keys
+ cat >> $HDIR/.ssh/config <<-EOF
+ # Auto-generated by $0 to ease the use of passwordless logins for all users
+ # Although this approach is questionnable, it's also one of the only way
+ # to automate some of the master-node configuration/discovery process
+ # until an Avahi-style approach is implemented.
+ Host *.gentoo.local ${NETADDR%.[09]*}.* node*
+ IdentityFile $HDIR/.ssh/$KEY_NAME
+ StrictHostKeyChecking no
+ UserKnownHostsFile /dev/null
+ CheckHostIP no
+ Compression no
+ EOF
+
+ echo "# we don't use IPV6, the following setting removes undue delays that would be added" >> /etc/ssh/ssh_config
+ echo "AddressFamily inet" >> /etc/ssh/ssh_config
+
+ chmod 600 $HDIR/.ssh/* $NFSROOT/root/.ssh/*
+ chmod 700 $HDIR/.ssh $NFSROOT/root/.ssh
+ popd
+}
+
####### Main #########
-# speed up the dev cycle by automating some tasks:
+# Speed up the dev cycle by automating some tasks:
if [[ "$1" == "--test" ]]; then
ewarn
ewarn "Yeah...you know what you're doing right?"
@@ -70,17 +111,14 @@ if [[ "$1" == "--test" ]]; then
/etc/init.d/net.eth1 restart
echo root:test | chpasswd
/etc/init.d/sshd start
- sed -i -e's:CONFIG_OK="no":CONFIG_OK="yes":' /etc/gentoo/*
+ sed -i -e's:CONFIG_OK="no":CONFIG_OK="yes":' $CONFDIR/*.conf
fi
check_conf
-aufs_mount
-# After this, all paths should be ok (no need to use relative paths with ${CDROOT}
-
-do_conf /etc/gentoo/ldap_auth.conf "emerge --config =net-nds/ldap-auth-0.1"
-/etc/init.d/slapd start || ewarn "Slapd did not start! See above for error messages...continuing"
+grep -q /mnt/aufs/tftproot /proc/mounts
+[ $? ] && aufs_mount
-. /etc/gentoo/cluster.conf
+. $CLUSTER_CONF
einfo "Making sure $CLUSTER_ETH is configured correctly.."
if [[ "$CLUSTER_ETH" =~ eth.* && $1 != "--test" ]]; then
echo "The cluster's NIC is set as $CLUSTER_ETH with the following config:"
@@ -99,20 +137,37 @@ if [[ "$CLUSTER_ETH" =~ eth.* && $1 != "--test" ]]; then
fi
[[ $ANS == "n" ]] && einfo "You know what you're doing..."
else
- einfo "CLUSTER_ETH is not set to an eth? device: $CLUSTER_ETH"
+ [[ $1 != "--test" ]] && einfo "CLUSTER_ETH is not set to an eth? device: $CLUSTER_ETH"
einfo "Hope you know what you're doing."
fi
-do_conf /etc/gentoo/cluster.conf "emerge --config =sys-cluster/beowulf-head-0.1"
+do_conf $CLUSTER_CONF "emerge --config =sys-cluster/beowulf-head-0.1"
+config_ssh
-# we need to set master and master.$DOMAINNAME to a real IP address for everything to work:
+# we need to set master and master.$DOMAINNAME to a real IP address (not 127.0.0.1) for everything to work:
echo "$(LC_ALL=C ifconfig "eth1" | sed -n -e 's#.*\(inet addr:\|inet \)\([^ ]*\).*#\2#p') $(hostname).$LOCALDOMAINNAME $(hostname)" >> /etc/hosts
-einfo "Setting up auth on the $NFSROOT"
-USE=-authmaster ROOT="$NFSROOT" emerge --config =net-nds/ldap-auth-0.1
-
einfo "We need to refresh resolv.conf and dnsmasq."
einfo "Restarting both $PUBETH and dnsmasq..."
/etc/init.d/net.$PUBETH restart
/etc/init.d/dnsmasq restart
+# This also has to be done with the $CLUSTER_CONF information sourced
+
+# Setting up Torque
+# Checking for pbs USE flag
+portageq envvar USE | grep -q pbs
+
+if [[ $? == 0 ]]; then
+ einfo "Setting up torque on $HOSTNAME and in $NFSROOT"
+ emerge --config =sys-cluster/torque-2.3.3
+ USE=-server ROOT=$NFSROOT emerge --config =sys-cluster/torque-2.3.3
+fi
+
+# we want to do this last, otherwise some name resolution problems might haunt you
+do_conf $LDAP_CONF "emerge --config =net-nds/ldap-auth-0.1"
+/etc/init.d/slapd start || ewarn "Slapd did not start! See above for error messages...continuing"
+einfo "Setting up auth on the $NFSROOT"
+USE=-authmaster ROOT="$NFSROOT" emerge --config =net-nds/ldap-auth-0.1
+
+[[ $? == 0 ]] && einfo "Once you have nodes going, restart Torque (pbs_server)"