#!/bin/sh VERSION=1.0.0 # Must know the target mirror disk, and must pass to # sub scripts for mounting proper device. # Default is hdc. MIRROR_DISK=$1 if [ -z "$MIRROR_DISK" ] then echo -e "No mirror disk entered. Assuming sync_all hdc." MIRROR_DISK="hdc" fi if [ -z "$2" ] then GOLD_IMAGE=N else GOLD_IMAGE=$2 fi # This is set to let sub programs know it was launched by all! # The feature allows to have appropriate status for sync_all and # indvidual syncs Flag="ALL" # Establish the environment (PATH for Commands execution & BP Parameters) PATH="$PATH:/usr/local/bin:/sbin:/usr/sbin:/usr/X11R6/bin:/usr/local/sbin:" export PATH . /etc/default/bp.ini 2>/dev/null echo "sync_all process initiated with the call - $0 $*" echo "Please wait..." # Redirect stdout and stderr to the sync_all.log exec > $BPDIR/logs.dir/sync_all.log 2>&1 date # mbe # Add call to LCD to display Sync'in message # /usr/local/bin/lcdman "Sync'ing Drives." "Do not remove." echo $$ > $BPDIR/Disk_Sync_In_Progress SYNCSTATUS=$BPDIR/reports.dir/syncstatus echo -e "Synchronizing started at \c" > $SYNCSTATUS date >> $SYNCSTATUS make_label_table > /usr/local/etc/disk_label_info spec mount /mirror [ -d /mirror/boot ] || mkdir -p /mirror/boot [ -d /mirror/usr ] || mkdir -p /mirror/usr [ -d /mirror/var ] || mkdir -p /mirror/var [ -d /mirror/backups ] || mkdir -p /mirror/backups umount /mirror mount /mirror/usr && mkdir -p /mirror/usr/bp umount /mirror/usr # Start the steps for root synchronization . /usr/local/bin/sync_root $MIRROR_DISK # Start the steps for root synchronization . /usr/local/bin/sync_boot $MIRROR_DISK # Start the steps for /usr synchronization . /usr/local/bin/sync_usr $MIRROR_DISK # Start the steps for /usr/bp synchronization . /usr/local/bin/sync_usr-bp $MIRROR_DISK # Start the steps for /var synchronization . /usr/local/bin/sync_var $MIRROR_DISK # Start the steps for /backups synchronization if hotswap... # If this is only a RAID 5 unit, no sync for backups folders. echo -e "Check to see if sync for /backups required." vgs 2> /dev/null | grep vgmirror > /dev/null 2>&1 if [ $? -eq 0 ] then echo -e "Sync for /backups required. Hot Swap unit." . /usr/local/bin/sync_backups $MIRROR_DISK else echo -e "Sync for /backups not required. RAID 5 unit." fi $BPDIR/bin/bputil -j clear echo -e "Synchronizing completed at \c" >> $SYNCSTATUS date >> $SYNCSTATUS rm -f $BPDIR/Disk_Sync_In_Progress # mbe # For regular sync, modify "other" drive for booting if [ "$GOLD_IMAGE" = "N" ] then echo -e "Inside GOLD_IMAGE check." case "$MIRROR_DISK" in "hdc") PRIMARY_DISK="hda" ;; "hda") PRIMARY_DISK="hdc" ;; "sdb") PRIMARY_DISK="sda" ;; "sda") PRIMARY_DISK="sdb" ;; esac echo -e "PRIMARY_DISK is $PRIMARY_DISK" echo -e "MIRROR_DISK is $MIRROR_DISK" mount /mirror mount /mirror/boot mount /mirror/var cat /mirror/boot/grub/grub.conf | eval sed 's/${PRIMARY_DISK}/${MIRROR_DISK}/g' > /mirror/boot/grub/grub.conf.tmp mv /mirror/boot/grub/grub.conf.tmp /mirror/boot/grub/grub.conf cat /mirror/etc/fstab | eval sed 's/${MIRROR_DISK}/hdx/g' > /mirror/etc/fstab.tmp cat /mirror/etc/fstab.tmp | eval sed 's/${PRIMARY_DISK}/${MIRROR_DISK}/g' > /mirror/etc/fstab.tmp1 cat /mirror/etc/fstab.tmp1 | eval sed 's/hdx/${PRIMARY_DISK}/g' > /mirror/etc/fstab cat /mirror/var/spool/cron/root | eval sed 's/sync_all" "${MIRROR_DISK}/sync_all" "${PRIMARY_DISK}/g' > /mirror/var/spool/cron/root.tmp mv /mirror/var/spool/cron/root.tmp /mirror/var/spool/cron/root rm -f /mirror/etc/fstab.tmp rm -f /mirror/etc/fstab.tmp1 umount /mirror/boot umount /mirror/var umount /mirror fi unspec # mbe # Add call to LCD to display Sync complete message # mbe # Leave this message displayed for 1 minuite, then # mbe # restore the default display. # /usr/local/bin/lcdman "Sync complete." "Ready" sleep 10 BP_VERSION=`cat $BPDIR/bp_VERS | awk ' { if ( $1 == "Version" ) print $2 } '` /usr/local/bin/lcdman "Unitrends DPU" "Version $BP_VERSION"