1
0
Fork 0
My old website. I completely made this one in bash-scripting.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

235 lines
7.4 KiB

#!/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 "<center>" >> $SITE/$FILENAME.html
echo "<img src='http://noc.sciuro.org/munin/$DNAME/$i/cpu-day.png'>" >> $SITE/$FILENAME.html
echo "<img src='http://noc.sciuro.org/munin/$DNAME/$i/memory-day.png'>" >> $SITE/$FILENAME.html
echo "<img src='http://noc.sciuro.org/munin/$DNAME/$i/if_eth0-day.png'>" >> $SITE/$FILENAME.html
echo "</center>" >> $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 "<b>Howto's</b>" >> $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 "-<a href='__SITEURL__/$FILENAME.html'>$HTT</a>" >> $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 "<a href='mailto:react@sciuro.org?SUBJECT=$FILENAME'>React to Howto</a>" >> $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 "<b>Blog</b>" >> $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 "-<a href='__SITEURL__/$FILENAME.html'>$BTITLE</a>" >> $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 "<a href='mailto:react@sciuro.org?SUBJECT=$BLOGID'>React to blog</a>" >> $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 "<b>Photo's</b>" >> $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 "-<a href='__SITEURL__/$FILENAME.html'>$PTITLE</a>" >> $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 "<center><table border='0'>" >> $SITE/$FILENAME.html
T=0
rename 'y/A-Z/a-z/' $FILENAME/*
for j in `ls $FILENAME/*.jpg`; do
if [ $T == '0' ]; then
echo "<tr><td>" >> $SITE/$FILENAME.html
T=$((T+1))
elif [ $T == '5' ]; then
echo "</td></tr><tr><td>" >> $SITE/$FILENAME.html
T=1
else
echo "</td><td>" >> $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 "<a href='__SITEURL__/photo/$DIRNAME/$NAME.html'><img src='__SITEURL__/photo/$DIRNAME/thumbs/$IMAGENAME' width=120px></a>" >> $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 "<center><a href='__SITEURL__/$FILENAME.html'>index</a></center>" >> $SITE/photo/$DIRNAME/$NAME.html
echo "<center><img src='__SITEURL__/photo/$DIRNAME/normal/$IMAGENAME' width=600px></center>" >> $SITE/photo/$DIRNAME/$NAME.html
cat $LAYOUT/footer.html >> $SITE/photo/$DIRNAME/$NAME.html
echo -n "*"
done
echo "</table></center>" >> $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]"