From: Jonatan Schlag Date: Wed, 19 Jul 2017 08:09:44 +0000 (+0200) Subject: util: add new function copy X-Git-Tag: 009~165 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a95d16fc92c4b2c94928fcd117c1298f732e57c5;p=network.git util: add new function copy Signed-off-by: Jonatan Schlag Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.util b/src/functions/functions.util index 381208cf..8c8f5691 100644 --- a/src/functions/functions.util +++ b/src/functions/functions.util @@ -752,3 +752,22 @@ hex2dec() { dec2hex() { printf "%02x\n" "${1}" } + +copy() { + # This function just copy config files + assert [ $# -eq 2 ] + + local src=${1} + local dst=${2} + + # Check if ${dst} is a directory + if [ -d ${dst} ]; then + log ERROR "${dst} is a directory." + return ${EXIT_ERROR} + fi + + if ! fread "${src}" > "${dst}"; then + log ERROR "Could not copy data from ${src} to ${dst}" + return ${EXIT_ERROR} + fi +}