Change v3 to v4 yumgroups.xml
[myplc.git] / build.sh
1 #!/bin/bash
2 #
3 # Builds MyPLC, either inside the MyPLC development environment in
4 # devel/root (if PLC_DEVEL_BOOTSTRAP is true), or in the current host
5 # environment (may be itself a MyPLC development environment or a
6 # Fedora Core 4 environment with the appropriate development packages
7 # installed).
8 #
9 # root.img (loopback image)
10 # root/ (mount point)
11 # data/ (various data files)
12 # data/etc/planetlab/ (configuration files)
13 # data/root (root's homedir)
14 #
15 # Mark Huang <mlhuang@cs.princeton.edu>
16 # Copyright (C) 2006 The Trustees of Princeton University
17 #
18 # $Id: build.sh,v 1.40 2007/01/30 16:03:20 mlhuang Exp $
19 #
20
21 . build.functions
22
23 # These directories are allowed to grow to unspecified size, so they
24 # are stored as symlinks to the /data partition. mkfedora and yum
25 # expect some of them to be real directories, however.
26 datadirs=(
27 /etc/planetlab
28 /root
29 /var/lib/pgsql
30 /var/www/html/alpina-logs
31 /var/www/html/boot
32 /var/www/html/download
33 /var/www/html/files
34 /var/www/html/sites
35 /var/www/html/generated
36 /var/www/html/install-rpms
37 /var/www/html/xml
38 /tmp
39 /usr/tmp
40 /var/tmp
41 /var/log
42 )
43 for datadir in "${datadirs[@]}" ; do
44     # If we are being re-run, it may be a symlink
45     if [ -h root/$datadir ] ; then
46         rm -f root/$datadir
47         mkdir -p root/$datadir
48     fi
49 done
50
51 echo "* myplc: Installing base filesystem"
52 mkdir -p root data
53 make_chroot root plc_config.xml
54
55 # Install configuration scripts
56 echo "* myplc: Installing configuration scripts"
57 install -D -m 755 plc_config.py root/tmp/plc_config.py
58 chroot root sh -c 'cd /tmp; python plc_config.py build; python plc_config.py install'
59 install -D -m 755 plc-config root/usr/bin/plc-config
60 install -D -m 755 plc-config-tty root/usr/bin/plc-config-tty
61 install -D -m 755 db-config root/usr/bin/db-config
62 install -D -m 755 dns-config root/usr/bin/dns-config
63
64 # Install initscripts
65 echo "* myplc: Installing initscripts"
66 find plc.d | cpio -p -d -u root/etc/
67 install -D -m 755 guest.init root/etc/init.d/plc
68 chroot root sh -c 'chkconfig --add plc; chkconfig plc on'
69
70 # Install web scripts
71 echo "* myplc: Installing web scripts"
72 mkdir -p root/usr/bin
73 install -m 755 \
74     $srcdir/plc/scripts/gen-sites-xml.py \
75     $srcdir/plc/scripts/gen-slices-xml-05.py \
76     $srcdir/plc/scripts/gen-static-content.py \
77     root/usr/bin/
78
79 # Install web pages
80 echo "* myplc: Installing web pages"
81 mkdir -p root/var/www/html
82 rsync -a $srcdir/new_plc_www/ root/var/www/html/
83
84 # Install Drupal rewrite rules
85 install -D -m 644 $srcdir/new_plc_www/drupal.conf root/etc/httpd/conf.d/drupal.conf
86
87 # Install configuration file
88 echo "* myplc: Installing configuration file"
89 install -D -m 444 $config data/etc/planetlab/default_config.xml
90 install -D -m 444 plc_config.dtd data/etc/planetlab/plc_config.dtd
91
92 # handle root's homedir and tweak root prompt
93 echo "* myplc: root's homedir and prompt"
94 roothome=data/root
95 mkdir -p $roothome
96 cat << EOF > $roothome/.profile
97 export PS1="<plc> \$PS1"
98 EOF
99 chmod 644 $roothome/.profile
100
101 # Move "data" directories out of the installation
102 echo "* myplc: Moving data directories out of the installation"
103 move_datadirs root data "${datadirs[@]}"
104
105 # Fix permissions on tmp directories
106 chmod 1777 data/tmp data/usr/tmp data/var/tmp
107
108 # Remove generated bootmanager script
109 rm -f data/var/www/html/boot/bootmanager.sh
110
111 # Initialize node RPMs directory. The PlanetLab-Bootstrap.tar.bz2
112 # tarball already contains all of the node RPMs pre-installed. Only
113 # updates or optional packages should be placed in this directory.
114 install -D -m 644 ../build/groups/v4_yumgroups.xml \
115     data/var/www/html/install-rpms/planetlab/yumgroups.xml
116
117 # Make image out of directory
118 echo "* myplc: Building loopback image"
119 make_image root root.img
120
121 exit 0