init
This commit is contained in:
commit
698993349c
26 changed files with 430 additions and 0 deletions
0
s6-rc-inotify/dependencies.d/init-services
Normal file
0
s6-rc-inotify/dependencies.d/init-services
Normal file
46
s6-rc-inotify/run
Normal file
46
s6-rc-inotify/run
Normal file
|
@ -0,0 +1,46 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
if ! command -v inotifywait 2>&1 >/dev/null; then
|
||||
echo "No inotifywait found. install inotify tools"
|
||||
apk add inotify-tools
|
||||
fi
|
||||
|
||||
echo "running inotify"
|
||||
|
||||
BASEEXCLUDE='.*\.swp|.*\.swx'
|
||||
|
||||
detect(){
|
||||
WATCH=$1
|
||||
EXCLUDE=$2
|
||||
REPLACEIN=$3
|
||||
REPLACEWITH=$4
|
||||
|
||||
echo "watching $WATCH and excluding $EXCLUDE"
|
||||
|
||||
inotifywait -mre close_write,delete --format '%e|%w|%f' --exclude "$EXCLUDE" "$WATCH" | while read RAWEVENT
|
||||
do
|
||||
|
||||
echo $RAWEVENT
|
||||
IFS='|'
|
||||
read -a SPLITEVENT <<< "$RAWEVENT"
|
||||
|
||||
EVENT=${SPLITEVENT[0]}
|
||||
DIR=${SPLITEVENT[1]}
|
||||
FILE=${SPLITEVENT[2]}
|
||||
|
||||
REPLACEDFILE=$DIR
|
||||
|
||||
if [[ $EVENT != 'DELETE' ]]; then
|
||||
REPLACEDFILE+=$FILE
|
||||
fi
|
||||
|
||||
if [ -n "$REPLACEIN" ] && [ -n "$REPLACEWITH" ]; then
|
||||
REPLACEDFILE=${REPLACEDFILE/$REPLACEIN/$REPLACEWITH}
|
||||
fi
|
||||
|
||||
occ files:scan --path=\"$REPLACEDFILE\" --shallow
|
||||
done
|
||||
}
|
||||
|
||||
detect /data/riksolo/files $BASEEXCLUDE /data/riksolo /riksolo
|
1
s6-rc-inotify/type
Normal file
1
s6-rc-inotify/type
Normal file
|
@ -0,0 +1 @@
|
|||
longrun
|
Loading…
Add table
Add a link
Reference in a new issue