リビジョン | 8370c4f6ffafb6c9c18515c56a030c453b5813da (tree) |
---|---|
日時 | 2011-01-16 21:18:26 |
作者 | henoheno <henoheno> |
コミッター | henoheno |
initial
@@ -0,0 +1,65 @@ | ||
1 | +#!/bin/sh | |
2 | +# $Id: pkwk_chmod.sh,v 1.1 2011/01/16 12:18:26 henoheno Exp $ | |
3 | +# ========================================================== | |
4 | + Copyright='(C) 2002-2004 minix-up project, All Rights Reserved' | |
5 | + Homepage='http://cvsknit.sourceforge.net/' | |
6 | + License='(also revised)BSD Licnese, NO WARRANTY' | |
7 | +# | |
8 | + | |
9 | + | |
10 | +# chmod 777 attach backup cache counter diff trackback wiki* 2>/dev/null | |
11 | +# chmod 666 wiki*/*.txt cache/*.dat cache/*.ref cache/*.rel 2>/dev/null | |
12 | + | |
13 | +check_dir() | |
14 | +{ | |
15 | + for dir in "$@"; do | |
16 | + test -d "$dir" || return 1 | |
17 | + done | |
18 | + return 0 | |
19 | +} | |
20 | + | |
21 | +list_dir() | |
22 | +{ | |
23 | + # Needed | |
24 | + echo 'wiki' | |
25 | + echo 'diff' | |
26 | + echo 'backup' | |
27 | + | |
28 | + # Optional | |
29 | + ls -d 'cache' 'counter' 'attach' wiki.[a-z][a-z] 2>/dev/null | while read dir; do | |
30 | + echo "$dir" | |
31 | + done | |
32 | +} | |
33 | + | |
34 | +list_files() | |
35 | +{ | |
36 | + for dir in "$@"; do | |
37 | + case "$dir" in | |
38 | + attach ) | |
39 | + # Unfortunately attach/attached-files have no suffix | |
40 | + # that should be .bin or someting | |
41 | + find "$dir" -type f -name '*.log' | |
42 | + ;; | |
43 | + backup ) find "$dir" -type f \( -name '*.txt' -or -name '*.gz' \) ;; | |
44 | + cache ) find "$dir" -type f \( -name '*.dat' -or -name '*.re[fl]' \) ;; | |
45 | + * ) find "$dir" -type f -name '*.txt' ;; | |
46 | + esac | |
47 | + done | |
48 | +} | |
49 | + | |
50 | + | |
51 | +# Validate | |
52 | +if ! check_dir ` list_dir ` ; then | |
53 | + echo 'ERROR: Seems not pukiwiki root directory' | |
54 | + exit 1 | |
55 | +fi | |
56 | + | |
57 | +# Run | |
58 | +list_dir | while read dir; do | |
59 | + chmod 777 "$dir" && { | |
60 | + list_files "$dir" | while read file; do | |
61 | + chmod 666 "$file" | |
62 | + done | |
63 | + } | |
64 | +done | |
65 | + |