cloud-set-guest-sshkey script (used by sshKey pair feature, has to be installed on the vm template) is a part of our code base now

This commit is contained in:
alena 2011-03-04 11:30:30 -08:00
parent 40db230095
commit 7cf4c375c2
3 changed files with 51 additions and 0 deletions

View File

@ -520,6 +520,7 @@ fi
%attr(0755,root,root) %{_bindir}/%{name}-setup-databases
%attr(0755,root,root) %{_bindir}/%{name}-migrate-databases
%attr(0755,root,root) %{_bindir}/%{name}-set-guest-password
%attr(0755,root,root) %{_bindir}/%{name}-set-guest-sshkey
%dir %{_datadir}/%{name}/setup
%{_datadir}/%{name}/setup/*.sql
%{_datadir}/%{name}/setup/*.sh

View File

@ -1,6 +1,7 @@
/usr/bin/cloud-setup-databases
/usr/bin/cloud-migrate-databases
/usr/bin/cloud-set-guest-password
/usr/bin/cloud-set-guest-sshkey
/usr/share/cloud/setup/*.sql
/usr/share/cloud/setup/*.sh
/usr/share/cloud/setup/server-setup.xml

View File

@ -0,0 +1,49 @@
#!/bin/bash
#
# Init file for SSH Public Keys Download Client
#
# chkconfig: 345 98 02
# description: SSH Public Keys Download Client
# Modify this line to specify the user (default is root)
user=ubuntu
# Get DomR Ip
DOMR_IP=$(ip route | grep default | cut -d' ' -f3)
if [ ! -n "$DOMR_IP" ]
then
echo "DomR IP address not found. Exiting."
exit 1
fi
# Get ssh public key
homedir=$(grep ^$user /etc/passwd|awk -F ":" '{print $6}')
sshdir=$homedir/.ssh
authorized=$sshdir/authorized_keys
publickey=$(wget -t 3 -T 20 -O - http://$DOMR_IP/latest/public-keys 2>/dev/null)
if [ $? -ne 0 ]
then
echo "Error receiving SSH public key. Exiting."
exit 1
fi
if [ ! -e $sshdir ]
then
mkdir $sshdir
fi
if [ ! -e $authorized ]
then
touch $authorized
fi
cat $authorized|grep -v "$publickey" > $authorized
echo "$publickey" >> $authorized
exit 0