#!/bin/bash # Variables SITEURL="/newsite" LAYOUT=_layout SITE=site EXTRA='images scripts files' SERVERS='314.sciuro.org chip.sciuro.org skippy.sciuro.org slappy.sciuro.org irc.sciuro.org lists.laurentiusgroep.nl' # Prereq mkdir -p $SITE # Root pagina's echo -n "Generating root pages" rm -rf $SITE/*.html for i in `ls *.txt`; do FILENAME=`echo $i |cut -d\. -f1` cat $LAYOUT/header.html >> $SITE/$FILENAME.html cat $i >> $SITE/$FILENAME.html cat $LAYOUT/footer.html >> $SITE/$FILENAME.html done echo " [Ok]" # Server directory echo -n "Generating server pages" mkdir -p $SITE/servers/ rm -rf $SITE/servers/*.html for i in `ls servers/*.txt`; do FILENAME=`echo $i |cut -d\. -f1` cat $LAYOUT/header.html >> $SITE/$FILENAME.html cat $LAYOUT/servers.html >> $SITE/$FILENAME.html cat $i >> $SITE/$FILENAME.html cat $LAYOUT/footer.html >> $SITE/$FILENAME.html done for i in $SERVERS; do HNAME=`echo $i | cut -d\. -f1` DNAME=`echo $i | cut -d\. -f2,3 --output-delimiter=\.` FILENAME=servers/graph-$HNAME cat $LAYOUT/header.html >> $SITE/$FILENAME.html cat $LAYOUT/servers.html >> $SITE/$FILENAME.html cat servers/graph.txt >> $SITE/$FILENAME.html echo "" >> $SITE/$FILENAME.html echo "
" >> $SITE/$FILENAME.html echo "" >> $SITE/$FILENAME.html echo "" >> $SITE/$FILENAME.html echo "" >> $SITE/$FILENAME.html echo "
" >> $SITE/$FILENAME.html cat $LAYOUT/footer.html >> $SITE/$FILENAME.html done echo " [Ok]" # Howto directory echo -n "Generating howto pages" mkdir -p $SITE/howto/ rm -rf $SITE/howto/*.html cat $LAYOUT/header.html >> $SITE/howto/index.html echo "Howto's" >> $SITE/howto/index.html echo "" >> $SITE/howto/index.html echo "Some howto's I wrote. If something is wrong, or you need help, please send me" >> $SITE/howto/index.html echo "a message." >> $SITE/howto/index.html echo "" >> $SITE/howto/index.html for i in `ls howto/*.txt`; do FILENAME=`echo $i |cut -d\. -f1` HTT=`echo $FILENAME |cut -d\/ -f2` echo "-$HTT" >> $SITE/howto/index.html done cat $LAYOUT/footer.html >> $SITE/howto/index.html for i in `ls howto/*.txt`; do FILENAME=`echo $i |cut -d\. -f1` cat $LAYOUT/header.html >> $SITE/$FILENAME.html cat $i >> $SITE/$FILENAME.html MODTIME=`date -r $i +%A\ %B%e\ %Y,\ %R` echo "" >> $SITE/$FILENAME.html echo "React to Howto" >> $SITE/$FILENAME.html echo "Last modification: $MODTIME" >> $SITE/$FILENAME.html cat $LAYOUT/footer.html >> $SITE/$FILENAME.html done echo " [Ok]" # Blog pages echo -n "Generating blog pages" mkdir -p $SITE/blog/ rm -rf $SITE/blog/*.html cat $LAYOUT/header.html >> $SITE/blog/index.html echo "Blog" >> $SITE/blog/index.html for i in `ls -r blog/*.txt`; do FILENAME=`echo $i |cut -d\. -f1` BTITLE=`echo $FILENAME |cut -d\/ -f2 |cut -b12-` BFILEDATE=`echo $FILENAME |cut -d\/ -f2 |cut -b-10` CURMONTH=`date -d$BFILEDATE +%B\ %Y` if [ "$CURMONTH" != "$LASTMONTH" ]; then LASTMONTH=$CURMONTH echo "" >> $SITE/blog/index.html echo "$CURMONTH" >> $SITE/blog/index.html fi echo "-$BTITLE" >> $SITE/blog/index.html done cat $LAYOUT/footer.html >> $SITE/blog/index.html for i in `ls blog/*.txt`; do FILENAME=`echo $i |cut -d\. -f1` cat $LAYOUT/header.html >> $SITE/$FILENAME.html BFILEDATE=`echo $FILENAME |cut -d\/ -f2 |cut -b-10` BDATE=`date -d$BFILEDATE +%A\ %B\ %e\ %Y` echo $BDATE >> $SITE/$FILENAME.html echo "" >> $SITE/$FILENAME.html cat $i >> $SITE/$FILENAME.html BLOGID=`echo $FILENAME |cut -d\/ -f2` echo "" >> $SITE/$FILENAME.html echo "React to blog" >> $SITE/$FILENAME.html cat $LAYOUT/footer.html >> $SITE/$FILENAME.html done echo " [Ok]" # Photo pages echo -n "Generating Photo pages" mkdir -p $SITE/photo/ rm -rf $SITE/photo/*.html cat $LAYOUT/header.html >> $SITE/photo/index.html echo "Photo's" >> $SITE/photo/index.html for i in `ls -r photo/*.txt`; do FILENAME=`echo $i |cut -d\. -f1` PTITLE=`echo $FILENAME |cut -d\/ -f2 |cut -b12-` PFILEDATE=`echo $FILENAME |cut -d\/ -f2 |cut -b-10` CURMONTH=`date -d$PFILEDATE +%B\ %Y` if [ "$CURMONTH" != "$LASTMONTH" ]; then LASTMONTH=$CURMONTH echo "" >> $SITE/photo/index.html echo "$CURMONTH" >> $SITE/photo/index.html fi echo "-$PTITLE" >> $SITE/photo/index.html done cat $LAYOUT/footer.html >> $SITE/photo/index.html echo " [Ok]" for i in `ls photo/*.txt`; do FILENAME=`echo $i |cut -d\. -f1` BFILEDATE=`echo $FILENAME |cut -d\/ -f2 |cut -b-10` BDATE=`date -d$BFILEDATE +%A\ %B\ %e\ %Y` BLOGID=`echo $FILENAME |cut -d\/ -f2` DIRNAME=`echo $FILENAME |cut -d\/ -f2` echo -n "Processing photo album $DIRNAME " mkdir -p $SITE/$FILENAME/normal/ mkdir -p $SITE/$FILENAME/thumbs/ #rm -rf $SITE/$FILENAME/thumbs/*.jpg rm -rf $SITE/photo/$DIRNAME/*.html cat $LAYOUT/header.html >> $SITE/$FILENAME.html echo $BDATE >> $SITE/$FILENAME.html echo "" >> $SITE/$FILENAME.html cat $i >> $SITE/$FILENAME.html echo "" >> $SITE/$FILENAME.html echo "
" >> $SITE/$FILENAME.html T=0 rename 'y/A-Z/a-z/' $FILENAME/* for j in `ls $FILENAME/*.jpg`; do if [ $T == '0' ]; then echo "
" >> $SITE/$FILENAME.html T=$((T+1)) elif [ $T == '5' ]; then echo "
" >> $SITE/$FILENAME.html T=1 else echo "" >> $SITE/$FILENAME.html T=$((T+1)) fi IMAGENAME=`echo $j |cut -d\/ -f3` if [ ! -f $SITE/photo/$DIRNAME/thumbs/$IMAGENAME ]; then convert -resize 120 photo/$DIRNAME/$IMAGENAME $SITE/photo/$DIRNAME/thumbs/$IMAGENAME fi if [ ! -f $SITE/photo/$DIRNAME/normal/$IMAGENAME ]; then convert -resize 600 photo/$DIRNAME/$IMAGENAME $SITE/photo/$DIRNAME/normal/$IMAGENAME fi NAME=`echo $IMAGENAME |cut -d\. -f1` echo "" >> $SITE/$FILENAME.html # Picture page cat $LAYOUT/header.html >> $SITE/photo/$DIRNAME/$NAME.html echo $BDATE >> $SITE/photo/$DIRNAME/$NAME.html echo "" >> $SITE/photo/$DIRNAME/$NAME.html cat $i >> $SITE/photo/$DIRNAME/$NAME.html echo "" >> $SITE/photo/$DIRNAME/$NAME.html echo "
index
" >> $SITE/photo/$DIRNAME/$NAME.html echo "
" >> $SITE/photo/$DIRNAME/$NAME.html cat $LAYOUT/footer.html >> $SITE/photo/$DIRNAME/$NAME.html echo -n "*" done echo "
" >> $SITE/$FILENAME.html cat $LAYOUT/footer.html >> $SITE/$FILENAME.html echo " [Ok]" done # Other directories echo -n "Process extra directories" for i in $EXTRA; do rm -rf $SITE/$i cp -a $i $SITE/$i done echo " [Ok]" # Other files echo -n "Process extra files" cp _extra/* $SITE/ echo " [Ok]" # Replace variables echo -n "Replace variables" for i in `find $SITE/ -name *.html`; do sed -i 's/__SITEURL__/\/newsite/g' $i done echo " [Ok]" # Publish echo -n "Publish website" rsync --delete --recursive $SITE/* 314:/usr/share/mini-httpd/html/newsite/ echo " [Ok]"