Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Mine
Thursday, August 6th, 2009 at 2:48:17am UTC 

  1. Index: trunk/mod_files.sh
  2. ===================================================================
  3. --- trunk/mod_files.sh  (revision 44)
  4. +++ trunk/mod_files.sh  (working copy)
  5. @@ -1,25 +1,65 @@
  6.  #! /bin/sh
  7.  
  8. -if test "$2" = ""; then
  9. -       echo "usage: $0 basedir depth"
  10. +if [[ "$2" = "" ]] || [[ "$3" = "" ]]; then
  11. +       echo "Usage: $0 BASE_DIRECTORY DEPTH MAJOR_PHP_VERSION"
  12. +       echo "BASE_DIRECTORY will be created if it doesn't exist"
  13. +       echo "DEPTH must be an integer number >0"
  14. +       echo "MAJOR_PHP_VERSION should be one of 4, 5, or 6"
  15.         exit 1
  16.  fi
  17.  
  18. -if test "$2" = "0"; then
  19. +if [[ "$2" = "0" ]] && [[ ! "$4" = "recurse" ]]; then
  20. +       echo "Can't create a directory tree with depth of 0, exiting."
  21. +fi
  22. +
  23. +if [[ "$2" = "0" ]]; then
  24.         exit 0
  25.  fi
  26.  
  27. +directory="$1"
  28. +depth="$2"
  29. +PHPVer="$3"
  30. +
  31.  hash_chars="0 1 2 3 4 5 6 7 8 9 a b c d e f"
  32. -if test "$3" -a "$3" -ge "5"; then
  33. -  hash_chars="$hash_chars g h i j k l m n o p q r s t u v"
  34. -  if test "$3" -eq "6"; then
  35. -    hash_chars="$hash_chars w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z - ,"
  36. -  fi
  37. +
  38. +if [[ "$PHPVer" -ge "5" ]]; then
  39. +       hash_chars="$hash_chars g h i j k l m n o p q r s t u v"
  40.  fi
  41.  
  42. +if [[ "$PHPVer" -ge "6" ]]; then
  43. +       hash_chars="$hash_chars w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z - ,"
  44. +fi
  45. +
  46. +while [[ -d $directory ]] && [[ $( ls $directory ) ]]; do
  47. +       echo "Directory $directory is not empty! What would you like to do?"
  48. +       
  49. +       options="\"Delete directory contents\" \"Choose another directory\" \"Quit\""
  50. +       eval set $options
  51. +       select opt in "$@"; do
  52. +              
  53. +              if [[ $opt = "Delete directory contents" ]]; then
  54. +                     echo "Deleting $directory contents... "
  55. +                     rm -rf $directory/*
  56. +              elif [[ $opt = "Choose another directory" ]]; then
  57. +                     echo "Which directory would you like to choose?"
  58. +                     read directory
  59. +              elif [[ $opt = "Quit" ]]; then
  60. +                     exit 0
  61. +              fi
  62. +              
  63. +              break;
  64. +       done
  65. +done
  66. +
  67. +if [[ ! -d $directory ]]; then
  68. +       mkdir -p $directory
  69. +fi
  70. +
  71. +
  72. +echo "Creating session path in $directory with a depth of $depth for PHP Version $PHPVer".X
  73. +
  74.  for i in $hash_chars; do
  75. -       newpath="$1/$i"
  76. +       newpath="$directory/$i"
  77.         mkdir $newpath || exit 1
  78. -       sh $0 $newpath `expr $2 - 1` $3
  79. +       sh $0 $newpath `expr $depth - 1` $PHPVer recurse
  80.  done
  81. -

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right
worth-right