refine strategy to spot ip address, keep on calling guest_ipv4
[build.git] / config.mlab / sliceimage.post
1 #!/bin/bash
2
3 vdir=$1
4
5 if [ -z "${vdir}" ] ; then
6         echo "ERROR: $0"
7         echo "Provide the directory of the root filesystem to operate on"
8         exit
9 fi
10
11 # reset root password to be empty
12 echo "in slice image: resetting root password"
13 sed -i -e "s/root:[\*|x]/root:/" ${vdir}/etc/passwd
14
15 # modify the sudoers file to remove the 'requiretty' attribute
16 echo "in slice image: removing requiretty from /etc/sudoers"
17 sed -i -e 's,^\(Defaults.*requiretty\),#\1,' ${vdir}/etc/sudoers
18
19 # disable Upstart by creating a symlink to /bin/true
20 #mv ${vdir}/sbin/initctl ${vdir}/sbin/initctl.orig
21 chroot ${vdir} mv /sbin/initctl /sbin/initctl.orig
22 chroot ${vdir} ln /bin/true /sbin/initctl 
23
24 # Fix up /etc/init.d/halt 
25 # xxx this would be wrong in f>=16 because there's no /sbin anymore
26 # but I suspect this is for vserver only..
27 echo "in slice image: fixing /etc/init.d/halt"
28 cat > ${vdir}/etc/init.d/halt <<EOF
29 #!/bin/bash
30 exec /sbin/killall5 -15
31 EOF
32
33 # make sure we do not end up with an empty /selinux 
34 # libvirt gets all confused when that happens
35 cd ${vdir}
36 if [ -d selinux ] ; then
37     if [ "$(ls -A selinux)" ] ; then
38         echo "sliceimage.post: WARNING: ${vdir}/selinux is not empty - preserving"
39     else
40         echo "sliceimage.post: REMOVING empty ${vdir}/selinux"
41         rmdir selinux
42     fi
43 fi
44 cd -