- remove api-config script
[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.38 2007/01/20 04:06:02 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/generated
35 /var/www/html/install-rpms
36 /var/www/html/xml
37 /tmp
38 /usr/tmp
39 /var/tmp
40 /var/log
41 )
42 for datadir in "${datadirs[@]}" ; do
43     # If we are being re-run, it may be a symlink
44     if [ -h root/$datadir ] ; then
45         rm -f root/$datadir
46         mkdir -p root/$datadir
47     fi
48 done
49
50 echo "* myplc: Installing base filesystem"
51 mkdir -p root data
52 make_chroot root plc_config.xml
53
54 # Install configuration scripts
55 echo "* myplc: Installing configuration scripts"
56 install -D -m 755 plc_config.py root/tmp/plc_config.py
57 chroot root sh -c 'cd /tmp; python plc_config.py build; python plc_config.py install'
58 install -D -m 755 plc-config root/usr/bin/plc-config
59 install -D -m 755 plc-config-tty root/usr/bin/plc-config-tty
60 install -D -m 755 db-config root/usr/bin/db-config
61 install -D -m 755 dns-config root/usr/bin/dns-config
62
63 # Install initscripts
64 echo "* myplc: Installing initscripts"
65 find plc.d | cpio -p -d -u root/etc/
66 install -D -m 755 guest.init root/etc/init.d/plc
67 chroot root sh -c 'chkconfig --add plc; chkconfig plc on'
68
69 # Install web scripts
70 echo "* myplc: Installing web scripts"
71 mkdir -p root/usr/bin
72 install -m 755 \
73     $srcdir/plc/scripts/gen-sites-xml.py \
74     $srcdir/plc/scripts/gen-slices-xml-05.py \
75     $srcdir/plc/scripts/gen-static-content.py \
76     root/usr/bin/
77
78 # Install web pages
79 echo "* myplc: Installing web pages"
80 mkdir -p root/var/www/html
81 rsync -a $srcdir/new_plc_www/ root/var/www/html/
82
83 # Install Drupal rewrite rules
84 install -D -m 644 $srcdir/new_plc_www/drupal.conf root/etc/httpd/conf.d/drupal.conf
85
86 # Install configuration file
87 echo "* myplc: Installing configuration file"
88 install -D -m 444 $config data/etc/planetlab/default_config.xml
89 install -D -m 444 plc_config.dtd data/etc/planetlab/plc_config.dtd
90
91 # handle root's homedir and tweak root prompt
92 echo "* myplc: root's homedir and prompt"
93 roothome=data/root
94 mkdir -p $roothome
95 cat << EOF > $roothome/.profile
96 export PS1="<plc> \$PS1"
97 EOF
98 chmod 644 $roothome/.profile
99
100 # Move "data" directories out of the installation
101 echo "* myplc: Moving data directories out of the installation"
102 move_datadirs root data "${datadirs[@]}"
103
104 # Fix permissions on tmp directories
105 chmod 1777 data/tmp data/usr/tmp data/var/tmp
106
107 # Remove generated bootmanager script
108 rm -f data/var/www/html/boot/bootmanager.sh
109
110 # Initialize node RPMs directory. The PlanetLab-Bootstrap.tar.bz2
111 # tarball already contains all of the node RPMs pre-installed. Only
112 # updates or optional packages should be placed in this directory.
113 install -D -m 644 ../build/groups/v3_yumgroups.xml \
114     data/var/www/html/install-rpms/planetlab/yumgroups.xml
115
116 # Make image out of directory
117 echo "* myplc: Building loopback image"
118 make_image root root.img
119
120 exit 0