SHOW:
|
|
- or go back to the newest paste.
1 | cat <<EOF1 > /etc/init.d/SharedFolderUpdate.sh | |
2 | ### BEGIN INIT INFO | |
3 | # Provides: Shared folder watcher. | |
4 | # Required-Start: $remote_fs $syslog | |
5 | # Required-Stop: $remote_fs $syslog | |
6 | # Default-Start: 2 3 4 5 | |
7 | # Default-Stop: 0 1 6 | |
8 | # Short-Description: Shared folder watcher | |
9 | # Description: Watches shared folders updating permissions | |
10 | ### END INIT INFO | |
11 | ||
12 | ||
13 | - | #!/bin/bash |
13 | + | #!/usr/bin/env bash |
14 | # /etc/init.d/SharedFolderUpdate.sh | |
15 | directory=`inotifywait -q -r --format %w -e create /home/shared/`; | |
16 | case "$1" in | |
17 | start) | |
18 | $FILES=/home/shared/ | |
19 | for f in $FILES | |
20 | do | |
21 | local FolderName=$(basename "$f") | |
22 | chown --recursive --reference=$FolderName $FolderName && chmod --recursive --reference=$FolderName $FolderName | |
23 | done | |
24 | ||
25 | while true; do | |
26 | - | directory=$(inotifywait -q -r --format %w -e create /home/shared/) #It gets stuck on this line!! |
26 | + | ## directory=$(inotifywait -q -r --format %w -e create /home/shared/) #It gets stuck on this line!! |
27 | chown --recursive --reference=$directory $directory | |
28 | chmod --recursive --reference=$directory $directory $$ sleep 1 | |
29 | done | |
30 | ;; | |
31 | ||
32 | stop) | |
33 | echo "Stopping Picontrol" | |
34 | LCD_PID=`ps auxwww | grep SharedFolderUpdate.sh | head -1 | awk '{print $2}'` | |
35 | kill -9 $LCD_PID | |
36 | ;; | |
37 | *) | |
38 | echo "Usage: /etc/init.d/SharedFolderUpdate.sh {start|stop}" | |
39 | exit 1 | |
40 | ;; | |
41 | esac | |
42 | exit 0 | |
43 | EOF1 |