Annotation of embedaddon/php/ext/session/mod_files.sh, revision 1.1.1.2

1.1       misho       1: #! /bin/sh
                      2: 
1.1.1.2 ! misho       3: if [[ "$2" = "" ]] || [[ "$3" = "" ]]; then
        !             4:        echo "Usage: $0 BASE_DIRECTORY DEPTH HASH_BITS"
        !             5:        echo "BASE_DIRECTORY will be created if it doesn't exist"
        !             6:        echo "DEPTH must be an integer number >0"
        !             7:        echo "HASH_BITS(session.hash_bits_per_charactor) should be one of 4, 5, or 6"
        !             8:        exit 1
1.1       misho       9: fi
                     10: 
1.1.1.2 ! misho      11: if [[ "$2" = "0" ]] && [[ ! "$4" = "recurse" ]]; then
        !            12:        echo "Can't create a directory tree with depth of 0, exiting."
1.1       misho      13: fi
                     14: 
1.1.1.2 ! misho      15: if [[ "$2" = "0" ]]; then
        !            16:        exit 0
        !            17: fi
        !            18: 
        !            19: directory="$1"
        !            20: depth="$2"
        !            21: hashbits="$3"
        !            22: 
1.1       misho      23: hash_chars="0 1 2 3 4 5 6 7 8 9 a b c d e f"
1.1.1.2 ! misho      24: 
        !            25: if [[ "$hashbits" -ge "5" ]]; then
        !            26:        hash_chars="$hash_chars g h i j k l m n o p q r s t u v"
1.1       misho      27: fi
                     28: 
1.1.1.2 ! misho      29: if [[ "$hashbits" -ge "6" ]]; then
        !            30:        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 - ,"
        !            31: fi
        !            32: 
        !            33: while [[ -d $directory ]] && [[ $( ls $directory ) ]]; do
        !            34:        echo "Directory $directory is not empty! What would you like to do?"
        !            35: 
        !            36:        options="\"Delete directory contents\" \"Choose another directory\" \"Quit\""
        !            37:        eval set $options
        !            38:        select opt in "$@"; do
        !            39: 
        !            40:               if [[ $opt = "Delete directory contents" ]]; then
        !            41:                      echo "Deleting $directory contents... "
        !            42:                      rm -rf $directory/*
        !            43:               elif [[ $opt = "Choose another directory" ]]; then
        !            44:                      echo "Which directory would you like to choose?"
        !            45:                      read directory
        !            46:               elif [[ $opt = "Quit" ]]; then
        !            47:                      exit 0
        !            48:               fi
        !            49: 
        !            50:               break;
        !            51:        done
        !            52: done
        !            53: 
        !            54: if [[ ! -d $directory ]]; then
        !            55:        mkdir -p $directory
        !            56: fi
        !            57: 
        !            58: 
        !            59: echo "Creating session path in $directory with a depth of $depth for session.hash_bits_per_character = $hashbits"
        !            60: 
1.1       misho      61: for i in $hash_chars; do
1.1.1.2 ! misho      62:        newpath="$directory/$i"
        !            63:        mkdir $newpath || exit 1
        !            64:        sh $0 $newpath `expr $depth - 1` $hashbits recurse
1.1       misho      65: done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>