#!/usr/local/bin/bash # # CREATE-ADMIN-PAGE # # script to create an admin page with all the mrtg info from all users. # # REQUIREMENTS: # - you must have set up all your mrtg-users as outlined and all paths must be the same (or check your paths and edit them please!) # - you must realize that I made this for my system alone (almost) and that it should work on any freebsd server, however I make no guarantees. # # # Zoidial, Inc. # Eric Thern eric(at)zoidial.com # # May 6, 2003 # # # variables - SET THESE! # # path to copy the resulting `admin` folder to # somewhere web-accessable, obviously # !! - don't forget the trailing / HTMLPATH=/home/adminuser/public_html/traffic/ # set your bandwidth price (in dollars) BANDWIDTHPRICE=5 # company name INDEXTITLE="Zoidial Incorporated Bandwidth Checker" # support email - IMPORTANT - escape your @. please! \@ DO NOT USE "@" without the \ -- don't do it. you'll regret it. SUPPORTEMAIL="support\@zoidial.com" # # use config files from the mrtg-users script to get the user information # edits the admin templates for each user adding their username and their bandwidth limit # rm -f /root/mrtg/admin/user-templates/* for i in `ls -1 /root/mrtg/mrtg-users/ |grep cfg | awk -F"." '{print $1}'`; do sed -e "s/USER/$i/g" /root/mrtg/admin/admin-template > /root/mrtg/admin/$i.backuptemplate && sed -e "s/BANDWIDTH/`cat /home/$i/public_html/traffic/index.php |grep "Bandwidth;" | awk -F';' '{print $4}' | awk -F'"' '{print $1}'`/" /root/mrtg/admin/$i.backuptemplate > /root/mrtg/admin/$i.backuptemplate2 && sed -e "s/EMAILARGH/$SUPPORTEMAIL/" /root/mrtg/admin/$i.backuptemplate2 > /root/mrtg/admin/user-templates/$i && rm /root/mrtg/admin/$i.*; done # # set up the index pages # cat /root/mrtg/admin/user-templates/* > /root/mrtg/admin/pages/FULLUSERTEMPLATE cat /root/mrtg/admin/pages/PREINDEX > /root/mrtg/admin/pages/index.php cat /root/mrtg/admin/pages/FULLUSERTEMPLATE >> /root/mrtg/admin/pages/index.php cat /root/mrtg/admin/pages/POSTINDEX >> /root/mrtg/admin/pages/index.php sed -e "s/INDEXTITLE/$INDEXTITLE/g" /root/mrtg/admin/pages/index.php > /root/mrtg/admin/admin/index.php sed -e "s/BANDWIDTHVARIABLE/$BANDWIDTHPRICE/g" /root/mrtg/admin/pages/INDEX2-TEMPLATE > /root/mrtg/admin/admin/index2.php # # copy over user logs to the admin directory # for i in `ls -1 /root/mrtg/mrtg-users/ |grep cfg | awk -F"." '{print $1}'`; do cp /home/$i/public_html/traffic/useraccounting.log /root/mrtg/admin/admin/$i.log; done # # copy the resulting html into here # cp -R /root/mrtg/admin/admin $HTMLPATH