functions: renommage fonction

localeval: more robust hostname handling
This commit is contained in:
2021-02-22 11:02:14 +01:00
parent bb26868607
commit 9921222131
2 changed files with 22 additions and 20 deletions

View File

@@ -33,7 +33,7 @@ function fileBiggerThan {
#Ok if file exists
# arg1: file to check
function fileMustExist {
function fileMustExists {
if [ -f ${1} ] ; then echo -ne "1;"
else echo -ne "0;"
fi
@@ -41,7 +41,7 @@ fi
#Ok if file DOESNOT exists
# arg1: file to check
function fileMustNOTExist {
function fileMustNOTExists {
if [ -f ${1} ] ; then echo -ne "0;"
else echo -ne "1;"
fi
@@ -49,14 +49,14 @@ fi
#Ok if dir exists
# arg1: dir to check
function dirMustExist {
function dirMustExists {
if [ -d ${1} ] ; then echo -ne "1;"
else echo -ne "0;"
fi
}
# Ok if given dir DOESNOT exists
# arg1: dir
function dirMustNOTExist {
function dirMustNOTExists {
if [ -d ${1} ] ; then echo -ne "0;"
else echo -ne "1;"
fi
@@ -65,7 +65,7 @@ fi
# Ok if file contains at least one occurence of pattern
# arg1: file
# arg2: pattern
function fileMustContain {
function fileMustContains {
file=$1
shift
string=$@
@@ -93,7 +93,7 @@ function fileCountPattern {
# arg1: file
# arg2: num of expected item
# arg3: pattern
function fileMustContainNItem {
function fileMustContainsNItem {
file=$1
n=$2
shift
@@ -110,7 +110,7 @@ function fileMustContainNItem {
# Ok if file DOESNOT contain pattern
# Arg1: file
# ArgN: pattern
function fileMustNOTContain {
function fileMustNOTContains {
file=$1
shift
string=$@

View File

@@ -1,16 +1,18 @@
#! /bin/bash
set -euo pipefail
IFS=$'\n\t'
source functions.sh
# check that alias has been tried
echo -ne "host\tname\troot history\tbash history\t<+CHANGEME+>\n"
for host in /srv/lxc/epsi/<+CHANGEME+>/* ; do
root=${host}/rootfs
host=$(basename $host)
echo -ne "host\tname\troot history\tbash history\t<+CHANGEME+>\n"
for host in /srv/lxc/ipi/ipi_g1*/rootfs ; do
root=${host}
#host=$(basename $host)
hostname=$(grep HOSTNAME ${root}/etc/sysconfig/network | cut -f2 -d=)
test -z "${hostname}" && hostname=$(cat ${root}/etc/hostname)
test -f ${root}/etc/motd && user="$(cat ${root}/etc/motd | sed 's/\n//')\t"
echo -ne "${hostname}\t${user}"
fileMTime ${root}/root/.bash_history
fileMTime ${root}/home/formation/.bash_history
<+CHANGEME+>
echo
done