]> git.sur5r.net Git - bacula/rescue/blob - rescue/linux/cdrom/makebinaries
a114dd3a97494f5b2620b9b739c777a712783e8a
[bacula/rescue] / rescue / linux / cdrom / makebinaries
1 #!/bin/sh
2
3 # this script finds all binaries and updates them with the ones 
4 # from your system, in order to maintain them more easily.
5 # Be careful. If you have specially made binaries (perhaps lean ones),
6 # they will be overwritten.
7
8 TOPDIR=`pwd`
9 R=roottree
10 PATH="/sbin:/bin:/usr/sbin:/usr/bin:$PATH"
11
12
13 # Cleanup and make necessary directories
14 rm -rf $R/sbin
15 mkdir -p $R/etc $R/initrd $R/lib $R/mnt $R/mnt/cdrom
16 mkdir -p $R/proc $R/root $R/sbin $R/tmp $R/var 
17 mkdir -p $R/dev $R/sys $R/initrd $R/sysroot
18 mkdir -p $R/etc/terminfo $R/etc/terminfo/l
19 mkdir -p $R/var/lib $R/var/log $R/var/run $R/var/state
20 mkdir -p $R/var/lib/nfs 
21 mkdir -p $R/var/log/news
22 touch $R/var/log/news/news.crit $R/var/log/news/news.err $R/var/log/news.notice
23
24 cd $R
25 ln -sf sbin bin
26 cd $TOPDIR
27
28 #
29 # Some users have a different shell for root, so be
30 #  sure to add it to the rootsbin list. Note, the shell may
31 #  be copied twice, but it is not worth the effort to run uniq
32 #  here.
33 #
34 TMPFILE=`mktemp -t bin.XXXXXXXXXX`
35 if [ $? !=  0 ]; then
36    echo "Could not make temp file"
37    exit 1
38 fi
39 cat rootsbin.list >${TMPFILE}
40 command=`grep ^root: /etc/passwd | cut -d ':' -f 7`
41 command=`basename $command`
42 if [ x$command != "xbash" ] ; then
43    echo "roottree/sbin/$command" >>${TMPFILE}
44 fi
45
46 echo "Building root /sbin. Some Could not find messages are normal ..."
47 for file in `cat ${TMPFILE}` ; do
48     command=`basename $file`
49     fullfile=`which $command 2> /dev/null`
50     if [ x$fullfile != x ] ; then
51         echo "updating $command in roottree with $fullfile"
52         cp -fpd $fullfile $file
53         if [ $? != 0 ] ; then
54            echo "Update failed."
55            exit 1
56         fi
57         strip $file 2>/dev/null
58     else
59         echo "==== Could not find $command on your system ===="
60         rm -f $file
61     fi
62 done
63 rm -f ${TMPFILE}
64
65 cd roottree/sbin
66 ln -sf halt reboot
67 cd $TOPDIR
68
69 # Copy all needed shared libraries
70 echo "Building root shared libaries ..."
71 rm -f `find roottree/lib/ -maxdepth 1 -type f 2>/dev/null`
72 #
73 # Statically linked binaries create an error
74 # message from ldd, so we ignore those
75 #
76 for lib in `find roottree/sbin/ -type f -exec ldd {} \; | awk '{print $3}' | sort | uniq` ; do
77   if [ -e $lib ] ; then
78      cp -fp $lib roottree/lib/
79      if [ $? != 0 ] ; then
80         echo "Update failed."
81         exit 1
82      fi
83   fi
84 done
85 #
86 # Wouldn't you know, there is one so that is critical to have or
87 #  nothing will load on 2.6 kernels.
88 #
89 cp -fp /lib/ld-linux.so.* roottree/lib/
90 strip `find roottree/lib/ -maxdepth 1 -type f` 2>/dev/null
91
92 # Grub crap
93 mkdir -p roottree/usr/share/grub
94 cp -fpr /usr/share/grub/* roottree/usr/share/grub
95
96 #
97 # Get a bunch of stuff from /etc
98 #
99 echo "Building /etc ..."
100 cp -p /etc/services roottree/etc/
101 if [ $? != 0 ] ; then
102    echo "Update failed."
103    exit 1
104 fi
105
106 for file in `cat rootetc.list` ; do
107    if [ -e $file ] ; then
108       cp -fp $file roottree/etc/
109    else
110       echo "==== Could not find $file in /etc ===="
111    fi
112 done
113 if [ -e /etc/modules.conf ] ; then
114    cp -fp /etc/modules.conf roottree/etc/
115 fi
116 if [ -e /etc/modprobe.conf ] ; then
117    cp -fp /etc/modprobe.conf roottree/etc/
118 fi
119 rm -rf roottree/etc/pam.d
120 if [ -e /etc/pam.d ] ; then
121    cp -a /etc/pam.d roottree/etc/
122    if [ -e /etc/pam.conf ] ; then
123       cp -fp /etc/pam.conf roottree/etc/
124    fi
125 fi
126
127 if [ -e /etc/init.d ] ; then
128    rm -rf roottree/etc/init.d
129    cp -aL /etc/init.d roottree/etc/
130 fi
131
132 if [ -e /etc/udev ] ; then
133    rm -rf roottree/etc/udev
134    cp -aL /etc/udev roottree/etc/
135 fi
136
137
138 if [ -e /etc/ssh ] ; then
139    cp -a /etc/ssh roottree/etc/
140    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
141    echo "!!!!                                             !!!!"
142    echo "!!!! Warning your /etc/ssh directory was copied. !!!!"
143    echo "!!!! Keep this directory and the CDROM secure.   !!!!"
144    echo "!!!!                                             !!!!"
145    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
146 fi
147 if [ -e /etc/security ] ; then
148   cp -a /etc/security roottree/etc/
149 fi
150
151 #
152 # Pull a few files needed by PAM
153 #
154 if [ -f /lib/libnss_files.so.1 ] ; then
155   cp -fp /lib/libnss_files.so.1 roottree/lib/
156 fi
157 cp -fp /lib/libnss_files.so.* roottree/lib/
158 cp -a /lib/security roottree/lib/