snafu
[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 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 # Marc E. Fiuczynski <mef@cs.princeton.edu>
17 # Copyright (C) 2006-2007 The Trustees of Princeton University
18 #
19 # $Id:$
20 #
21
22 . build.functions
23
24 # These directories are allowed to grow to unspecified size, so they
25 # are stored as symlinks to the /data partition. mkfedora and yum
26 # expect some of them to be real directories, however.
27 datadirs=(
28 /etc/planetlab
29 /root
30 /var/lib/pgsql
31 /var/www/html/alpina-logs
32 /var/www/html/boot
33 /var/www/html/download
34 /var/www/html/files
35 /var/www/html/sites
36 /var/www/html/generated
37 /var/www/html/install-rpms
38 /var/www/html/xml
39 /tmp
40 /usr/tmp
41 /var/tmp
42 /var/log
43 )
44
45 pl_fixdirs root "${datadirs[@]}"
46
47 echo "* myplc: Installing base filesystem"
48 mkdir -p root data
49 make_chroot root plc_config.xml
50
51 # Install configuration scripts
52 echo "* myplc: Installing configuration scripts"
53 install -D -m 755 plc_config.py root/tmp/plc_config.py
54 chroot root sh -c 'cd /tmp; python plc_config.py build; python plc_config.py install'
55 install -D -m 755 plc-config root/usr/bin/plc-config
56 install -D -m 755 plc-config-tty root/usr/bin/plc-config-tty
57 install -D -m 755 db-config root/usr/bin/db-config
58 install -D -m 755 dns-config root/usr/bin/dns-config
59
60 # Install initscripts
61 echo "* myplc: Installing initscripts"
62 find plc.d | cpio -p -d -u root/etc/
63 install -D -m 755 guest.init root/etc/init.d/plc
64 chroot root sh -c 'chkconfig --add plc; chkconfig plc on'
65
66 # Install web scripts
67 echo "* myplc: Installing web scripts"
68 mkdir -p root/usr/bin
69 install -m 755 \
70     $srcdir/plc/scripts/gen-sites-xml.py \
71     $srcdir/plc/scripts/gen-slices-xml-05.py \
72     $srcdir/plc/scripts/gen-static-content.py \
73     root/usr/bin/
74
75 # Install web pages
76 echo "* myplc: Installing web pages"
77 mkdir -p root/var/www/html
78 rsync -a $srcdir/new_plc_www/ root/var/www/html/
79
80 # Install Drupal rewrite rules
81 install -D -m 644 $srcdir/new_plc_www/drupal.conf root/etc/httpd/conf.d/drupal.conf
82
83 # Install configuration file
84 echo "* myplc: Installing configuration file"
85 install -D -m 444 $config data/etc/planetlab/default_config.xml
86 install -D -m 444 plc_config.dtd data/etc/planetlab/plc_config.dtd
87
88 # handle root's homedir and tweak root prompt
89 echo "* myplc: root's homedir and prompt"
90 roothome=data/root
91 mkdir -p $roothome
92 cat << EOF > $roothome/.profile
93 export PS1="<plc> \$PS1"
94 EOF
95 chmod 644 $roothome/.profile
96
97 # Move "data" directories out of the installation
98 echo "* myplc: Moving data directories out of the installation"
99 pl_move_dirs root data /data "${datadirs[@]}"
100
101 # Fix permissions on tmp directories
102 pl_fixtmp_permissions data
103
104 # Remove generated bootmanager script
105 rm -f data/var/www/html/boot/bootmanager.sh
106
107 # Initialize node RPMs directory. The PlanetLab-Bootstrap.tar.bz2
108 # tarball already contains all of the node RPMs pre-installed. Only
109 # updates or optional packages should be placed in this directory.
110 install -D -m 644 $pl_YUMGROUPSXML \
111     data/var/www/html/install-rpms/planetlab/yumgroups.xml
112
113 # Make image out of directory
114 echo "* myplc: Building loopback image"
115 pl_make_image root root.img 100000000
116
117 exit 0