##############################################################################
-# Copyright (c) 2010-2013 Georgia Public Library Service."
+# Copyright (c) 2010-2019 Georgia Public Library Service."
# 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
PURPOSE_="Generate config files needed for Evergreen-ILS Cluster"
SYNOPSIS_="$NAME_"
REQUIRES_="standard GNU commands, apt, dpkg"
- VERSION_="2.00"
- DATE_="2010-11-23; last update: 2019-11-11"
+ VERSION_="2.01"
+ DATE_="2010-11-23; last update: 2019-12-03"
AUTHOR_="Andy Witter <awitter@georgialibraries.org>"
URL_="http://evergreen-ils.org"
CATEGORY_="devel"
then
cp -f "$TMPOSRFNODES" "setup_${NODE_FOLDER}/opensrf_nodes.txt"
cp -f "$TEMPLATEDIR/setup_sshkeys.sh" "setup_${NODE_FOLDER}"
+ cp -f "$TEMPLATEDIR/utility/utility_head_ssh_keys.sh" "setup_${NODE_FOLDER}"
+ cp -f "$TEMPLATEDIR/GenaSYS_FirstRun" "setup_${NODE_FOLDER}"
cp -f "$TEMPLATEDIR/utility/opensrf-crontab" "setup_${NODE_FOLDER}"
cp -f "$TEMPLATEDIR/Net-Z3950-SimpleServer-1.12.tar.gz" "setup_${NODE_FOLDER}"
+ for BRICKHEAD in ${BRICKHEADLIST}
+ do
+ echo "$BRICKHEAD" >> "setup_${NODE_FOLDER}/brickhead_nodes.txt"
+ done
#cp -rf "$TEMPLATEDIR/apache2/websockets" "setup_${NODE_FOLDER}"
fi
if echo ${NODE_FOLDER} | grep -q sip0
echo -e $COL_BR_CYAN"A new config file for GenaSYS has been created and"
echo -e "saved as $COL_YELLOW${NEW_CONFIG_FILE}"$COL_RESET
+echo "DEBUG: BRICKHEADLIST is: ${BRICKHEADLIST}"
+
#rm -rf $TMPFOLDER
echo "Failed to install new crontab for tar_file"
sleep 3
fi
- if [ -e ./setup_sshkeys.sh ]
+ if [ -e ./utility_head_ssh_keys.sh ]
then
- echo;echo;echo "Setting up ssh keys"
- sleep 3
- ./setup_sshkeys.sh
+ echo;echo;echo -e $COL_BR_BLUE"Setting up ssh keys"
+ echo -e $COL_BR_GREEN"*** PLEASE NOTE..."
+ echo "You will have to login as user opensrf"
+ echo "Or su - opensrf from root to complete"
+ echo "the setup of SSH keys to brick heads"$COL_RESET
+ sleep 4
+ cp ./utility_head_ssh_keys.sh /home/opensrf
+ echo >> /home/opensrf/.bashrc >> /home/opensrf/.bashrc
+ echo '### Added by GenaSYS' >> /home/opensrf/.bashrc >> /home/opensrf/.bashrc
+ echo 'if [ -e ./utility_head_ssh_keys.sh ];then' >> /home/opensrf/.bashrc >> /home/opensrf/.bashrc
+ echo ' if [ -e ./.GenaSYS_FirstRun ];then' >> /home/opensrf/.bashrc
+ echo ' ./utility_head_ssh_keys.sh' >> /home/opensrf/.bashrc
+ echo ' rm ./.GenaSYS_FirstRun' >> /home/opensrf/.bashrc
+ echo ' fi' >> /home/opensrf/.bashrc
+ echo 'fi' >> /home/opensrf/.bashrc
else
- echo -e COL_BR_RED"***Warning.. setup_sshkeys.sh is missing"
+ echo -e COL_BR_RED"***Warning.. utility_head_ssh_keys.sh is missing"
fi
else
--- /dev/null
+#!/bin/bash
+
+OPENSRF_HOME="/home/opensrf"
+PUB_KEY="${OPENSRF_HOME}/.ssh/id_rsa.pub"
+
+echo
+echo
+echo
+echo "_______Evergreen Multi-host SSH Key Configuration________"
+echo
+echo "This will generate a ssh key for this host $(hostname) and"
+echo "copy it to all hosts running OpenSRF in this cluster."
+echo
+echo "(1) The user opensrf *MUST* exist on all the target nodes including this one."
+echo "(2) The hostnames for all the nodes in the cluster *MUST* be resolvable on this host."
+echo "(3) All the nodes *MUST* be reachable with SSH from this host."
+echo
+
+read -p "Press [ENTER] to continue or [Ctrl-C] to quit" CONTINUE
+
+if cat /etc/passwd |grep -q opensrf
+then
+ if [ ! -e "$PUB_KEY" ]
+ then
+ echo "Generating Key for this host"
+ echo "Leave passphrase blank. just"
+ echo "press [Enter] when prompted."
+ echo
+ sleep 3
+ su - opensrf -c "ssh-keygen -t rsa"
+ else
+ echo
+ echo "Using existing public key"
+ sleep 1
+ echo
+ fi
+
+ if [ ! -d "$HOME/.ssh" ] ### Workaround for ssh-copy-id mktemp errors.
+ then
+ mkdir ~/.ssh
+ if [ ! -z $SUDO_USER ]
+ then
+ chown $SUDO_USER.$SUDO_USER ~/.ssh
+ fi
+
+ fi
+
+ for NODE in $(cat brick_heads.txt)
+ do
+ echo
+ echo Setting up SSH keys for OpenSRF node: $NODE
+ echo
+ #su - opensrf -c "ssh-copy-id -i $PUB_KEY opensrf@$NODE"
+ ssh-copy-id -i $PUB_KEY opensrf@$NODE -o StrictHostKeyChecking=no
+ su - opensrf -c "ssh $NODE -o StrictHostKeyChecking=no -C 'echo $NODE OK'"
+ done
+else
+ echo "user opensrf does not exist create the user"
+ echo "before running this program."
+fi