functions: renommage fonction
localeval: more robust hostname handling
This commit is contained in:
14
functions.sh
14
functions.sh
@@ -33,7 +33,7 @@ function fileBiggerThan {
|
|||||||
|
|
||||||
#Ok if file exists
|
#Ok if file exists
|
||||||
# arg1: file to check
|
# arg1: file to check
|
||||||
function fileMustExist {
|
function fileMustExists {
|
||||||
if [ -f ${1} ] ; then echo -ne "1;"
|
if [ -f ${1} ] ; then echo -ne "1;"
|
||||||
else echo -ne "0;"
|
else echo -ne "0;"
|
||||||
fi
|
fi
|
||||||
@@ -41,7 +41,7 @@ fi
|
|||||||
|
|
||||||
#Ok if file DOESNOT exists
|
#Ok if file DOESNOT exists
|
||||||
# arg1: file to check
|
# arg1: file to check
|
||||||
function fileMustNOTExist {
|
function fileMustNOTExists {
|
||||||
if [ -f ${1} ] ; then echo -ne "0;"
|
if [ -f ${1} ] ; then echo -ne "0;"
|
||||||
else echo -ne "1;"
|
else echo -ne "1;"
|
||||||
fi
|
fi
|
||||||
@@ -49,14 +49,14 @@ fi
|
|||||||
|
|
||||||
#Ok if dir exists
|
#Ok if dir exists
|
||||||
# arg1: dir to check
|
# arg1: dir to check
|
||||||
function dirMustExist {
|
function dirMustExists {
|
||||||
if [ -d ${1} ] ; then echo -ne "1;"
|
if [ -d ${1} ] ; then echo -ne "1;"
|
||||||
else echo -ne "0;"
|
else echo -ne "0;"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
# Ok if given dir DOESNOT exists
|
# Ok if given dir DOESNOT exists
|
||||||
# arg1: dir
|
# arg1: dir
|
||||||
function dirMustNOTExist {
|
function dirMustNOTExists {
|
||||||
if [ -d ${1} ] ; then echo -ne "0;"
|
if [ -d ${1} ] ; then echo -ne "0;"
|
||||||
else echo -ne "1;"
|
else echo -ne "1;"
|
||||||
fi
|
fi
|
||||||
@@ -65,7 +65,7 @@ fi
|
|||||||
# Ok if file contains at least one occurence of pattern
|
# Ok if file contains at least one occurence of pattern
|
||||||
# arg1: file
|
# arg1: file
|
||||||
# arg2: pattern
|
# arg2: pattern
|
||||||
function fileMustContain {
|
function fileMustContains {
|
||||||
file=$1
|
file=$1
|
||||||
shift
|
shift
|
||||||
string=$@
|
string=$@
|
||||||
@@ -93,7 +93,7 @@ function fileCountPattern {
|
|||||||
# arg1: file
|
# arg1: file
|
||||||
# arg2: num of expected item
|
# arg2: num of expected item
|
||||||
# arg3: pattern
|
# arg3: pattern
|
||||||
function fileMustContainNItem {
|
function fileMustContainsNItem {
|
||||||
file=$1
|
file=$1
|
||||||
n=$2
|
n=$2
|
||||||
shift
|
shift
|
||||||
@@ -110,7 +110,7 @@ function fileMustContainNItem {
|
|||||||
# Ok if file DOESNOT contain pattern
|
# Ok if file DOESNOT contain pattern
|
||||||
# Arg1: file
|
# Arg1: file
|
||||||
# ArgN: pattern
|
# ArgN: pattern
|
||||||
function fileMustNOTContain {
|
function fileMustNOTContains {
|
||||||
file=$1
|
file=$1
|
||||||
shift
|
shift
|
||||||
string=$@
|
string=$@
|
||||||
|
|||||||
28
localeval.sh
28
localeval.sh
@@ -1,16 +1,18 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
source functions.sh
|
source functions.sh
|
||||||
# check that alias has been tried
|
echo -ne "host\tname\troot history\tbash history\t<+CHANGEME+>\n"
|
||||||
echo -ne "host\tname\troot history\tbash history\t<+CHANGEME+>\n"
|
for host in /srv/lxc/ipi/ipi_g1*/rootfs ; do
|
||||||
for host in /srv/lxc/epsi/<+CHANGEME+>/* ; do
|
root=${host}
|
||||||
root=${host}/rootfs
|
#host=$(basename $host)
|
||||||
host=$(basename $host)
|
hostname=$(grep HOSTNAME ${root}/etc/sysconfig/network | cut -f2 -d=)
|
||||||
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"
|
test -f ${root}/etc/motd && user="$(cat ${root}/etc/motd | sed 's/\n//')\t"
|
||||||
echo -ne "${hostname}\t${user}"
|
echo -ne "${hostname}\t${user}"
|
||||||
fileMTime ${root}/root/.bash_history
|
fileMTime ${root}/root/.bash_history
|
||||||
fileMTime ${root}/home/formation/.bash_history
|
fileMTime ${root}/home/formation/.bash_history
|
||||||
<+CHANGEME+>
|
|
||||||
echo
|
echo
|
||||||
|
|
||||||
done
|
done
|
||||||
Reference in New Issue
Block a user