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
|
||||
# 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=$@
|
||||
|
||||
14
localeval.sh
14
localeval.sh
@@ -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)
|
||||
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
|
||||
Reference in New Issue
Block a user