runif for lockutil
This commit is contained in:
@@ -1,12 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
VERSION=230908.0
|
||||||
|
|
||||||
_help() {
|
_help() {
|
||||||
echo '
|
echo '
|
||||||
Usage: lock-util {lock-file} [-v] [command] [args]
|
Usage: lock-util {lock-file} [-v] [command] [args]
|
||||||
Commands:
|
Commands:
|
||||||
create
|
create
|
||||||
exist ( return 0 if lock exists )
|
exist ( return 0 if lock exists )
|
||||||
old [age in seconds] ( return 0 if file younger than [args] seconds or file not present )
|
old [age in seconds] ( return 0 if file older than [args] seconds or file not present )
|
||||||
|
runif [age in seconds] ( old + create, if file not exist, or older than [arg], then touch file and return 0, else 1 )
|
||||||
remove
|
remove
|
||||||
-v as first argument sets very verbose mode
|
-v as first argument sets very verbose mode
|
||||||
|
|
||||||
@@ -80,5 +83,17 @@ _remove() {
|
|||||||
exit $ec
|
exit $ec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[ $COMMAND = "runif" ]] && {
|
||||||
|
[[ -z "$ARG" ]] && _help && echo "MISSING ARGUMENT" | $BOXES && exit 1
|
||||||
|
VERBOSE=$VERBOSE "$0" "$LOCKFILE" old "$ARG"
|
||||||
|
ec=$?
|
||||||
|
[[ $ec -eq 0 ]] && {
|
||||||
|
_exist && _remove
|
||||||
|
VERBOSE=$VERBOSE "$0" "$LOCKFILE" create
|
||||||
|
ec=$?
|
||||||
|
}
|
||||||
|
exit $ec
|
||||||
|
}
|
||||||
|
|
||||||
echo Command not recognized
|
echo Command not recognized
|
||||||
_help
|
_help
|
||||||
|
|||||||
Reference in New Issue
Block a user