Bug 8199: insert generated private key where it is expected

This commit is contained in:
Chiradeep Vittal 2011-01-27 17:25:08 -08:00
parent daa8439c00
commit 8a1ca01f44
3 changed files with 21 additions and 8 deletions

View File

@ -15,7 +15,7 @@ vmops=..,0755,/etc/xapi.d/plugins
vmopsSnapshot=..,0755,/etc/xapi.d/plugins
hostvmstats.py=..,0755,/opt/xensource/sm
systemvm.iso=../../../../../vms,0644,/opt/xensource/packages/iso
id_rsa.cloud=..,0600,/root/.ssh
id_rsa.cloud=../../../systemvm,0600,/root/.ssh
network_info.sh=..,0755,/opt/xensource/bin
setupxenserver.sh=..,0755,/opt/xensource/bin
make_migratable.sh=..,0755,/opt/xensource/bin

View File

@ -17,7 +17,7 @@ ovstunnel=..,0755,/etc/xapi.d/plugins
vmopsSnapshot=..,0755,/etc/xapi.d/plugins
hostvmstats.py=..,0755,/opt/xensource/sm
systemvm.iso=../../../../../vms,0644,/opt/xensource/packages/iso
id_rsa.cloud=..,0600,/root/.ssh
id_rsa.cloud=../../../systemvm,0600,/root/.ssh
network_info.sh=..,0755,/opt/xensource/bin
setupxenserver.sh=..,0755,/opt/xensource/bin
make_migratable.sh=..,0755,/opt/xensource/bin

View File

@ -1,6 +1,7 @@
#!/bin/bash
# $1 = new key
# Copies keys that enable SSH communication with system vms
# $1 = new public key
# $2 = new private key
#set -x
@ -10,7 +11,7 @@ MOUNTPATH=/mnt/cloud/systemvm
TMPDIR=${TMP}/cloud/systemvm
inject() {
inject_into_iso() {
local isofile=${SYSTEMVM_PATCH_DIR}/$1
local newpubkey=$2
local backup=${isofile}.bak
@ -36,16 +37,28 @@ inject() {
rm -rf $TMPDIR
}
copy_priv_key() {
local newprivkey=$1
cp -fb $newprivkey $(dirname $0)/id_rsa.cloud && chmod 0600 $(dirname $0)/id_rsa.cloud
return $?
}
mkdir -p $MOUNTPATH
[ $# -ne 1 ] && echo "Usage: $(basename $0) <new keyfile>" && exit 3
[ $# -ne 2 ] && echo "Usage: $(basename $0) <new public key file> <new private key file>" && exit 3
newpubkey=$1
newprivkey=$2
[ ! -f $newpubkey ] && echo "$(basename $0): Could not open $newpubkey" && exit 3
[ ! -f $newprivkey ] && echo "$(basename $0): Could not open $newprivkey" && exit 3
[ $EUID -ne 0 ] && echo "$(basename $0): You have to be root to run this script" && exit 3
command -v mkisofs > /dev/null || (echo "$(basename $0): mkisofs not found, please install or ensure PATH is accurate" ; exit 4)
inject systemvm.iso $newpubkey
#inject systemvm-premium.iso $newpubkey
inject_into_iso systemvm.iso $newpubkey
#inject_into_iso systemvm-premium.iso $newpubkey
[ $? -ne 0 ] && exit 5
copy_priv_key $newprivkey
exit $?