]> arthur.barton.de Git - netatalk.git/blobdiff - contrib/shell_utils/fce_ev_script.sh
Merge remote-tracking branch 'origin/branch-netatalk-3-1'
[netatalk.git] / contrib / shell_utils / fce_ev_script.sh
diff --git a/contrib/shell_utils/fce_ev_script.sh b/contrib/shell_utils/fce_ev_script.sh
new file mode 100644 (file)
index 0000000..8e3410c
--- /dev/null
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+usage="$(basename $0) [-h] [-v version] [-e event] [-P path] [-S source path] -- FCE sample script
+
+where:
+    -h  show this help text
+    -v  version
+    -e  event
+    -P  path
+    -S  source path for events like rename/move
+    -u  username
+    -p  pid
+    -i  event ID
+"
+
+while getopts ':hs:v:e:P:S:u:p:i:' option; do
+  case "$option" in
+    h) echo "$usage"
+       exit
+       ;;
+    v) version=$OPTARG
+       ;;
+    e) event=$OPTARG
+       ;;
+    P) path=$OPTARG
+       ;;
+    S) srcpath=$OPTARG
+       ;;
+    u) user=$OPTARG
+       ;;
+    p) pid=$OPTARG
+       ;;
+    i) evid=$OPTARG
+       ;;
+    ?) printf "illegal option: '%s'\n" "$OPTARG" >&2
+       echo "$usage" >&2
+       exit 1
+       ;;
+  esac
+done
+shift $((OPTIND - 1))
+
+printf "FCE Event: $event" >> /tmp/fce.log 
+if [ -n "$version" ] ; then
+    printf ", protocol: $version" >> /tmp/fce.log
+fi
+if [ -n "$evid" ] ; then
+    printf ", ID: $evid" >> /tmp/fce.log
+fi
+if [ -n "$pid" ] ; then
+    printf ", pid: $pid" >> /tmp/fce.log
+fi
+if [ -n "$user" ] ; then
+    echo -n ", user: $user" >> /tmp/fce.log
+fi
+if [ -n "$srcpath" ] ; then
+    echo -n ", source: $srcpath" >> /tmp/fce.log
+fi
+if [ -n "$path" ] ; then
+    echo -n ", path: $path" >> /tmp/fce.log
+fi
+printf "\n" >> /tmp/fce.log