#!/bin/sh #set -x #chmod u+rx generateindex SUCCESS=0 E_NOARGS=65 newfile="generateindex.shtml"; oldfile="index.shtml"; # Should only use no parameter if [[ $# -ne 0 ]]; then echo "Usage: $0" exit $E_NOARGS fi # Header echo "" > $newfile echo "" >> $newfile echo " " >> $newfile echo " Surprise" >> $newfile echo " " >> $newfile # Only CHANGE this section with appropriate values echo " " >> $newfile echo " " >> $newfile # Only CHANGE this section echo "" >> $newfile echo "" >> $newfile echo " " >> $newfile echo "

" >> $newfile echo "

" >> $newfile echo " Surprise" >> $newfile echo "

" >> $newfile echo " " >> $newfile echo "" >> $newfile echo " " >> $newfile # Body #ndx1=${#filelist[*]} ndx1=0 # Build the weblinks of files just after the body part. echo "Building the weblinks" #while [ $ndx1 -gt 0 ]; do while [ $ndx1 -lt ${#filelist[*]} ]; do #ndx1=$ndx1-1 echo "Processing ${filelist[$ndx1]}..." #echo "ndx1=$ndx1" trfile=${filelist[$ndx1]/%a.jpg/} echo "

" >> $newfile echo "

" >> $newfile echo " \"$trfile\"" >> $newfile echo "
" >> $newfile echo " Got a surprise for you. Select the image. Dated: " >> $newfile echo "
" >> $newfile ndx1=$ndx1+1 done # Footer echo "

" >> $newfile echo " \"Valid\"Valid" >> $newfile # Add something here if needed echo "

" >> $newfile echo " " >> $newfile echo "" >> $newfile # Footer # Backups the original and then rename the new copy as the original if test -s $oldfile; then echo "Processing $oldfile..." mv $oldfile $oldfile~;mv $newfile $oldfile # If there is no differences, bring the original back. diff --brief $oldfile $oldfile~ if [ "$?" -eq $SUCCESS ]; then echo "No differences found." mv $oldfile~ $oldfile else echo Processed $oldfile fi else mv $newfile $oldfile echo Processed $oldfile fi