1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
# Configuration space
. /etc/fai/nfsroot.conf
N=$NFSROOT
CS=$FAI_CONFIGDIR
TFTP=$TFTPROOT
# - - - - - - - - - - - - - - - - -
error() {
echo "ERROR: $*" >/dev/stderr
}
# - - - - - - - - - - - - - - - - -
chk-file() {
local file=$1
if [ ! -f $file ]; then
error "$file is missing"
fi
}
# - - - - - - - - - - - - - - - - -
chk-no-file() {
# check that files does not exist
local file=$1
if [ -f $file ]; then
error "$file exists, but it should not."
fi
}
# - - - - - - - - - - - - - - - - -
chk-size() {
# check if the disk space of a path is greater than minsize
# path can be a directory or a file
local path=$1
local minsize=$2
local size
if [ ! -e $path ]; then
error "$path does not exist."
return
fi
size=$(du -Dsm $path | awk '{print $1}')
if [ $size -lt $minsize ]; then
error "$path is too small: $size MB. Should be greater $minsize MB"
else
echo "OK: $path size is $size MB"
fi
}
# - - - - - - - - - - - - - - - - -
chk-loop-device() {
# check if we can use loop devices
trap 'exit 77' ERR ABRT EXIT QUIT
qemu-img create test.raw 10M
loop=$(losetup -P -f --show test.raw)
echo "LOOP: $loop"
losetup -d $loop
rm test.raw
trap - ERR ABRT EXIT QUIT
}
|