From 4d12c3f2d0536775e0638f3642a0dc176c58cc28 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20A=2E=20Holm?= Date: Tue, 31 Oct 2023 23:10:34 +0100 Subject: [PATCH] logging: Use hostname from `~/.compname` if it exists If it doesn't exist, use the output from the `hostname` command as it has always done. a81e161c-783a-11ee-bac6-45c42403b986 --- logging | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/logging b/logging index 1551fab5..cfbf0e49 100755 --- a/logging +++ b/logging @@ -11,7 +11,7 @@ #======================================================================= progname=logging -VERSION=0.1.0 +VERSION=0.1.1 ARGS="$(getopt -o "\ h\ @@ -67,10 +67,11 @@ END exit 0 fi +host=$1 +test -z "$host" && host=$([ -f ~/.compname ] && cat ~/.compname || hostname) + [ -d $LOGDIR/. ] || mkdir -p $LOGDIR || { echo logging: $LOGDIR: Cannot create log directory >&2; exit 1; } export LDATE=`u` -host=$1 -test -z "$host" && host=$(hostname) uuid=`suuid -t logging -w eo -c "logging $host"` || { echo logging: Error when generating UUID, logging not started >&2; exit 1; } export LNAME="$LOGDIR/$LDATE.$uuid.$host" SESS_UUID="${SESS_UUID}logging/$uuid," script -ft $LNAME.scrlog 2>$LNAME.timing -- 2.11.4.GIT