mklinklist.sh

 

#
###
### mklinklist.sh
###
### Create a file called linklist.sh
### which contains link.sh linking commands
### to files in current directory.
###
###
### Usage:
###
###    mklinklist.sh filetype linkdirectory [ 1 ]
###
### Where filetype is the type of file to create 
### links to: *.html, *.java, *.xml, or javadoc.
###    
### linkdirectory is the directory in and under which
### to look for files in which to insert links.
###    
### If a 1 is present, use link1.sh, which only looks     
### in linkdirectory, and not recursively into directories   
### below.   
###    



if [ "$2" = "" ]
then
   echo "Usage: mklinklist.sh linkdir filetype [ linkphrase ] [ 1 ]"
   exit 1
fi



DEPOT=$1
filetype=$2
linkphrase=$3
x1=$4


#DEPOT=/var/www/depot/dev



if [ "$filetype" = "htm" ]
then

    echo "date" > linklist.sh
    echo "x=$DEPOT" >> linklist.sh

    ## If were are dealing with Javadoc files
    ## create a link to package-summary.
    if [ "$linkphrase" != "" ]
    then
        echo link${x1}.sh \$x package-summary.htm $linkphrase  >> linklist.sh
    fi

    ls -1 *.htm 2>/dev/null | \
    grep -v package | \
    sed "s/^/link${x1}.sh \$x /" > tmp.out

    ls -1 *.htm 2>/dev/null | \
    grep -v package | \
    sed "s/\.htm//" > tmp1.out

    paste -d" " tmp.out tmp1.out  >> linklist.sh
    echo "date" >> linklist.sh

    #sh ./linklist.sh
fi

if [ "$filetype" = "html" ]
then

    echo "date" > linklist.sh
    echo "x=$DEPOT" >> linklist.sh

    ## If were are dealing with Javadoc files
    ## create a link to package-summary.
    #if [ "$linkphrase" != "" ]
    #then
        echo link${x1}.sh \$x package-summary.html $linkphrase  >> linklist.sh
    #fi

    ls -1 *.html 2>/dev/null | \
    grep -v package | \
    grep -v adsense | \
    sed "s/^/link${x1}.sh \$x /" > tmp.out

    ls -1 *.html 2>/dev/null | \
    grep -v package | \
    grep -v adsense | \
    sed "s/\.html//" > tmp1.out

    paste -d" " tmp.out tmp1.out  >> linklist.sh
    echo "date" >> linklist.sh

    #sh ./linklist.sh
fi


if [ "$filetype" = "java" ]
then


    echo "date" > linklist.sh
    echo "x=$DEPOT" >> linklist.sh

    if [ "$linkphrase" != "" ]
    then
        echo link${x1}.sh \$x index.html $linkphrase  >> linklist.sh
    fi
        
    ls -1 *.java.html 2>/dev/null | \
    grep -v package | \
    sed "s/^/link${x1}.sh \$x /" > tmp.out

    ls -1 *.java.html 2>/dev/null | \
    grep -v package | \
    sed "s/\.java\.html//" > tmp1.out

    paste -d" " tmp.out tmp1.out  >> linklist.sh
    echo "date" >> linklist.sh

    #sh ./linklist.sh
fi


if [ "$filetype" = "xml" ]
then

    echo "date" > linklist.sh
    echo "x=$DEPOT" >> linklist.sh

    ls -1 *.xml.html 2>/dev/null | sed "s/^/link${x1}.sh \$x /" > tmp.out
    ls -1 *.xml.html 2>/dev/null | sed "s/\.html//" > tmp1.out

    paste -d" " tmp.out tmp1.out  >> linklist.sh
    echo "date" >> linklist.sh

    #sh ./linklist.sh

fi

if [ "$filetype" = "jar" ]
then

    echo "date" > linklist.sh
    echo "x=$DEPOT" >> linklist.sh

    ls -1 *.jar 2>/dev/null | sed "s/^/link${x1}.sh \$x /" > tmp.out
    ls -1 *.jar 2>/dev/null | sed "s/\.html//" > tmp1.out

    paste -d" " tmp.out tmp1.out  >> linklist.sh
    echo "date" >> linklist.sh

    #sh ./linklist.sh

fi