This function easily lock or unlock a file.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/functions/functions.util | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/src/functions/functions.util b/src/functions/functions.util index 4b6f956..23e5a4b 100644 --- a/src/functions/functions.util +++ b/src/functions/functions.util @@ -738,3 +738,17 @@ hex2dec() { dec2hex() { printf "%02x\n" "${1}" } + +lock_file() { + assert [ $# -eq 1 ] + local file=${1} + + touch "${file}.lock" +} + +unlock_file() { + assert [ $# -eq 1 ] + local file=${1} + + rm -f "${file}.lock" +}