OSDN Git Service

Keep the file timesamp of commit time
[pukiwiki/pukiwiki_devel.git] / pkwk_chmod.sh
1 #!/bin/sh
2 # $Id: pkwk_chmod.sh,v 1.10 2011/01/24 15:12:51 henoheno Exp $
3 #  Chmod script for PukiWiki DATA_HOME
4 #  ==========================================================
5    Copyright='(C) 2002-2004 minix-up project, All Rights Reserved'
6    Homepage='http://cvsknit.sourceforge.net/'
7    License='(also revised)BSD Licnese, NO WARRANTY'
8 #
9
10 check_dir()
11 {
12   for dir in "$@"; do
13     test -d "$dir" || return 1
14   done
15   return 0
16 }
17
18 list_dir()
19 {
20   # Needed
21   echo 'wiki'
22   echo 'diff'
23   echo 'backup'
24
25   # Optional
26   ls -d 'cache' 'counter' 'attach' wiki.[a-z][a-z] 2>/dev/null | while read dir; do
27     echo "$dir"
28   done
29 }
30
31 list_files()
32 {
33   for dir in "$@"; do
34     case "$dir" in
35       attach )
36          # Unfortunately attach/attached-files have no suffix
37          # that should be .bin or someting
38          find "$dir" -type f -name '*.log'
39       ;;
40       backup ) find "$dir" -type f \( -name '*.txt' -or -name '*.gz'     \) ;;
41       cache  ) find "$dir" -type f \( -name '*.dat' -or -name '*.re[fl]' -or -name '*.lock' \) ;;
42       *      ) find "$dir" -type f -name '*.txt' ;;
43     esac
44   done
45 }
46
47
48 # Validate
49 if ! check_dir ` list_dir ` ; then
50   echo 'ERROR: Seems not pukiwiki DATA_HOME'
51   exit 1
52 fi
53
54 # Run
55 list_dir | while read dir; do
56   chmod 777 "$dir" && {
57     list_files "$dir" | while read file; do
58       chmod 666 "$file"
59     done
60   }
61 done
62
63 # ERRATA
64 chmod a-x INSTALL.txt image/b_pukiwiki.official.png
65
66 chmod o+r .ht* */.htaccess *.php */*.php image/*.png image/face/*.png */index.html
67 chmod o+rx lib skin plugin image image/face
68
69 #chmod o+rx doc
70 #chmod o+r *.txt doc/*.txt
71
72 # .htaccess