c4148308e132095fcb1a7a8b509b95a01b8aa6cc
[build.git] / config.planetlab / 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 # Fix up /etc/init.d/halt 
20 # xxx this would be wrong in f>=16 because there's no /sbin anymore
21 # but I suspect this is for vserver only..
22 echo "in slice image: fixing /etc/init.d/halt"
23 cat > ${vdir}/etc/init.d/halt <<EOF
24 #!/bin/bash
25 exec /sbin/killall5 -15
26 EOF
27
28 # make sure we do not end up with an empty /selinux 
29 # libvirt gets all confused when that happens
30 cd ${vdir}
31 if [ -d selinux ] ; then
32     if [ "$(ls -A selinux)" ] ; then
33         echo "sliceimage.post: WARNING: ${vdir}/selinux is not empty - preserving"
34     else
35         echo "sliceimage.post: REMOVING empty ${vdir}/selinux"
36         rmdir selinux
37     fi
38 fi
39
40 # for when runing under lxc, make sure we don't try to fsck from a slice
41 sed -i -e 's,1 1,0 0,' ${vdir}/etc/fstab
42
43 cd -