OSDN Git Service

bc153b76c4285af08217e7d41f25f9704d4db333
[pukiwiki/pukiwiki_devel.git] / pkwk_chmod.sh
1 #!/bin/sh
2 # $Id: pkwk_chmod.sh,v 1.4 2011/01/16 14:50:37 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 o+r *.php */*.php
11 # chmod o+rx lib skin plugin image image/face doc
12 #    chmod 777 attach backup cache counter diff trackback wiki* 2>/dev/null
13 #    chmod 666 wiki*/*.txt cache/*.dat cache/*.ref cache/*.rel  2>/dev/null
14
15 check_dir()
16 {
17   for dir in "$@"; do
18     test -d "$dir" || return 1
19   done
20   return 0
21 }
22
23 list_dir()
24 {
25   # Needed
26   echo 'wiki'
27   echo 'diff'
28   echo 'backup'
29
30   # Optional
31   ls -d 'cache' 'counter' 'attach' wiki.[a-z][a-z] 2>/dev/null | while read dir; do
32     echo "$dir"
33   done
34 }
35
36 list_files()
37 {
38   for dir in "$@"; do
39     case "$dir" in
40       attach )
41          # Unfortunately attach/attached-files have no suffix
42          # that should be .bin or someting
43          find "$dir" -type f -name '*.log'
44       ;;
45       backup ) find "$dir" -type f \( -name '*.txt' -or -name '*.gz'     \) ;;
46       cache  ) find "$dir" -type f \( -name '*.dat' -or -name '*.re[fl]' \) ;;
47       *      ) find "$dir" -type f -name '*.txt' ;;
48     esac
49   done
50 }
51
52
53 # Validate
54 if ! check_dir ` list_dir ` ; then
55   echo 'ERROR: Seems not pukiwiki DATA_HOME'
56   exit 1
57 fi
58
59 # Run
60 list_dir | while read dir; do
61   chmod 777 "$dir" && {
62     list_files "$dir" | while read file; do
63       chmod 666 "$file"
64     done
65   }
66 done
67