From 15d551d5e173d4da4b63cc89aa16462b665d001b Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Wed, 9 May 2012 22:21:22 +0200 Subject: [PATCH] Added shell logger --- logshell/cvmshell | 2 ++ logshell/logshell | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 logshell/cvmshell create mode 100644 logshell/logshell diff --git a/logshell/cvmshell b/logshell/cvmshell new file mode 100644 index 0000000..f37a82d --- /dev/null +++ b/logshell/cvmshell @@ -0,0 +1,2 @@ +#!/bin/sh +sudo /etc/cvm/logshell diff --git a/logshell/logshell b/logshell/logshell new file mode 100644 index 0000000..39a4b8c --- /dev/null +++ b/logshell/logshell @@ -0,0 +1,22 @@ +#!/usr/bin/python +import random, string, subprocess, os +from datetime import time, date, datetime +from time import strftime + +rand = ''.join(random.choice(string.letters + string.digits) for i in xrange(8)) + +today = datetime.today() +day = today.day +month = today.month +year = today.year +hour = today.hour +minute = today.minute +second = today.second + +rand = "%s_%s" % (strftime("%Y%m%d_%H%M%S"), rand) + +subprocess.call("script -qt 2>/etc/cvm/log/log.%s.time -c 'su -s \"/bin/bash\" cvm' -a /etc/cvm/log/log.%s" % (rand, rand), shell=True) + +if os.environ['SHELL'] != "/bin/bash": + os.remove("/etc/cvm/log/log.%s.time" % rand) + os.remove("/etc/cvm/log/log.%s" % rand)