[ Index ]

PHP Cross Reference of Web Application Component Toolkit

title

Body

[close]

/ -> setup.sh (source)

   1  #!/bin/sh
   2  
   3  # Create and set permissions on directories used for storing compiled templates.
   4  
   5  # Author: Jonathon Ramsey <jon@bangoid.com>
   6  #         Nicolas Cadou
   7  #         R. Michael Van Dam
   8  # This file is released under the LGPL license. See the file LICENSE in the root
   9  # of the distribution for details.
  10  # $Id: setup.sh,v 1.5 2004/05/03 23:31:49 jon-bangoid Exp $
  11  
  12  cache_dir="cache";
  13  templates_dir="templates";
  14  compiled_dir="compiled";
  15  cvsdir="CVS";
  16  perms="0777"
  17  
  18  # Recursively step thru dir structure, setting apt permissions for compiled
  19  # template and cache directories
  20  writableDirSetup() {
  21      for i in *; do
  22          if [ -d "$i" ]; then
  23              cd "$i";
  24              if [[ "$i" == "$templates_dir" ]]; then
  25                  compiledSetup;
  26              elif [[ "$i" == "$cache_dir" ]]; then
  27                  chmod $perms .;
  28              fi
  29              writableDirSetup;
  30              cd ..;
  31          fi
  32      done
  33      return 0;
  34  }
  35  
  36  # Set permissions on compiled directories to world writable
  37  compiledSetup() {
  38      if [ ! -e "`pwd`/$compiled_dir" ]; then
  39          mkdir "$compiled_dir";
  40      fi
  41      chmod $perms "$compiled_dir";
  42      cd "$compiled_dir";
  43      compiledSubdirSetup;
  44      cd ..;
  45      return 0;
  46  }
  47  
  48  # Set permissions on subdirectories of compiled to world writable
  49  compiledSubdirSetup() {
  50      for i in *; do
  51          if [[ -d "$i" && "$i" != "$cvsdir" ]]; then
  52              chmod $perms "$i";
  53              cd "$i";
  54              compiledSubdirSetup;
  55              cd ..;
  56          fi
  57      done
  58  }
  59  
  60  cat <<EOF
  61  
  62  The WACT templating system requires PHP writeable directories
  63  (templates/compiled and cache) to store its compiled templates and output
  64  caches.
  65  
  66  This script sets up the required directories so that the examples and unit
  67  tests will run correctly.  The required directories are set up as WORLD
  68  writeable. You may prefer to change them to OWNER+GROUP writeable, with
  69  their GROUP set to that of your webserver.
  70  
  71  EOF
  72  cd examples;
  73  writableDirSetup;
  74  cd ..;
  75  if [ 0 -eq $? ]; then
  76      echo "The WACT examples are now all set up and ready to roll. Have fun.";
  77  else
  78      cat <<EOF
  79  Something has gone wrong. The end result was supposed to be a
  80  '$compiled_dir' directory under every '$templates_dir' directory, and
  81  several '$cache_dir', directories, all with permissions set to 777.
  82  
  83  Sorry. Please patch the script and let us know.
  84  
  85  EOF
  86  fi
  87  exit 0;


Generated: Sun Nov 28 19:36:09 2004 Cross-referenced by PHPXref 0.5