#!/usr/bin/bash
#Title: Behind Big Sister 
#Subject: Install notes file layout for Big Sister
#
# The "Status Collector" (bbd & bsmon) creates Web pages showing "Agents"
# The "Agent" (uxmon) reports to the "Status Collector"
# 
#
#  $BIG_SISTER_HOME/
#  |
#  |- bin/	The binaries
#  |
#  |- adm/	Configuration files local to the machine
#  |    |
#  |    |-bb-display.cfg		Tells bbdisp.pm what Web pages it should create and which
#  |	|				tables they should contain.
#  |	|
#  |	|-hosts.allow			OBSOLETE (but still active)
#  |	|
#  |	|-permissions			tell bbd which agents are allowed to connect and
#  |	|
#  |    |-grouping			Grouping information for dynamic join/leave of
#  |	|				host groups (when using the generic uxmon-rules.pl)
#  |	|
#  |	|-uxmon-net			The agent configuration file 
#  |	|				Do not forget to at least edit this file after a new installation			
#  |	|
#  |	|-bb_event_generator.cfg	The configuration file for the alarm generator
#  |	|
#  |	|-notify.cfg			If you use bb_event_generator with notify this is
#  |	|
#  |	|-graphtemplates  		The definitions in this file are used as a template
#  |	|				for creating performance data history databases				
#  |	|
#  |	|-bsmon_site.cfg		Configures the various Big Sister server modules
#  |
#  |- uxmon/	The client software of Big Sister (Unix Monitor)
#  |
#  |- etc/	Various configuration files (not very populated yet)
#  |    |
#  |    |-syslog		If you are checking system log files ("syslog" check)	
#  |    |
#  |    |-mibs.txt		If you are using snmp monitor this file is used for
#  |    |			mapping text to oids
#  |    |
#  |    |-OV			configuration file for HP Openview uxmon Monitor 
#  |    |			(only if you are using the "OV" check)
#  |	|
#  |	|-graphtemplates  	The definitions in this file are used as a template
#  |	|			for creating performance data history databases		
#  |	|
#  |	|-bsmon.cfg		Configures the various Big Sister server modules	
#  |
#  |- www/	Big Sister generated HTML files 
#  |
#  |- www/logs 	Client status files
#  |
#  |- www/logs/	History
#  |
#  |- var/	The location where Big Sister stores any 
# 		  file (except for the WWW files) it writes to
#
#
# Currently implemented monitors:
#
#   - oracle: 		Oracle database check
#   - tripwire: 	Tripwire system consistency check
#   - bbscript: 	for re-using Big Brother monitoring scripts
#   - statusfile: 	as a simple interface to simple monitors
#   - cpuload: 		CPU load as reported by uptime
#   - eventlog: 	monitoring NT EventLog
#   - logfile: 		generic log file monitor
#   - procs: 		checking running processes
#   - ping: 		checking reachability of a host
#   - fs: 		checking file system usage
#   - rpc_ping: 	checking RPC responses
#   - tcp: 		generic TCP monitor
#   - sar: 		checks sar output against limits
#   - snmp: 		does snmp polling
#   - dumpdates: 	check for last dump/ufsdump backup
#   - syslog: 		check system log files
#   - OV: 		HP Openview trap monitor
#   - metastat: 	check Solstice DiskSuite RAID-Systems
#   - dns: 		check DNS servers
#   - radius: 		Radius
#   - http/realhttp: 	Web Server

############################################################
#
# Install
#
############################################################

#
#  Perl snmp module
#
perl -MCPAN -e'install "Bundle::CPAN"'

# To use graphical status displays (%image statement)
# need Tobias Oetiker's RRDTool available from
perl -MCPAN -e'install "GD"'


 SNMP_Session.pm
perl -MCPAN -e'install "Config::General"'
   no
perl -MCPAN -e'install "SNMP"'
   Where is the ucd-snmp library installed? [/usr/lib]/usr/lib


Unable to locate the MIBs, Please enter the path:  [/usr/local/sbin]  
	/usr/share/mibs 
	/usr/share/mibs/ietf/
	/usr/bin
	


#
#  Create group
#
echo "Creating the group for big sister:  bigsister"
if ( /usr/sbin/groupadd -g 498 bigsister )
then
  echo "group=bigsister not used, gid=498 not used"
  echo "creating group big sister on 498"
  /usr/sbin/groupadd -g 498 bigsister
else
   echo "either bigsister exits or 498 is used"
exit
fi

#
#  Create user
#
echo "create the big sister user:  bigsister"
useradd -u 498 \
	-g bigsister \
	-d /home/bigsister \
	-c "Big Sister" \
	-s /bin/bash \
	bigsister -m

#
#  DON'T make directories, install will do 
#
# ! mkdir /usr/local/httpd/cgi-bin/bs
# ! mkdir /usr/local/httpd/htdocs/bs
ln -s /home/bigsister/bs/www /usr/local/httpd/htdocs/bs
ln -s /home/bigsister/bs/bin /usr/local/httpd/cgi-bin/bs


#
#  put package in place
#
cp big-sister-0.97.tar.gz /home/bigsister/
cd ~bigsister/
tar -zxvpf big-sister-0.97.tar.gz
cd bs-0.97/

chown -R bigsister:bigsister /home/bigsister

############################################################ 
#
#  Configuration
#
############################################################

cat >> /home/bigsister/bs/adm/uxmon-net << THIS
  johns2          load diskload memory \
                fs=all(6%-10%),all-ufs(6%-10%),all-ext2(6%-10%) diskfree \
                syslog dumpdates \
                procs=init(1-1),sendmail(1-20) procs eventlog cpuload \
                network

  johns2          bsdisplay
  johns2          frequency=10 perfdata=etc/perf options=perf bsdisplay
  johns2          frequency=30 perfdata=etc/perfslow options=perf bsdisplay
THIS

cat >> /home/bigsister/bs/adm/resources  << THIS
 *.path=/sbin:/usr/sbin:/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/local/sbin
 *.skin=white_bg
 *.log_facility: daemon
 bbd.log_facility: daemon
THIS

 mv adm/bb-display.cfg adm/orig.bb-display.cfg
 mv etc/bsmon.cfg /etc/orig.bsmon.cfg

bin/bb_start start

############################################################
# this are the install options:
#
#  USER=	user name on the system
#  PERL=	location of perl
#  DEST=	diretory location to installe package
#  CGIPATH=	absolute path to big sister's cgis
#  WEBROOT=	From root of web site, path to big sister
#
############################################################
make install \
	USER=bigsister \
	DEST=/home/bigsister/bs \
	CGIPATH=/cgi-bin/bs \
	WEBROOT=/bs \
#	PERL=/usr/bin \

vi adm/resources
  *.path=/home/bingsister/bs/bin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
  uxmon.path=/home/bingsister/bs/bin:/usr/sbin:/bin:/usr/bin:/usr/local/bin  

su - bigsister -c "cd /home/bigsister/bs;./bin/bb_start start Big Sister"
su - bigsister -c "cd /home/bigsister/bs;./bin/bb_start stop Big Sister"
su - bigsister -c "cd /home/bigsister/bs;./bin/bb_start restart Big Sister"

cp  bs.first/adm/resources bs/adm/
cp bs.first/adm/uxmon-net bs/adm/uxmon-net
cp bs.first/adm/bb-display.cfg bs/adm/bb-display.cfg


# this fix was allowing symbolic links out of cgi-bin