Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #197271 > unrolled thread

A "Where am I" routine

Started byRichard Owlett <rowlett@cloud85.net>
First post2018-07-06 13:30 +0200
Last post2018-07-10 22:30 +0200
Articles 9 — 6 participants

Back to article view | Back to linux.debian.user


Contents

  A "Where am I" routine Richard Owlett <rowlett@cloud85.net> - 2018-07-06 13:30 +0200
    Re: A "Where am I" routine Zenaan Harkness <zenaan@freedbms.net> - 2018-07-06 14:20 +0200
      Re: A "Where am I" routine Richard Owlett <rowlett@cloud85.net> - 2018-07-06 16:10 +0200
        Re: A "Where am I" routine David Christensen <dpchrist@holgerdanske.com> - 2018-07-07 04:40 +0200
        Re: A "Where am I" routine Zenaan Harkness <zenaan@freedbms.net> - 2018-07-07 05:40 +0200
    Re: A "Where am I" routine Mike McClain <mike.junk.46@att.net> - 2018-07-07 04:40 +0200
    Re: A "Where am I" routine David Wright <deblis@lionunicorn.co.uk> - 2018-07-10 20:50 +0200
      Re: A "Where am I" routine john doe <johndoe65534@mail.com> - 2018-07-10 21:10 +0200
      Re: A "Where am I" routine Richard Owlett <rowlett@cloud85.net> - 2018-07-10 22:30 +0200

#197271 — A "Where am I" routine

FromRichard Owlett <rowlett@cloud85.net>
Date2018-07-06 13:30 +0200
SubjectA "Where am I" routine
Message-ID<w8x61-2M5-5@gated-at.bofh.it>
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.

[toc] | [next] | [standalone]


#197274

FromZenaan Harkness <zenaan@freedbms.net>
Date2018-07-06 14:20 +0200
Message-ID<w8xSp-3h1-3@gated-at.bofh.it>
In reply to#197271
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.

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

Happy testing,

[toc] | [prev] | [next] | [standalone]


#197277

FromRichard Owlett <rowlett@cloud85.net>
Date2018-07-06 16:10 +0200
Message-ID<w8zAR-4jF-9@gated-at.bofh.it>
In reply to#197274
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.


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

[toc] | [prev] | [next] | [standalone]


#197302

FromDavid Christensen <dpchrist@holgerdanske.com>
Date2018-07-07 04:40 +0200
Message-ID<w8LiG-2SL-5@gated-at.bofh.it>
In reply to#197277
On 07/06/18 07:00, 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.

> 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.

One file and two commands come to mind:

2018-07-06 18:55:59 dpchrist@po ~
$ cat /etc/debian_version
9.4

2018-07-06 19:07:38 dpchrist@po ~
$ uname -a
Linux po 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64 
GNU/Linux

2018-07-06 19:25:55 dpchrist@po ~/sandbox/debian
$ mount -l | grep 'on / '
/dev/mapper/sda3_crypt on / type btrfs 
(rw,relatime,ssd,space_cache,subvolid=5,subvol=/) [po_root]


In a shell script, you can assign these values into variables:

2018-07-06 19:29:15 dpchrist@po ~/sandbox/debian
$ cat id_debian
#!/bin/sh
# $Id: id_debian,v 1.3 2018/07/07 02:30:11 dpchrist Exp $
# Simple-minded script for identifying Debian hosts
# Copyright 2018 by David Paul Christensen dpchrist@holgerdanske.com
# Public domain

DEBIAN_VERSION=`/bin/cat /etc/debian_version`
UNAME_A=`/bin/uname -a`
MOUNT_L_ROOT=`/bin/mount -l | /bin/grep 'on / '`

2018-07-06 19:30:16 dpchrist@po ~/sandbox/debian
$ /bin/sh id_debian


You can source the above script from another script to obtain the 
variable values:

2018-07-06 19:32:08 dpchrist@po ~/sandbox/debian
$ cat source_id_debian
#!/bin/sh
# $Id: source_id_debian,v 1.2 2018/07/07 02:32:07 dpchrist Exp $
# Sources 'id_debian' to obtain identification variables
# Copyright 2018 by David Paul Christensen dpchrist@holgerdanske.com
# Public domain

