#!/bin/bash
[ "$2" == "" ] && exec echo "Usage: $0 <Type: title_modify/content_add_1st/content_modify> <set_id/config_name/config_name>"

TYPE=$1
PARAM2=$2

case $TYPE in
    title_modify)
        SET_ID=${PARAM2}
        /usr/bin/sed -i.bak "s/MRTG Index Page/MRTG Index Page (N1-EN SET${SET_ID})/" index.html 
        ;;
    content_add_1st)
        CONFIG_NAME=${PARAM2}
        env LANG=C /usr/bin/mrtg ${CONFIG_NAME}
        ;;
    content_modify)
        CONFIG_NAME=${PARAM2}
        /usr/bin/indexmaker ${CONFIG_NAME} > index.html
        ;;
    content)
        SET_ID=11
        CONFIG_NAME=${PARAM2}
        env LANG=C /usr/bin/mrtg ${CONFIG_NAME} || true
        /usr/bin/indexmaker --title="MRTG Index Page SET${SET_ID}" ${CONFIG_NAME} > index.html
        ;;
esac
