INDEX_TPL=index-template.html
INDEX_OUT=index.html
INDEX_TMP=.index-tmp.html
HTML_TMP=.tmp.html

cp $INDEX_TPL $INDEX_TMP

# lista de archivos
echo '<ul class="files">' > $HTML_TMP

for f in `ls`; do
	echo "<li><a href='$f'>$f</a></li>" >> $HTML_TMP
done

echo '</ul>' >> $HTML_TMP

sed -i "/MY_FILES/{r $HTML_TMP
d
}" $INDEX_TMP

# lista de usuaries
echo '<ul class="usus">' > $HTML_TMP

for usu in `ls /home`; do
	echo "<li><a href='/~$usu'>~$usu</a> <a href='/~$usu/blog/'>[b]</a></li>" >> $HTML_TMP
done

echo '</ul>' >> $HTML_TMP

sed -i "/HOME_LINKS/{r $HTML_TMP
d
}" $INDEX_TMP

# copiamos temp final a index final
cp $INDEX_TMP $INDEX_OUT

# borramos temps
rm $INDEX_TMP $HTML_TMP