. ./id_debian

echo $DEBIAN_VERSION
echo $UNAME_A
echo $MOUNT_L_ROOT

2018-07-06 19:32:10 dpchrist@po ~/sandbox/debian
$ /bin/sh source_id_debian
9.4
Linux po 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64 
GNU/Linux
/dev/mapper/sda3_crypt on / type btrfs 
(rw,relatime,ssd,space_cache,subvolid=5,subvol=/) [po_root]


David

[toc] | [prev] | [next] | [standalone]


#197306

FromZenaan Harkness <zenaan@freedbms.net>
Date2018-07-07 05:40 +0200
Message-ID<w8MeK-3qq-3@gated-at.bofh.it>
In reply to#197277
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,

[toc] | [prev] | [next] | [standalone]


#197303

FromMike McClain <mike.junk.46@att.net>
Date2018-07-07 04:40 +0200
Message-ID<w8LiG-2SL-7@gated-at.bofh.it>
In reply to#197271
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.

Facing a similar problem of several distributions on one machine I
took a different approach.
I use a separate partition for data '/mc' accessable from all
distributions.
This little script tells me where I'm running from:

#!/bin/bash
#   /mc/bin/set_dist    set the variable DIST   071512  Mc
#   source this file and DIST will transfer to the calling file

#   which distribution (based on partition label)
if [ $(grep -c UUID /proc/cmdline) -gt 0 ]; then
    bid=$(cut -d'=' -f4 /proc/cmdline | cut -d' ' -f1);
    rline=$(blkid | grep $bid) ;
    rstr=${rline#*\"};
    DIST=${rstr%%\"*};
    unset bid rline rstr;
else
    DIST=$( e2label $(mount | grep " / " | cut -d" " -f1 ) );
fi

The various partitions are labeled for the Debian version.

This may or may not help you but works for me.

Have fun,
Mike
--
"Beauty without grace is a hook without a bait."
    - Ninon de Lenclos

[toc] | [prev] | [next] | [standalone]


#197456

FromDavid Wright <deblis@lionunicorn.co.uk>
Date2018-07-10 20:50 +0200
Message-ID<wa5S1-1TG-1@gated-at.bofh.it>
In reply to#197271
On Fri 06 Jul 2018 at 06:25:43 (-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.

If you're going to compare your test runs, you might be better off
storing the results in separate files, either named for the
configuration, or in directories named that way. It's a lot easier to

diff -u configuration-A/test-2.log configuration-B/test-2.log | less

than to compare the corresponding lines from different sections of the
same, common logging file (involving a lot of plumbing).

Cheers,
David.

[toc] | [prev] | [next] | [standalone]


#197459

Fromjohn doe <johndoe65534@mail.com>
Date2018-07-10 21:10 +0200
Message-ID<wa6bo-2gx-5@gated-at.bofh.it>
In reply to#197456
On 7/10/2018 8:40 PM, David Wright wrote:
> On Fri 06 Jul 2018 at 06:25:43 (-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.
> 
> If you're going to compare your test runs, you might be better off
> storing the results in separate files, either named for the
> configuration, or in directories named that way. It's a lot easier to
> 
> diff -u configuration-A/test-2.log configuration-B/test-2.log | less
> 

The option '-s' is also useful to know if the files are identical.

-- 
John Doe

[toc] | [prev] | [next] | [standalone]


#197463

FromRichard Owlett <rowlett@cloud85.net>
Date2018-07-10 22:30 +0200
Message-ID<wa7qN-2YE-15@gated-at.bofh.it>
In reply to#197456
On 07/10/2018 01:40 PM, David Wright wrote:
> On Fri 06 Jul 2018 at 06:25:43 (-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.
> 
> If you're going to compare your test runs, you might be better off
> storing the results in separate files,

I wish a common log file.
I was envisioning a "function" {wrong word?}, which would return "Where 
you came from" as an introductory header.
A better response later, I've just been given a hint to solving 2 
(apparently unrelated) problems of higher priority.

P.S. You supplied the hint ;}

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web