#!/bin/bash
export DATE="`date +%y%m%d.%H%M`"

mkdir -p /root/racadm
cd /root/racadm

(
  racadm setrac -t
  racadm setrac -h
  racadm setrac -o
  racadm setrac -T
  racadm setrac -d
) >>racadm.setrac.${DATE}

# gives segmentation fault here (I use omconfig instead):
#(
#  echo "racadm config -g cfgUserAdmin -o cfgUserAdminPassword -i 1 xxx"
#  racadm config -g cfgUserAdmin -o cfgUserAdminPassword -i 1 xxx
#) >>racadm.config.passwd.${DATE} 2>&1

#
# this email test will work only if you change 192.168.98.254 and
# user@host.domain to your values
#
racadm config -g cfgRemoteHosts -o cfgRhostsSmtpServerIpAddr 192.168.98.254
racadm config -g cfgUserAdmin -o cfgUserAdminEmailEnable -i 1 1
racadm config -g cfgUserAdmin -o cfgUserAdminEmailCustomMsg -i 1 "RAC-`hostname`"
racadm config -g cfgUserAdmin -o cfgUserAdminEmailAddress -i 1 user@host.domain
racadm racreset
sleep 60
racadm config -g cfgUserAdmin -o cfgUserAdminEmailEnable -i 1 1
racadm testemail -i 1

# the full "racadm getconfig" is segfaulting, but this is working:
(
  racadm getconfig -g idRacInfo
  racadm getconfig -g mngRacControl
  racadm getconfig -g cfgMonitor
  racadm getconfig -g cfgLanNetworking
  racadm getconfig -g cfgCurrentLanNetworking
  racadm getconfig -g cfgDialupNetworking
  racadm getconfig -g cfgRemoteHosts
  for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
  do
    racadm getconfig -g cfgUserAdmin -i $i
  done
  for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
  do
    racadm getconfig -g cfgTraps -i $i
  done
  for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
  do
    racadm getconfig -g cfgDemandDial -i $i
  done
  for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
  do
    racadm getconfig -g cfgDialinUsers -i $i
  done
  racadm getconfig -g cfgSessionManagement
  racadm getconfig -g cfgSerial
  racadm getconfig -g cfgNetTuning
  racadm getconfig -g cfgOobSnmp
  racadm getconfig -g cfgRacTuning
  racadm getconfig -g ifcRacManagedNodeOs
  racadm getconfig -g cfgRacSecurity
  racadm getconfig -g cfgRacVirtual
) >>racadm.getconfig.all.${DATE}

#
# this is segfaulting, but before it gives a little bit:
racadm racdump >>racadm.racdump.${DATE}

#
# working, but "No RAC sensors supported"...
racadm getsensors >>racadm.getsensors.${DATE}

#
(racadm getsysinfo; racadm getsysinfo -A) >>racadm.getsysinfo.${DATE}

