- Add apache to list of users that can send mail as others without a
[myplc.git] / build_devel.sh
1 #!/bin/bash
2 #
3 # Build a complete MyPLC development environment. Requires PlanetLab
4 # source code to be exported into directories at the same level as we
5 # are (i.e., ..).
6 #
7 # devel/root.img (loopback image)
8 # devel/root/ (mount point)
9 # devel/data/ (various data files)
10 # devel/data/cvs/ (local CVS repository)
11 # devel/data/build/ (build area)
12 # devel/data/etc/planetlab/ (configuration)
13 # devel/data/root (root's home dir)
14 #
15 # Mark Huang <mlhuang@cs.princeton.edu>
16 # Copyright (C) 2006 The Trustees of Princeton University
17 #
18 # $Id: build_devel.sh,v 1.6 2007/01/11 21:49:52 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 /build
29 /cvs
30 /root
31 /tmp
32 /usr/tmp
33 /var/tmp
34 /var/log
35 )
36 for datadir in "${datadirs[@]}" ; do
37     # If we are being re-run, it may be a symlink
38     if [ -h devel/root/$datadir ] ; then
39         rm -f devel/root/$datadir
40         mkdir -p devel/root/$datadir
41     fi
42 done
43
44 echo "* myplc-devel: Installing base filesystem"
45 mkdir -p devel/root
46 make_chroot devel/root plc_devel_config.xml
47
48 # Import everything (including ourself) into a private CVS tree
49 echo "* myplc-devel: Building CVS repository"
50 cvsroot=$PWD/devel/data/cvs
51 mkdir -p $cvsroot
52 cvs -d $cvsroot init
53
54 myplc=$(basename $PWD)
55 pushd ..
56 for dir in * ; do
57     if [ ! -d $cvsroot/$dir ] ; then
58         pushd $dir
59         if [ "$dir" = "$myplc" ] ; then
60             # Ignore generated files
61             ignore="-I ! -I devel -I root -I root.img -I data" 
62         else
63             ignore="-I !"
64         fi
65         cvs -d $cvsroot import -m "Initial import" -ko $ignore $dir planetlab $IMPORT_TAG
66         popd
67     fi
68 done
69 popd
70
71 # Install configuration file
72 echo "* myplc-devel: Installing configuration file"
73 install -D -m 444 plc_devel_config.xml devel/data/etc/planetlab/default_config.xml
74 install -D -m 444 plc_config.dtd devel/data/etc/planetlab/plc_config.dtd
75
76 # Install configuration scripts
77 echo "* myplc-devel: Installing configuration scripts"
78 install -D -m 755 plc_config.py devel/root/tmp/plc_config.py
79 chroot devel/root sh -c 'cd /tmp; python plc_config.py build; python plc_config.py install'
80 install -D -m 755 plc-config devel/root/usr/bin/plc-config
81 install -D -m 755 plc-config-tty devel/root/usr/bin/plc-config-tty
82
83 # Install initscripts
84 echo "* myplc-devel: Installing initscripts"
85 find plc.d/functions | cpio -p -d -u devel/root/etc/
86 install -D -m 755 guest.init devel/root/etc/init.d/plc
87 chroot devel/root sh -c 'chkconfig --add plc; chkconfig plc on'
88
89 # handle root's homedir and tweak root prompt
90 echo "* myplc-devel: root's homedir and prompt"
91 roothome=devel/data/root
92 mkdir -p $roothome
93 cat << EOF > $roothome/.profile
94 export PS1="<plc-devel> \$PS1"
95 EOF
96 chmod 644 $roothome/.profile
97
98 # Move "data" directories out of the installation
99 echo "* myplc-devel: Moving data directories out of the installation"
100 move_datadirs devel/root devel/data "${datadirs[@]}"
101
102 # Fix permissions on tmp directories
103 chmod 1777 devel/data/tmp devel/data/usr/tmp devel/data/var/tmp
104
105 # Make image out of directory
106 echo "* myplc-devel: Building loopback image"
107 make_image devel/root devel/root.img
108
109 exit 0