use web imports to transfer files
[koha-eprints] / eprints-clone.sh
1 #!/bin/sh -xe
2
3 from=ffzg
4 to=bibliografija
5
6 ep=/usr/share/eprints3
7
8 bin="time sudo -u eprints $ep/bin"
9
10 dir=/tmp/eprints-clone
11 test -d $dir || mkdir $dir
12
13 # select just one export
14 if [ ! -e $dir/$from.archive.xml ] ; then
15         # wd don't want files embedded in XML
16         #$bin/export $from archive XMLFiles > $dir/$from.archive.xml
17         $bin/export $from archive XML      > $dir/$from.archive.xml
18 )
19 test -e $dir/$from.archive.xml || 
20
21 test -e $dir/$from.subject.xml || $bin/export $from subject XML      > $dir/$from.subject.xml
22 test -e $dir/$from.user.xml    || $bin/export $from user    XML      > $dir/$from.user.xml
23
24 if $bin/epadmin test $to ; then
25         echo "$to exists, skip import"
26 else
27         echo "$to import from $from started"
28         exit 1
29
30         $bin/epadmin create $to
31
32         cd /usr/share/eprints3/archives/$to/cfg
33         git init
34         git add *
35         git commit -m "new repository $to"
36
37         rsync -rv $ep/archives/$from/cfg/ $ep/archives/$to/cfg/
38
39         echo "restore core configuration of $to"
40         git diff cfg.d/adminemail.pl | patch -R -p1
41         git diff cfg.d/10_core.pl    | patch -R -p1
42         git diff lang/en/phrases/archive_name.xml | patch -R -p1
43
44         git diff cfg.d/database.pl | patch -R -p1
45
46         git commit -m "$from configuration changes" -a
47
48         echo "Modify databse for $from shema"
49         $bin/epadmin update $to
50
51         #$bin/epadmin              erase_data $to
52
53         echo "Importing data to $to"
54         $bin/import        $to user   XML $dir/$from.user.xml
55         $bin/import_subjects --xml        $to            $dir/$from.subject.xml
56         $bin/import --enable-web-imports  $to eprint XML $dir/$from.archive.xml
57
58         $bin/generate_static $to
59         $bin/generate_views $to
60         $bin/generate_abstracts $to
61 fi
62
63