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.

236 lines
7.4 KiB

11 years ago
#!/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"
11 years ago
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]"
11 years ago
# Server directory
echo -n "Generating server pages"
11 years ago
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]"
11 years ago
# Howto directory
echo -n "Generating howto pages"
11 years ago
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]"
11 years ago
# Blog pages
echo -n "Generating blog pages"
11 years ago
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]"
11 years ago
# Photo pages
echo -n "Generating Photo pages"
11 years ago
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]"
11 years ago
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 "
11 years ago
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
11 years ago
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
11 years ago
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
11 years ago
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
11 years ago
cat $LAYOUT/footer.html >> $SITE/photo/$DIRNAME/$NAME.html
echo -n "*"
11 years ago
done
echo "</table></center>" >> $SITE/$FILENAME.html
cat $LAYOUT/footer.html >> $SITE/$FILENAME.html
echo " [Ok]"
11 years ago
done
# Other directories
echo -n "Process extra directories"
11 years ago
for i in $EXTRA; do
rm -rf $SITE/$i
cp -a $i $SITE/$i
done
echo " [Ok]"
11 years ago
# Other files
echo -n "Process extra files"
cp _extra/* $SITE/
echo " [Ok]"
11 years ago
# Replace variables
echo -n "Replace variables"
11 years ago
for i in `find $SITE/ -name *.html`; do
sed -i 's/__SITEURL__/\/newsite/g' $i
done
echo " [Ok]"
11 years ago
# Publish
echo -n "Publish website"
11 years ago
rsync --delete --recursive $SITE/* 314:/usr/share/mini-httpd/html/newsite/
echo " [Ok]"