From af4c13ea318458fc62645973f069657e7b5e5e20 Mon Sep 17 00:00:00 2001 From: Stephen Soltesz Date: Wed, 10 Nov 2010 18:09:29 -0500 Subject: [PATCH] This is supported only if there is a receiving server, such as myops, for the uploaded history files. Otherwise, there is no effect. Configure by setting MONITOR_SERVER in bootmanager/configuration --- source/BootManager.py | 10 +++++++++- source/setup_bash_history_scripts.sh | 3 +-- source/steps/ChainBootNode.py | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/source/BootManager.py b/source/BootManager.py index e5a448e..4ea06c8 100755 --- a/source/BootManager.py +++ b/source/BootManager.py @@ -18,6 +18,7 @@ from steps import * from Exceptions import * import notify_messages import BootServerRequest +import utils # all output is written to this file BM_NODE_LOG= "/tmp/bm.log" @@ -112,7 +113,7 @@ class log: self.LogEntry( str, 0, 1 ) # bm log uploading is available back again, as of nodeconfig-5.0-2 - def Upload( self ): + def Upload( self, extra_file=None ): """ upload the contents of the log to the server """ @@ -144,6 +145,10 @@ class log: FormData = [('log',(pycurl.FORM_FILE, self.OutputFilePath)), ("hostname",hostname), ("type","bm.log")]) + if extra_file is not None: + # NOTE: for code-reuse, evoke the bash function 'upload_logs'; + # by adding --login, bash reads .bash_profile before execution. + utils.sysexec( """bash --login -c "upload_logs %s" """ % extra_file, self) ############################## @@ -362,6 +367,9 @@ def main(argv): # the data back to PlanetLab central LOG= log( BM_NODE_LOG ) + # NOTE: assume CWD is BM's source directory, but never fail + utils.sysexec("./setup_bash_history_scripts.sh || /bin/true", LOG) + LOG.LogEntry( "BootManager started at: %s" % \ time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()) ) diff --git a/source/setup_bash_history_scripts.sh b/source/setup_bash_history_scripts.sh index cf697ec..6298d16 100644 --- a/source/setup_bash_history_scripts.sh +++ b/source/setup_bash_history_scripts.sh @@ -90,7 +90,7 @@ for f in bash-prompt-default bash-prompt-xterm ; do done # NOTE: allow command run directly over ssh to be logged also. -echo 'source /etc/profile ; source /root/.bash_profile' > /root/.bashrc +echo "source /etc/profile ; source $BASH_PROFILE" > /root/.bashrc # NOTE 1: crond is not installed on the boot image, so this maintains a # persistent process to upload logs on legacy nodes. @@ -100,7 +100,6 @@ echo 'source /etc/profile ; source /root/.bash_profile' > /root/.bashrc # same time. initial_delay=$(( $RANDOM * 3 )) - cat < $PERIODIC_SCRIPT #!/bin/bash if [ -f $BASH_PROFILE ] ; then diff --git a/source/steps/ChainBootNode.py b/source/steps/ChainBootNode.py index 292a901..8ee2a88 100644 --- a/source/steps/ChainBootNode.py +++ b/source/steps/ChainBootNode.py @@ -169,7 +169,7 @@ def Run( vars, log ): log.write( "Unloading modules and chain booting to new kernel.\n" ) # further use of log after Upload will only output to screen - log.Upload() + log.Upload("/root/.bash_eternal_history") # regardless of whether kexec works or not, we need to stop trying to # run anything -- 2.43.0