#!/bin/bash
#이 스크립트는 홈디렉토리에 있는 그림파일들을 이용해 간단하게
#갤러리는 만들어 줍니다.
#이 스크립트의 작성자는 http://blog.kashel.net 의 luark 입니다.
#GPL을 따르므로 맘대로 고쳐쓰셔도 좋지만 원작자 표시는 지우지 말아주세요 ㅜㅜ
#디렉토리 구조 탐색
#선언부분
galfile="/home/luark/gallery.html"
#사진이 저장된 가장 상위디렉토리
sshotdir="/home/luark/sshot/"
#갤러리 이름
homename="Gallery for Kashel. powered by easywebgallery"
#웹계정의 갤러리용 디렉토리. 미리 만들어주셔야 합니다.
galdir="luark@kashel.net:~/kashel.net/htdocs/sshot"
#페이지당 사진 수
articleperpage="3"
#사진의 크기
width="320"
height="240"
#홈페이지의 메타데이타
metadata="
$homename"
#예상페이지수 계산
howmanypics=$(echo $(ls $sshotdir | wc -l))
howmanypage=$(echo $(ls $sshotdir | wc -l)/$articleperpage | bc)
howmanysub=$(echo $(ls $sshotdir | wc -l))
#여분으로 하나더
page=$(echo $howmanypage+1 | bc)
#작업할디렉토리로 이동합니다.
cd $sshotdir;cd ..
#프레임의 기본틀 작성
echo "" > $galfile
echo "$metadata" >> $galfile
echo "" >> $galfile
echo "" >> $galfile
#프레임1 sub.html작성
echo "$metadata " > sub.html
echo "$homename Move To KasheL Blog
" >> sub.html
#프레임2 page.html작성
echo "$metadata " > page.html
echo "1. You can show the page list by clicking Topic." >> page.html
#프레임3 pic.html작성
echo "$metadata " > pic.html
echo "2. You can show the pictures by clicking page number." >> pic.html
#주제목록을 만듭니다.
subcount=0
echo "페이지 목록을 만들고 있습니다."
echo "다음과 같은 주제가 검출되었습니다."
for sub in $(ls $sshotdir);do
echo "$sub"
done
for sub in $(ls $sshotdir);do
#페이지 목록을 만듭니다.
echo "$metadata Subject : $sub ||" >> pagefile_$sub.html
((howmanysub+=1))
#그림디렉토리의 파일목록을 출력하여 html파일로 만드는 부분입니다.
pagenumber=1
echo "
" >> galfile_$sub$pagenumber.html
while ((pagenumberFile Name : $pic" >> galfile_$sub$pagenumber.html
echo -n "" >> galfile_$sub$pagenumber.html
((count+=1))
#페이지당 그림수를 파악해서 각 배수에 해당할 때마다 페이지링크를 추가하고 해당하지 않으면 그냥 계속합니다.
if ((count%articleperpage));then
continue
else
echo -n "$pagenumber " >> pagefile_$sub.html
((pagenumber+=1))
echo "
" >> galfile_$sub$pagenumber.html
count=0
fi
done
echo "
" >> galfile_$sub$pagenumber.html
done
#주제숫자를 파악해서 같으면 html을 종료하고 빠져나가고, 작으면 계속됩니다.
if ((howmanysub" >> pagefile_$sub.html
break
else ((howmanysub=subcount));
((subcount+=1))
continue
fi
done
#주제 목록을 작성합니다.
echo "주제 목록을 작성중입니다......"
echo -n "Subject : " >> sub.html
for sub in $(ls $sshotdir);do
echo -n "$sub " >> sub.html
done
echo "" >> sub.html
echo "사진의 인덱싱이 완료되었습니다."
#mv *html sshot
#파일을 rsync할 준비를 합니다.
mv $galfile $sshotdir/index.html
mv *html $sshotdir/
#싱크합니다.
echo "이제 웹계정에 업로드 하도록 하겠습니다. 만약 암호를 묻는다면 계정의 암호를 넣어주세요."
rsync -av -e "ssh -p 7373" $sshotdir/* $galdir
rm $sshotdir/*.html
#완성입니다.
echo "이처럼 손쉬운 방법으로 웹갤러리가 만들어 졌습니다. http://blog.kashel.net 의 luark에게 댓글이라도 남겨주세요"