From 7fffb3f1f470bb42100c7cd72f65f058f0ec11a6 Mon Sep 17 00:00:00 2001 From: Leigh B Stoller Date: Thu, 15 Mar 2012 08:54:20 -0600 Subject: [PATCH] Move the host keys contruction from ssh into this separate script. --- install/phases/boss/hostkeys | 46 ++++++++++++++++++++++++++++++++++++ install/phases/boss/ssh | 22 ----------------- 2 files changed, 46 insertions(+), 22 deletions(-) create mode 100755 install/phases/boss/hostkeys diff --git a/install/phases/boss/hostkeys b/install/phases/boss/hostkeys new file mode 100755 index 000000000..6fe93d99b --- /dev/null +++ b/install/phases/boss/hostkeys @@ -0,0 +1,46 @@ +# +# The template +# +use strict; +use libinstall; +use installvars; + +sub Install($$$) +{ + my ($server, $isupdate, $impotent) = @_; + + # Replace if this script does an update for ip/domain. + return 0 + if ($isupdate); + + # + # Create a set of hostkeys for the images. + # + Phase "imagekeysdir", "Creating $IMAGEKEYS_DIR", sub { + DoneIfExists($IMAGEKEYS_DIR); + mkdir $IMAGEKEYS_DIR,0775 or + PhaseFail("Unable to create $IMAGEKEYS_DIR : $!"); + ExecQuietFatal("$CHGRP tbadmin $IMAGEKEYS_DIR"); + }; + my %keytypes = ( + "rsa1" => "ssh_host_key", + "rsa" => "ssh_host_rsa_key", + "dsa" => "ssh_host_dsa_key"); + + Phase "imagekeys", "Creating host keys for images", sub { + foreach my $type (keys(%keytypes)) { + my $name = $keytypes{$type}; + + Phase $type, "Creating $type host key", sub { + DoneIfExists("$IMAGEKEYS_DIR/$name"); + ExecQuietFatal("$SSH_KEYGEN -t $type -N '' ". + " -f $IMAGEKEYS_DIR/$name"); + }; + } + }; + return 0; +} + +# Local Variables: +# mode:perl +# End: diff --git a/install/phases/boss/ssh b/install/phases/boss/ssh index d743391bf..8335367bc 100755 --- a/install/phases/boss/ssh +++ b/install/phases/boss/ssh @@ -19,28 +19,6 @@ sub Install($$$) ExecQuietFatal("$SSH_KEYGEN -t rsa -P '' -f $ROOT_PRIVKEY"); }; # - # Create a set of hostkeys for the images. - # - Phase "imagekeysdir", "Creating $IMAGEKEYS_DIR", sub { - DoneIfExists($IMAGEKEYS_DIR); - mkdir $IMAGEKEYS_DIR,0775 or - PhaseFail("Unable to create $IMAGEKEYS_DIR : $!"); - ExecQuietFatal("$CHGRP tbadmin $IMAGEKEYS_DIR"); - }; - my %keytypes = ( - "rsa1" => "ssh_host_key", - "rsa" => "ssh_host_rsa_key", - "dsa" => "ssh_host_dsa_key"); - - Phase "imagekeys", "Creating host keys for images", sub { - foreach my $type (keys(%keytypes)) { - my $name = $keytypes{$type}; - - ExecQuietFatal("$SSH_KEYGEN -t $type -N '' ". - " -f $IMAGEKEYS_DIR/$name"); - } - }; - # # Stick it into the DB. # WARNING: This sitevar (node/ssh_pubkey) is referenced in tmcd.c # -- GitLab