std.h: Don't use `extern` in function prototypes
[sunny256-utils.git] / mkFiles
blob4772d5a229a006d43f96d92b5b565fa47617dcad
1 #!/usr/bin/env bash
3 #=======================================================================
4 # mkFiles
5 # File ID: 571d0be4-08ef-11de-8399-000475e441b9
6 # Creates Files.json in current directory.
7 #=======================================================================
9 # FIXME: Why doesn’t the ^ (caret) work with "grep -z" ?
11 test -w /tmp/. || { echo mkFiles: /tmp/: Directory not writable or not found >&2; exit 1; };
12 lockname=mkFiles.lock
13 until mkdir $lockname 2>/dev/null; do
14 echo $0: $lockname: Waiting for lock... >&2
15 sleep 5
16 done
18 unset suuid_m
19 if test "$1" = "-m"; then
20 shift
21 suuid_m=" -m"
24 tmpjson=/tmp/.mkFiles.$uuid.tmp
25 find "$@" -type f -print0 | \
26 grep -zv '/\.git/' | \
27 LC_COLLATE=C sort -z | \
28 fldb -z -f - >>$tmpjson
29 mv $tmpjson Files.json
30 fileinfo="$(fldb Files.json | json_reformat -m)"
31 uuid=`suuid$suuid_m -t mkfiles --raw -w eo -c "<c_mkfiles> <host>$(hostname)</host> <directory>$(/bin/pwd)</directory> <fileinfo>$fileinfo</fileinfo> </c_mkfiles>"` || { echo mkFiles: suuid error >&2; rmdir $lockname; exit 1; }
32 echo mkFiles: Done.
34 rmdir $lockname