Skip to content

Commit 4ef5f80

Browse files
committed
initiall add
1 parent 9a571ac commit 4ef5f80

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

restore-replicas

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
# This is intended to be called from puppet on both the master and the
3+
# primary machine. Its purpose is to restore repository configurations
4+
# when a backup machine is installed from scratch.
5+
# IMPORTANT NOTE: this will restore all the repositories from the primary
6+
# machine, but if any repositories were added by hand (that is, outside
7+
# of manage-replicas), then the source URL will be left pointing to the
8+
# primary machine rather than the real stratum 0 it is supposed to come
9+
# from. Those would need to be separately restored with add-repository -H
10+
# before calling this function.
11+
12+
VARLIB=/var/lib/cvmfs-hastratum1
13+
SHARE=/usr/share/cvmfs-hastratum1
14+
15+
DONEFILE=$VARLIB/restoration-date
16+
if [ -f $DONEFILE ]; then
17+
exit
18+
fi
19+
20+
if cvmfsha-is-master; then
21+
exit
22+
fi
23+
24+
. /etc/cvmfs/hastratum1.conf
25+
26+
THISHOST="`uname -n`"
27+
case $THISHOST in
28+
$HOST1) OTHERHOST=$HOST2;;
29+
$HOST2) OTHERHOST=$HOST1;;
30+
*) echo "Not running on $HOST1 or $HOST2" >&2; exit 1;;
31+
esac
32+
33+
sed "s/@otherhost@/$OTHERHOST/" $SHARE/restore-replicas.conf.in >$VARLIB/restore-replicas.conf
34+
if ! $SHARE/manage-replicas -f $VARLIB/restore-replicas.conf; then
35+
echo "Restoration of replicas failed" >&2
36+
exit 1
37+
fi
38+
rm $VARLIB/restore-replicas.conf
39+
40+
# fix the incorrect source URLs
41+
(
42+
echo "addcmd true"
43+
echo "remcmd true"
44+
cat /etc/cvmfs/manage-replicas.conf
45+
) > $VARLIB/manage-replicas.conf
46+
if ! $SHARE/manage-replicas -f $VARLIB/manage-replicas.conf; then
47+
echo "Restoration of replica source URLs failed" >&2
48+
exit 1
49+
fi
50+
rm $VARLIB/manage-replicas.conf
51+
52+
date >$DONEFILE

restore-replicas.conf.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# this file is used by restore-replicas, not intended to be hand-edited
2+
#
3+
addcmd add-repository -H @fqrn@ @url@ @fqrn@/stage
4+
remcmd remove-repository -f -h @fqrn@
5+
replist http://@otherhost@:8000/cvmfs/info/v1/repositories.json
6+
source http://@otherhost@:8000
7+
repos *

0 commit comments

Comments
 (0)