implemented appendfile
This commit is contained in:
@@ -117,6 +117,40 @@ installfile()
|
||||
export -f installfile
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Add the content of a file at the end of an other
|
||||
appendfile()
|
||||
{
|
||||
local infile=$1
|
||||
if [[ -f $MYPATH/repo/hosts/$HOSTNAME/$infile ]]; then
|
||||
local source="$MYPATH/repo/hosts/$HOSTNAME/$infile"
|
||||
elif [[ -f $MYPATH/repo/common/$infile ]]; then
|
||||
local source="$MYPATH/repo/common/$infile"
|
||||
else
|
||||
# Not found in repository, we expect full name
|
||||
local source="$infile"
|
||||
fi
|
||||
unset infile
|
||||
|
||||
local file=$2
|
||||
if [[ -e $file ]]; then
|
||||
prnt E "appendfile(): Target must be on the root filesystem and full path must be provided."
|
||||
die 13
|
||||
fi
|
||||
if [[ ! $file == /* ]]; then
|
||||
prnt E "appendfile(): Target file must exist."
|
||||
die 13
|
||||
fi
|
||||
|
||||
prnt I "Ajout de contenu au fichier $file..."
|
||||
cat $ource >> $file
|
||||
if [[ $? -ne 0 ]]; then
|
||||
prnt E "appendfile(): Couldn't append a file!"
|
||||
die 12
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# determine if a directory is empty
|
||||
isdirempty()
|
||||
|
||||
Reference in New Issue
Block a user