#!/bin/sh
# mkuniq.sh 0.1
# Copyright (C) 2005 John Eriksson
#
# Description:
# Makes a static index.php instead of one dynamically genereated one.
# This makes the page load faster. Used mostly for the pics archive.

# perform basic checks
if ( ! echo "$PWD" | grep bilder ); then
	echo "be in the picture catalog."
	exit 1
fi

CATALOG="`basename $PWD`"

if [ "$CATALOG" = "bilder" -o "$CATALOG" = "pics" ]; then
	echo "be in the correct catalog."
	exit 1
fi

if [ -f index.php ]; then
	echo "remove the index.php first."
	exit 1
fi

# make the symlink
ln -sf ../bildscript.php index.php

# get the generated file
wget localhost/pics/"`basename "$PWD"`"/

# remove symlink and place unique file with same name
rm -f index.php
mv index.html index.php

# we're done
echo "done."

# EOF
