From b860ceaf58a2726cc9d27d0da8ddc01e65e3b860 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Thu, 26 Feb 2009 17:25:53 +0000 Subject: [PATCH] undo this one for building rc26 --- source/steps/InitializeBootManager.py | 7 +- source/steps/StartDebug.py | 103 +++++++++++++------------- 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/source/steps/InitializeBootManager.py b/source/steps/InitializeBootManager.py index 2f976da..d1fda39 100644 --- a/source/steps/InitializeBootManager.py +++ b/source/steps/InitializeBootManager.py @@ -1,5 +1,7 @@ #!/usr/bin/python2 +# $Id$ + # Copyright (c) 2003 Intel Corporation # All rights reserved. # @@ -86,8 +88,9 @@ def Run( vars, log ): log.write( "Loading support for Fusion MPT SCSI controllers\n" ) utils.sysexec_noerr( "modprobe mptscsih", log ) - log.write( "Loading support for LVM\n" ) - utils.sysexec_noerr( "modprobe dm_mod", log ) +# out of the way for rc26 +# log.write( "Loading support for LVM\n" ) +# utils.sysexec_noerr( "modprobe dm_mod", log ) # for anything that needs to know we are running under the boot cd and # not the runtime os os.environ['PL_BOOTCD']= "1" diff --git a/source/steps/StartDebug.py b/source/steps/StartDebug.py index 1bc6d23..c441d03 100644 --- a/source/steps/StartDebug.py +++ b/source/steps/StartDebug.py @@ -13,7 +13,7 @@ import utils import compatibility -message= \ +warning_message= \ """ --------------------------------------------------------- This machine has entered a temporary debug state, so @@ -27,8 +27,13 @@ Thank you. --------------------------------------------------------- """ +# this can be invoked +# either at the end of the bm logic, because something failed (last_resort = True) +# and/or it can be invoked as a fallback very early in the bootmanager logic, +# so we can reach the node regardless of what happens (e.g. bm sometimes hangs) + +def Run( vars, log, last_resort = True): -def Run( vars, log ): """ Bring up sshd inside the boot cd environment for debug purposes. @@ -41,7 +46,13 @@ def Run( vars, log ): BOOT_CD_VERSION A tuple of the current bootcd version """ - log.write( "\n\nStep: Starting debug mode.\n" ) + if last_resort: + message="Starting debug mode" + else: + message="Starting fallback sshd" + + + log.write( "\n\nStep: %s.\n"%message ) # make sure we have the variables we need try: @@ -58,77 +69,63 @@ def Run( vars, log ): except ValueError, var: raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var - - log.write( "Starting debug environment\n" ) - + # constants ssh_source_files= "%s/debug_files/" % BM_SOURCE_DIR ssh_dir= "/etc/ssh/" ssh_home= "/root/.ssh" cancel_boot_flag= "/tmp/CANCEL_BOOT" sshd_started_flag= "/tmp/SSHD_RUNNING" - sshd_started= 0 - try: - os.stat(sshd_started_flag) - sshd_started= 1 - except OSError, e: - pass - - if not sshd_started: - # NOTE: these commands hang if ssh_host_*_key files exist, b/c - # ssh-keygen asks for user input to confirm the overwrite. - # could fix this with "echo 'y' | " - log.write( "Creating ssh host keys\n" ) - - utils.makedirs( ssh_dir ) - utils.sysexec( "ssh-keygen -t rsa1 -b 1024 -f %s/ssh_host_key -N ''" % - ssh_dir, log ) - utils.sysexec( "ssh-keygen -t rsa -f %s/ssh_host_rsa_key -N ''" % - ssh_dir, log ) - utils.sysexec( "ssh-keygen -d -f %s/ssh_host_dsa_key -N ''" % - ssh_dir, log ) - - if BOOT_CD_VERSION[0] >= 3: - utils.sysexec( "cp -f %s/sshd_config_v3 %s/sshd_config" % - (ssh_source_files,ssh_dir), log ) - else: - utils.sysexec( "cp -f %s/sshd_config_v2 %s/sshd_config" % - (ssh_source_files,ssh_dir), log ) + # create host keys if needed + if not os.path.isdir (ssh_dir): + utils.makedirs (ssh_dir) + key=ssh_dir+"/ssh_host_key" + if not os.path.isfile (key): + log.write("Creating host rsa1 key %s\n"%key) + utils.sysexec( "ssh-keygen -t rsa1 -b 1024 -f %s -N ''" % key, log ) + key=ssh_dir+"/ssh_host_rsa_key" + if not os.path.isfile (key): + log.write("Creating host rsa key %s\n"%key) + utils.sysexec( "ssh-keygen -t rsa -f %s -N ''" % key, log ) + key=ssh_dir+"/ssh_host_dsa_key" + if not os.path.isfile (key): + log.write("Creating host dsa key %s\n"%key) + utils.sysexec( "ssh-keygen -d -f %s -N ''" % key, log ) + + if BOOT_CD_VERSION[0] >= 3: + utils.sysexec( "cp -f %s/sshd_config_v3 %s/sshd_config" % (ssh_source_files,ssh_dir), log ) else: - log.write( "ssh host keys already created\n" ) - + utils.sysexec( "cp -f %s/sshd_config_v2 %s/sshd_config" % (ssh_source_files,ssh_dir), log ) - # always update the key, may have change in this instance of the bootmanager + # always update the key, may have changed in this instance of the bootmanager log.write( "Installing debug ssh key for root user\n" ) - - utils.makedirs( ssh_home ) - utils.sysexec( "cp -f %s/debug_root_ssh_key %s/authorized_keys" % - (ssh_source_files,ssh_home), log ) + if not os.path.isdir ( ssh_home): + utils.makedirs( ssh_home ) + utils.sysexec( "cp -f %s/debug_root_ssh_key %s/authorized_keys" % (ssh_source_files,ssh_home), log ) utils.sysexec( "chmod 700 %s" % ssh_home, log ) utils.sysexec( "chmod 600 %s/authorized_keys" % ssh_home, log ) - if not sshd_started: + # start sshd + if not os.path.isfile(sshd_started_flag): log.write( "Starting sshd\n" ) - - if BOOT_CD_VERSION[0] == 2: - utils.sysexec( "/usr/sbin/sshd", log ) - else: - utils.sysexec( "service sshd start", log ) - + if BOOT_CD_VERSION[0] == 2: utils.sysexec( "/usr/sbin/sshd", log ) + else: utils.sysexec( "service sshd start", log ) # flag that ssh is running utils.sysexec( "touch %s" % sshd_started_flag, log ) else: - log.write( "sshd already running\n" ) + # it is expected that sshd is already running when last_resort==True + if not last_resort: + log.write( "sshd is already running\n" ) - - # this will make the initial script stop requesting scripts from PLC - utils.sysexec( "touch %s" % cancel_boot_flag, log ) + if last_resort: + # this will make the initial script stop requesting scripts from PLC + utils.sysexec( "touch %s" % cancel_boot_flag, log ) # for ease of use, setup lvm on 2.x cds if BOOT_CD_VERSION[0] == 2: compatibility.setup_lvm_2x_cd(vars,log) - print message + if last_resort: + print warning_message return - -- 2.47.0