How to create mirror?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to create mirror?
# 1  
Old 05-23-2014
How to create mirror?

hello
how can i add mirror link in for command to check if mirror 1 was break, check mirror2 ?

Code:
MIRROR=http://domain1.com/file.tar.gz
MIRROR2=http://domain2.com/file.tar.gz

Code:
if [ $answer = 1 ]; then
    wget $MIRROR
    echo "$BACK2MENU" ; read
fi

# 2  
Old 05-23-2014
Capture return code after you try and get from mirror1.
Code:
if [ $answer == 1 ]; then
    wget $MIRROR
RC="$?"
if [[ "$RC" -ne 0 ]]; then
wget $MIRROR2
fi
    echo "$BACK2MENU" ; read
fi

# 3  
Old 05-23-2014
Why not simply re-run wget with mirror2 url, but only if mirror(1) fails.
Saves you another 'if' block.
Code:
if [ $answer = 1 ]; then
    wget $MIRROR || wget $MIRROR2
    echo "$BACK2MENU" ; read
fi

hth
# 4  
Old 05-23-2014
Quote:
Originally Posted by SriniShoo
Capture return code after you try and get from mirror1.
Code:
if [ $answer == 1 ]; then
    wget $MIRROR
RC="$?"
if [[ "$RC" -ne 0 ]]; then
wget $MIRROR2
fi
    echo "$BACK2MENU" ; read
fi

what RC="$?" exactly do?
and will the data of RC drop ?
example:
i have 10 miror checker in the scriot,
i have to define RC for all of them or change it to RC3 RC4 ?
i want to know the dead time of this variable only
Quote:
Originally Posted by sea
Why not simply re-run wget with mirror2 url, but only if mirror(1) fails.
Saves you another 'if' block.
Code:
if [ $answer = 1 ]; then
    wget $MIRROR || wget $MIRROR2
    echo "$BACK2MENU" ; read
fi

hth
there are several reason when an error occurred during wget:
sometimes timeout error happened
sometimes file doesnt exist,
sometimes file exist But the server does not have permission to download

in these cases, is this methid work fine? coz all of these situation has their own error number,
# 5  
Old 05-23-2014
RC=$? sets the variable RC, which is a synonym for Return Code, to exactly this, others use 'RET', 'ret', 'return_code' or something alike.
$? contains the return code of the previously executed command.

SriniShoo:
  1. run wget
  2. set RC to $?
  3. Compare RC with 0 (success)
  4. If anything else but 0, call wget for mirror2

sea:
  1. run wget
  2. return code is anything but 0, call wget for mirror2

So, yes, either solution will jump in upon any fail.

Of course, you could to handle the error code, in the like of (i didnt check return codes for wget):
Code:
if [ $answer == 1 ]; then
	wget $MIRROR
	RC="$?"
	case "$RC" in
	0)	echo "All done well"	;;
	1)	echo "Regular fail"
		wget $MIRROR2		;;
	*)	echo "Error: $RC"	;;
	esac
fi

hth

Last edited by sea; 05-23-2014 at 03:03 PM.. Reason: added code
This User Gave Thanks to sea For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. HP-UX

What is the difference between DRD and Root Mirror Disk using LVM mirror ?

what is the difference between DRD and Root Mirror Disk using LVM mirror ? (3 Replies)
Discussion started by: maxim42
3 Replies

2. Solaris

Second Mirror is not booting !

zpool status -v below my mirrors in Solaris 10 config: NAME STATE READ WRITE CKSUM rpool ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c3t0d0s0 ONLINE 0 0 0 ... (2 Replies)
Discussion started by: top.level
2 Replies

3. Solaris

How to reattach a mirror?

OK, I upgraded to the latest version of Solaris 10. Perhaps 'upgrade' isn't the right term because I reinstalled the root/boot drive with Solaris 10. Prior to this I had 4 physical drives. The first two had "/" and "/usr", the other two had a /var/audit and /home. I initially booted from cdrom and... (7 Replies)
Discussion started by: brownwrap
7 Replies

4. Solaris

Create a boot disk mirror on Solaris 10 x86

I’m setting up a boot disk mirror on Solaris 10 x86. I’m used to doing it on SPARC, where you can copy the partition table using fmthard. My x86 boot disk has 2 primary partitions, a Solaris one and a diagnostic one. Is there a way to copy those 2 primary partitions to the second disk without... (6 Replies)
Discussion started by: TKD
6 Replies

5. Solaris

How to create mirror disk in solaris machine?

hi, I'm newbie in Solaris 10. can someone explain me the steps of how to create mirror disk in Solaris machine. thanks in advance (5 Replies)
Discussion started by: Wong_Cilacap
5 Replies

6. Solaris

What is mirror and sub mirror in RAID -1 SVM

Hi , I am new to SVM .when i try to learn RAID 1 , first they are creating two RAID 0 strips through metainit d51 1 1 c0t0d0s2 metainit d52 1 1 c1t0d0s2 In the next step metainit d50 -m d51 d50: Mirror is setup next step is metaattach d50 d52 d50 : submirror d52 is... (7 Replies)
Discussion started by: vr_mari
7 Replies

7. Solaris

ZFS Mirror versus Hardware Mirror

I've looked a little but haven't found a solid answer, assuming there is one. What's better, hardware mirroring or ZFS mirroring? Common practice for us was to use the raid controllers on the Sun x86 servers. Now we've been using ZFS mirroring since U6. Any performance difference? Any other... (3 Replies)
Discussion started by: Lespaul20
3 Replies

8. Solaris

Create a logical volume from a mirror and single disk?

I have two 72GB disks that are mirrored and mounted (/backup). I have a 18GB drive in an array I just attached to the server, which is running Solaris 9. I need to create a new logical volume partition and make the existing mirror device (/dev/md/dsk/d34) and the array's 18GB drive a member of... (3 Replies)
Discussion started by: dotcom75
3 Replies

9. UNIX for Dummies Questions & Answers

create raidctl mirror with mounted source parition

I am mirroring a single partition drive with raidctl. The source partition was mounted when I created the mirror with raidctl -c c1t1d0 c1t3d0. The source disk was defined with s2 and s6 only. I didn't think to umount it first. Is there a problem with that? (2 Replies)
Discussion started by: csgonan
2 Replies
Login or Register to Ask a Question