[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: A "Where am I" routine



On Fri, Jul 06, 2018 at 09:00:11AM -0500, Richard Owlett wrote:
> On 07/06/2018 07:15 AM, Zenaan Harkness wrote:
> > On Fri, Jul 06, 2018 at 06:25:43AM -0500, Richard Owlett wrote:
> > > I multi-boot several configurations &/or releases of Debian.
> > > I will run identical test scripts on each.
> > > I want to store the results in a common logging file.
> > > 
> > > I can set up an appropriate environment with a custom fstab containing:
> > > > 
> > > >   # create a common area
> > > >   LABEL=owlcommon /home/richard/Documents/tst_common vfat user,rw,umask=000 0 0
> > > >   # a dummy mount labeled to show which instance
> > > >   LABEL=dummy /home/richard/Documents/where/sda14 ext4 user,ro 0 0
> > > > 
> > > > 
> > > The first statement gives me a directory usable by all.
> > > The second tells me where I am by using:
> > >     ls /home/richard/Documents/where
> > > in any test script.
> > 
> > OK, a directory existing/ named per your location. Sounds reasonable.
> > My default would normally be to create a config file "per host/ per
> > test env" containing one or more env vars (which specify what I need
> > to know about that host/ test-env, which I would "source" in bash
> > scripts which do things depending on the test environment.
> 
> I think I follow your logic. But I could not implement it. What man pages should I read? What term(s) should I use in
> a WEB search to get an overview?
> 
> As I've only one machine, I'm never conscious of it having a host name.
> When I do a new install the same string is generally used for both the host name and the partition label - generally a
> reminder of current purpose.
> 
> E.G.
> hostname returns "debian-jan13" -- when installed was key information
> Partition label is "new-net-inst" -- I didn't install from DVD.
> The partition is /dev/sda14 .
> Desired information dependent on topic-du-jour.


When you do an install, after the install then create a file like so:

- #~/Documents/where/vars.env

INSTALL_DATE="20180113" # use ISO dates for sorting, filenames etc
LOG_DIR="$HOME/Documents/where/logs/"
INSTALL_INTENTION="Testing Debian sid release"
NOTE1="Learn about openstack devstack."


- So then, in your shiny new sid install, you want to do some
  testing, create a little script, and near the beginning you do
  something like this:

source /etc/os-release
source $HOME/Documents/where/vars.env

and after these two lines you have the respective environment
variables available to play with.


- Now, in a file called something like ~/lib/dtstamp.sh I have the
  following lines:

DTSEP=""
generateYMD      () { date +%Y%m%d; }
generateYMDHM    () { date +%Y%m%d-%H${1:-$DTSEP}%M; }
generateYMDHMS   () { date +%Y%m%d-%H${1:-$DTSEP}%M.%S; }
generateYMDHMSN  () { date +%Y%m%d-%H${1:-$DTSEP}%M.%S.%N; }

which I use to create date/time stamps useful for filenames and log
file entries (i.e. no spaces, ISO format, etc).


- Finally, for example to create a log file name and do some tests,
  try something like this:

source ~/lib/dtstamp.sh
RUN_DTSTAMP=`generateYMDHMSN :`
LOGFILENAME="$LOG_DIR/${INSTALL_DATE}-do_tests-${RUN_DTSTAMP}.log"
cat /etc/os-release > $LOGFILENAME
echo "" >> $LOGFILENAME
do_the_tests.sh >> $LOGFILENAME


- Voi la :)

Good luck,



> > But a shared/ mounted directory sounds fine too - that's also a place
> > where you can store logs etc.
> > 
> > Happy testing,


Reply to: