building for f31
[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 # a workaround for running f12 slices under f18; as per Andy findings, we
44 # remove /etc/event.d/tty[23456] inside the slice image
45 # this is not required in f>=16 since these files are upstart-specific anyway
46 rm -f ${vdir}/etc/event.d/tty[23456]
47
48 # mid 2015 (I know..) : fix for fedora 14 slices
49 # use fedora's archive, and other yum-related issues
50 if [[ "$vdir" =~ .*f14.* ]] ; then
51     echo "* sliceimage.post: rectifying fedora14 slice image with fedora-release-14-2.noarch.rpm"
52     rpm --root=$vdir -U http://mirror.onelab.eu/third-party/fedora-release-14-2.noarch.rpm
53 fi
54
55 cd -