use the FQDN for PLC_WWW_HOST rather than localhost to get cron.php
[myplc.git] / build.sh
1 #!/bin/bash
2 #
3 # Builds MyPLC in the current host environment
4 # This is for the so-called chroot installation mode, meaning that
5 # the resulting rpm will install a full chroot image in /plc/root
6 # that can be run through chroot /plc/root
7 # This chroot mode is to be opposed to the native mode (see build-native.sh)
8 # that can be used in the host's root context or within a vserver
9 #
10 # root.img (loopback image)
11 # root/ (mount point)
12 # data/ (various data files)
13 # data/etc/planetlab/ (configuration files)
14 # data/root (root's homedir)
15 #
16 # Mark Huang <mlhuang@cs.princeton.edu>
17 # Copyright (C) 2006 The Trustees of Princeton University
18 #
19 # $Id$
20 #
21
22 . build.functions
23
24 # pldistro expected as $1 - defaults to planetlab
25 pldistro=$1 ; shift
26
27 # These directories are allowed to grow to unspecified size, so they
28 # are stored as symlinks to the /data partition. mkfedora and yum
29 # expect some of them to be real directories, however.
30 datadirs=(
31 /etc/planetlab
32 /root
33 /var/lib/pgsql
34 /var/www/html/alpina-logs
35 /var/www/html/boot
36 /var/www/html/download
37 /var/www/html/download-planetlab-i386
38 /var/www/html/files
39 /var/www/html/sites
40 /var/www/html/generated
41 /var/www/html/install-rpms
42 /var/www/html/xml
43 /tmp
44 /usr/tmp
45 /var/tmp
46 /var/log
47 )
48
49 pl_fixdirs root "${datadirs[@]}"
50
51 echo "* myplc: Installing base filesystem"
52 mkdir -p root data
53
54 pl_root_makedevs root
55 pkgsfile=$(pl_locateDistroFile ../build/ ${pldistro} myplc.pkgs)
56 pl_root_mkfedora root $pldistro $pkgsfile
57 pl_root_tune_image root
58
59 # Install configuration scripts
60 echo "* myplc: Installing configuration scripts"
61 install -D -m 755 plc_config.py root/tmp/plc_config.py
62 chroot root sh -c 'cd /tmp; python plc_config.py build; python plc_config.py install'
63 install -D -m 755 plc-config root/usr/bin/plc-config
64 install -D -m 755 plc-config-tty root/usr/bin/plc-config-tty
65 install -D -m 755 db-config root/usr/bin/db-config
66 install -D -m 755 dns-config root/usr/bin/dns-config
67 install -D -m 755 plc-map.py root/usr/bin/plc-map.py
68 install -D -m 755 clean-empty-dirs.py root/usr/bin/clean-empty-dirs.py
69 install -D -m 755 mtail.py root/usr/bin/mtail.py
70 install -D -m 755 check-ssl-peering.py root/usr/bin/check-ssl-peering.py
71 # Extra scripts (mostly for mail and dns) not installed by myplc by default.  Used in production
72 mkdir root/etc/support-scripts
73 cp support-scripts/* root/etc/support-scripts 
74 # copy initscripts to etc/plc_sliceinitscripts
75 mkdir root/etc/plc_sliceinitscripts
76 cp plc_sliceinitscripts/* root/etc/plc_sliceinitscripts
77
78 # Install initscripts
79 echo "* myplc: Installing initscripts"
80 find plc.d | cpio -p -d -u root/etc/
81 install -D -m 755 guest.init root/etc/init.d/plc
82 chroot root sh -c 'chkconfig --add plc; chkconfig plc on'
83
84 # fetch the release stamp from the build if any
85 # I could not come up with any more sensitive scheme 
86 if [ -f ../../../myplc-release ] ; then
87   cp ../../../myplc-release myplc-release
88 else
89   echo "Cannot find release information." > myplc-release
90   date >> myplc-release
91   echo "$HeadURL$" >> myplc-release
92 fi
93 # install it in /etc/myplc-release 
94 install -m 444 myplc-release root/etc/myplc-release
95
96 ### Thierry Parmentelat - april 16 2007
97 # fix the yum.conf as produced by mkfedora
98 # so we can use the build's fc4 mirror for various installs/upgrades
99 # within the chroot jail
100 # yum_conf_to_build_host is defined in build.functions
101 yum_conf_to_build_host ../build > root/etc/yum.conf
102
103 ### Thierry Parmentelat - may 8 2008
104 # no doc built in this old-fashioned packaging anymore
105 # use myplc-docs instead
106
107 # Install configuration file
108 echo "* myplc: Installing configuration file"
109 install -D -m 444 default_config.xml data/etc/planetlab/default_config.xml
110 install -D -m 444 plc_config.dtd data/etc/planetlab/plc_config.dtd
111
112 # handle root's homedir and tweak root prompt
113 echo "* myplc: root's homedir and prompt"
114 roothome=data/root
115 mkdir -p $roothome
116 cat << EOF > $roothome/.profile
117 export PS1="<plc> \$PS1"
118 EOF
119 chmod 644 $roothome/.profile
120
121 # Move "data" directories out of the installation
122 echo "* myplc: Moving data directories out of the installation"
123 pl_move_dirs root data /data "${datadirs[@]}"
124
125 # Fix permissions on tmp directories
126 pl_fixtmp_permissions data
127
128 # Remove generated bootmanager script
129 rm -f data/var/www/html/boot/bootmanager.sh
130
131 # yumgroups.xml and yum repo : let noderepo handle that
132
133 # Make image out of directory
134 echo "* myplc: Building loopback image"
135 pl_make_image root root.img 100000000
136
137 exit 0