Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Method to have root start a script when logging on

Status
Not open for further replies.

bswip

Programmer
Oct 16, 2002
111
US
I am writng a menu script for our D/R and would like to have my script start after a reboot. On of my menu options is to perform either a sys_unconfig or a boot -- -r after all the Solaris patches have been installed (the unconfig would be used if the system needed it otherwise a reboot is all we need). So after the restart, I would like to restart my script once root logs in. I am unsure where to place the command. If I place it in .profile, then any terminalsession will start the script. So I only want it started once.

Thanks

BTW: If anyone is interested in this DR menuing script I will share it with them. It also will recover NetBackup.

 
Easiest way would be to create a flag in the root directory (much like the /reconfigure file used to reconfig devices). A custom startup script then checks for the flag - if found deletes it so it won't run again and carries on to call your scripts.

P.S. Netbackup and Legato seem a pain to DR with - we used to make a ufsdump of the essential root partitions following any Legato or Netbackup dumps each night and use this to recover a fully functional OS whilst booted from the install CD.

regards
 
Sorry forgot to mention - the custom script should be put in /etc/rc2.d.
 
julianbarnett, how do you automate a nightly ufsdump? Does the system need to be in single user, can a script do all this.

Sorry for the question but I'm new to this Solaris and still learning.

Thanks for your time.
Dave
dgazzane@primal.com
 
To be honest I have never shut a system down to single user to do a ufsdump of root or any other partition and have never had a problem. If your dumps are done in the early hours and assuming your'e not running a global 24 x 7 app or overnight batch, everything should be pretty quiescent. Raw databases shoud be dumped (and compressed) to disk files prior to your ufsdump kicking in anyway.

Dump logic something like - add your own logging / error checks..

#!/usr/bin/ksh
LOGFILE=/your/logdir/ufsdump.`date`
# Rewind tape
mt -f /dev/rmt/0 rewind >$LOGFILE 2>&1
# change 0 above to your tape device number
# Get list of mounted ufs filesystems
for FS in `df -k -Fufs | grep -v Filesystem | awk '{ print $6}'`
do
echo "Dumping $FS" >>$LOGFILE 2>&1
ufsdump -0uf /dev/rmt/0n $FS >>$LOGFILE 2>&1
# 0n important 'no-rewind' appends dumps to tape
# without 'n' each dump overwrites the previous!
done
# Rewind and offline tape
mt -f /dev/rmt/0 rewoffl

JB




 
You could just put an entry in the /etc/initab for your script to run once during boot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top