NB update bash cgi script

Just wrote a little bash cgi script to make sure nanoblogger is kept up to date (the calendar more-or-less). Below is the code for it. You’ll need to change your main_index.htm template file to have a server side include to the cgi script of course, and you will probably have to do a little tweaking to nb/lib/config.sh to produce .shtml files instead of .html files. Of course, one could just create a cron job to update all the nanoblogger data files, but if you don’t have access to crontab, this would be an alternative solution.

#!/usr/bin/bash 
# 
# nbupdate.cgi by strikelight
# free for use and modification
# 

echo Content-type: text/plain 
echo “” 

# Configure the following variables first 

NB_PATH=”/home/username/nanoblogger/nb” 
NB_UPDATE_ARGS=”-b /blog_dir -u” 
NB_UPDATE_FILE=”/blog_dir/data/update.log” 
NB_UPDATE_TIME=0 

if [ -f “$NB_UPDATE_FILE” ]; then NB_UPDATE_TIME=`stat -f $NB_UPDATE_FILE` NB_UPDATE_TIME=`date -r $NB_UPDATE_TIME +D` else NB_RESULT=`touch $NB_UPDATE_FILE` fi 
NB_CURR_TIME=`date +D` 

if [ “$NB_CURR_TIME” != “$NB_UPDATE_TIME” ]; then NB_RESULT=`$NB_PATH $NB_UPDATE_ARGS` NB_RESULT=`rm $NB_UPDATE_FILE` 

NB_RESULT=`touch $NB_UPDATE_FILE` fi