From 24b5d26cbcc75685f20948309da3727eba5982d2 Mon Sep 17 00:00:00 2001 From: vallard Date: Fri, 4 Dec 2009 00:55:48 +0000 Subject: [PATCH] creation scripts for statelite nodes git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4718 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- .../xcat/netboot/add-on/statelite/add_passwd | 38 +++++++++ .../xcat/netboot/add-on/statelite/add_ssh | 78 +++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100755 xCAT-server/share/xcat/netboot/add-on/statelite/add_passwd create mode 100755 xCAT-server/share/xcat/netboot/add-on/statelite/add_ssh diff --git a/xCAT-server/share/xcat/netboot/add-on/statelite/add_passwd b/xCAT-server/share/xcat/netboot/add-on/statelite/add_passwd new file mode 100755 index 000000000..e413e906b --- /dev/null +++ b/xCAT-server/share/xcat/netboot/add-on/statelite/add_passwd @@ -0,0 +1,38 @@ +#!/bin/sh + +function usage { + echo + echo "Usage: $MYNAME netboot_rootdir " + echo + echo "e.g." + echo + echo "$MYNAME /install/netboot/fedora8/x86_64/compute/rootimg " + echo +} + +case "$#" in + 1) + ROOTDIR=$1 + ;; + *) + usage >&2 + exit 1 + ;; +esac + +if [ -z "$XCATROOT" ] +then + echo "${MYNAME}: XCATROOT no defined" >&2 + exit 1 +fi + +if [ ! -d $ROOTDIR ] +then + echo "${MYNAME}: root image $ROOTDIR does not exist" >&2 + exit 1 +fi + +# now we put node specific things in here... +cp /etc/passwd $ROOTDIR/etc/ +cp /etc/group $ROOTDIR/etc/ +cp /etc/shadow $ROOTDIR/etc/ diff --git a/xCAT-server/share/xcat/netboot/add-on/statelite/add_ssh b/xCAT-server/share/xcat/netboot/add-on/statelite/add_ssh new file mode 100755 index 000000000..5b74bd06d --- /dev/null +++ b/xCAT-server/share/xcat/netboot/add-on/statelite/add_ssh @@ -0,0 +1,78 @@ +#!/bin/sh + +function usage { + echo + echo "Usage: $MYNAME netboot_rootdir " + echo + echo "e.g." + echo + echo "$MYNAME /install/netboot/fedora8/x86_64/compute/rootimg " + echo +} + +case "$#" in + 1) + ROOTDIR=$1 + ;; + *) + usage >&2 + exit 1 + ;; +esac + +if [ -z "$XCATROOT" ] +then + echo "${MYNAME}: XCATROOT no defined" >&2 + exit 1 +fi + +if [ ! -d $ROOTDIR ] +then + echo "${MYNAME}: root image $ROOTDIR does not exist" >&2 + exit 1 +fi + +if [ -r $ROOTDIR/etc/ssh/sshd_config ] +then + cp $ROOTDIR/etc/ssh/sshd_config $ROOTDIR/etc/ssh/sshd_config.ORIG + sed -i 's/^X11Forwarding .*$/X11Forwarding yes/' $ROOTDIR/etc/ssh/sshd_config + sed -i 's/^KeyRegenerationInterval .*$/KeyRegenerationInterval 0/' $ROOTDIR/etc/ssh/sshd_config + sed -i 's/\(.*MaxStartups.*\)/#\1/' $ROOTDIR/etc/ssh/sshd_config + echo "MaxStartups 1024" >>$ROOTDIR/etc/ssh/sshd_config +fi + +if [ -r $ROOTDIR/etc/ssh/sshd_config ] +then + echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config +fi + +if [ -d /install/postscripts/_ssh ] +then + echo "setup root .ssh" + # this gets the authorized key + cd /install/postscripts/_ssh + mkdir -p $ROOTDIR/root/.ssh + cp -f * $ROOTDIR/root/.ssh + cd - >/dev/null + chmod 700 $ROOTDIR/root/.ssh + chmod 600 $ROOTDIR/root/.ssh/* +fi + +# now we put node specific things in here... +cp /etc/xcat/hostkeys/ssh_host_dsa_key $ROOTDIR/etc/ssh/ +chmod 600 $ROOTDIR/etc/ssh/ssh_host_dsa_key +cp /etc/xcat/hostkeys/ssh_host_rsa_key $ROOTDIR/etc/ssh/ +chmod 600 $ROOTDIR/etc/ssh/ssh_host_rsa_key + +mkdir -p $ROOTDIR/root/.ssh/ +cp /root/.ssh/id_rsa $ROOTDIR/root/.ssh/id_rsa +chmod 600 $ROOTDIR/root/.ssh/id_rsa +cp /root/.ssh/id_rsa.pub $ROOTDIR/root/.ssh/id_rsa.pub +chmod 644 $ROOTDIR/root/.ssh/id_rsa.pub +cp /root/.ssh/config $ROOTDIR/root/.ssh/config +chmod 600 $ROOTDIR/root/.ssh/config + +#chroot $ROOTDIR ssh-keygen -y -f /root/.ssh/id_rsa >/root/.ssh/id_rsa.pub + + +