summaryrefslogtreecommitdiffstats
path: root/genome-repo/genome-repo/genome-repo-bootstrap
blob: 4d904456cd95b4ec1891c83221b4323313956c60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
#
# genome-repo-bootstrap:         Starts genome-repo bootstrap process
#
# chkconfig: 35 99 95
#
# description:       Bootstrap an Genome Repository.  This can safely be run multiple times.
#

LOG=/var/log/genome-repo-bootstrap.log

# Source function library.
. /etc/init.d/functions

[ -z "$HOME" ] && export HOME=/

case "$1" in
    start)
        /usr/bin/puppet --logdest=syslog /etc/genome/bootstrap.pp

        # If this is a respin machine, try to automatically configure it
        if [ -e /etc/sysconfig/genome-quickstart ]; then
            # Create a working directory for the sync
            mkdir /tmp/sync >> $LOG
            pushd /tmp/sync >> $LOG
                # Sync from the public Genome repositories
                git clone git://git.fedorahosted.org/git/genome >> $LOG
                pushd genome >> $LOG
                    git submodule init >> $LOG
                    git submodule update >> $LOG
                popd >> $LOG
                
                chown -R genome:genome /tmp/sync/genome >> $LOG

                pushd genome >> $LOG
                    # Update the current machine with the public contents
                    su - genome -c "genome-sync save --workingdir='/tmp/sync/genome'" >> $LOG

                    # Prime cobbler with the default profile
                    cp tools/genome-respin/cobbler/Fedora-`uname -i`.profiles /var/lib/cobbler/profiles

                    # Prime cobbler with the default repos
                    cp tools/genome-respin/cobbler/Fedora-`uname -i`.repos /var/lib/cobbler/repos

                    # Bounce the puppetmaster.  Seems that the repo_extensions are not getting processed after genome-sync
                    service puppetmaster restart
                popd >> $LOG
            popd >> $LOG

            # Remove the file so this only runs once
            /bin/rm -f /etc/sysconfig/genome-quickstart
        fi

        RETVAL=$?

        if [ "$RETVAL" -eq 0 ]; then
            action "" /bin/true
        else
            action "" /bin/false
        fi

        exit 0
        ;;
    *)
        echo $"Usage: $0 {start}"
        RETVAL=1
esac

exit $RETVAL