-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.sh
More file actions
35 lines (27 loc) · 783 Bytes
/
script.sh
File metadata and controls
35 lines (27 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
MONITOR_USB="/media/joaquin/usb"
MONITOR_DESKTOP="/home/joaquin/Desktop"
ENCRYPT="/home/joaquin/Documents/Project/encrypt"
DECRYPT="/home/joaquin/Documents/Project/decrypt"
INOTIFYWAIT="/usr/bin/inotifywait"
usb_monitoring(){
$INOTIFYWAIT -m "$MONITOR_USB" -e create|
while read -r directory event filename; do
full_file_path="$directory$filename"
if [[ $event == "CREATE" ]]; then
bash -c "$ENCRYPT $full_file_path; exec bash"
fi
done
}
desktop_monitoring(){
$INOTIFYWAIT -m "$MONITOR_DESKTOP" -e create|
while read -r directory event filename; do
full_file_path="$directory$filename"
if [[ $event == "CREATE" ]]; then
bash -c "$DECRYPT $full_file_path; exec bash"
fi
done
}
usb_monitoring &
desktop_monitoring &
wait