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.
10 PATH="/sbin:/bin:/usr/sbin:/usr/bin:$PATH"
13 # Cleanup and make necessary directories
16 mkdir -p $R/etc $R/initrd $R/lib $R/mnt $R/mnt/cdrom
17 mkdir -p $R/proc $R/root $R/sbin $R/tmp $R/var $R/usr
18 mkdir -p $R/dev $R/sys $R/initrd $R/sysroot
19 mkdir -p $R/etc/terminfo $R/etc/terminfo/l
20 mkdir -p $R/var/lib $R/var/log $R/var/run $R/var/state
21 mkdir -p $R/var/lib/nfs
22 mkdir -p $R/var/log/news
23 touch $R/var/log/news/news.crit $R/var/log/news/news.err $R/var/log/news.notice
32 # Some users have a different shell for root, so be
33 # sure to add it to the rootsbin list. Note, the shell may
34 # be copied twice, but it is not worth the effort to run uniq
37 TMPFILE=`mktemp -t bin.XXXXXXXXXX`
39 echo "Could not make temp file"
42 cat rootsbin.list >${TMPFILE}
43 # Try to find the shell program for root
44 command=`grep ^root: /etc/passwd | cut -d ':' -f 7`
45 command=`basename $command`
46 if [ x$command != "xbash" ] ; then
47 echo "roottree/sbin/$command" >>${TMPFILE}
50 echo "Building root /sbin. Some Could not find messages are normal ..."
51 for file in `cat ${TMPFILE}` ; do
52 command=`basename $file`
53 fullfile=`which $command 2> /dev/null`
54 if [ x$fullfile != x ] ; then
55 # echo "updating $command in roottree with $fullfile"
56 cp -fp $fullfile $file
61 strip $file 2>/dev/null
63 echo "==== Could not find $command on your system ===="
71 # Eliminate recursive link
75 # Copy all needed shared libraries
76 echo "Building root shared libaries ..."
77 rm -f `find roottree/lib/ -maxdepth 1 -type f 2>/dev/null`
79 # Statically linked binaries create an error
80 # message from ldd, so we ignore those
82 for lib in `find roottree/sbin/ -type f -exec ldd {} \; | awk '{print $3}' | sort | uniq` ; do
84 cp -fp $lib roottree/lib/
92 # Wouldn't you know, there is one so that is critical to have or
93 # nothing will load on 2.6 kernels.
95 cp -fp /lib/ld-linux.so.* roottree/lib/
96 strip `find roottree/lib/ -maxdepth 1 -type f` 2>/dev/null
99 if [ -d /usr/share/grub ] ; then
100 mkdir -p roottree/usr/share/grub
101 cp -fpR /usr/share/grub/* roottree/usr/share/grub
102 elif [ -d /lib/grub ] ; then
103 mkdir -p roottree/lib/grub
104 cp -fpR /lib/grub/* roottree/lib/grub
105 elif [ -d /usr/lib/grub ] ; then
106 mkdir -p roottree/usr/lib/grub
107 cp -fpR /usr/lib/grub* roottree/usr/lib/grub
109 echo "======= Warning could not find grub scripts ========"
112 if [ -d /lib/udev ] ; then
114 cp -fpR /lib/udev $R/lib/
118 # Get a bunch of stuff from /etc
120 echo "Building /etc ..."
122 if [ -f /etc/rc.status ]; then
123 cp -fp /etc/rc.status $R/etc/
125 # copy the whole sysconfig directory
126 if [ -d /etc/sysconfig ]; then
127 rm -rf $R/etc/sysconfig
128 cp -fpR /etc/sysconfig/ $R/etc/
130 # comment out HWADDR in any ifcfg-eth* file, otherwise ifconfig won't start
131 for i in `ls $R/etc/sysconfig/network*/ifcfg-eth*`
133 grep ^HWADDR $i >/dev/null 2>&1
134 if [ $? -eq 0 ]; then
135 sed -e 's/HWADDR/#HWADDR/' < $i > /tmp/temp.$$
136 mv -f /tmp/temp.$$ $i
140 if [ -d /etc/syslog-ng ] ; then
141 cp -fpR /etc/syslog-ng/ $R/etc/
144 cp -p /etc/services roottree/etc/
145 if [ $? != 0 ] ; then
146 echo "Update failed."
150 for file in `cat rootetc.list` ; do
151 if [ -f $file ] ; then
152 cp -fp $file roottree/etc/
154 echo "==== Could not find $file in /etc ===="
158 # RedHat has a non-standard rc.d/init.d layout
159 if [ -d /etc/rc.d/init.d ]; then
160 cp -a /etc/rc.d/ $R/etc/
161 (cd $R/etc; ln -sf rc.d init.d)
162 rcdtarget=$R/etc/rc.d
163 elif [ -d /etc/init.d ]; then
164 cp -a /etc/init.d/ $R/etc/
165 (cd $R/etc; ln -sf init.d rc.d)
166 rcdtarget=$R/etc/init.d
168 cp -f $R/etc/rc ${rcdtarget}/
169 cp -a ${MKCDREC_DIR}/etc/rc.d/* ${rcdtarget}
170 cat /dev/null > $R/etc/rc.d/rc.inits
171 chmod +x $R/etc/rc.d/rc.inits
172 touch $R/etc/rc.d/rc.local
174 if [ -f /etc/modules.conf ] ; then
175 cp -fp /etc/modules.conf roottree/etc/
177 if [ -f /etc/modprobe.conf ] ; then
178 cp -fp /etc/modprobe.conf roottree/etc/
180 if [ -f /etc/modprobe.conf.local ] ; then
181 cp -fp /etc/modprobe.conf.local roottree/etc/
183 if [ -d /etc/modprobe.d ] ; then
184 cp -a /etc/modprobe.d roottree/etc/
187 rm -rf roottree/etc/pam.d
188 if [ -d /etc/pam.d ] ; then
189 cp -a /etc/pam.d roottree/etc/
190 if [ -e /etc/pam.conf ] ; then
191 cp -fp /etc/pam.conf roottree/etc/
195 if [ -d /etc/hotplug ] ; then
196 cp -a /etc/hotplug $R/etc
198 if [ -d /etc/hotplug.d ] ; then
199 cp -a /etc/hotplug.d $R/etc
201 if [ -d /etc/udev ]; then
202 cp -a /etc/udev $R/etc
204 if [ -d /etc/dev.d ]; then
205 cp -a /etc/dev.d $R/etc
209 if [ -f /etc/rc.status ] ; then
210 cp -fp /etc/rc.status roottree/etc/
214 if [ -e /etc/ssh ] ; then
215 cp -a /etc/ssh roottree/etc/
216 echo "====================================================="
218 echo "==== Warning your /etc/ssh directory was copied. ===="
219 echo "==== Keep this directory and the CDROM secure. ===="
221 echo "====================================================="
223 if [ -e /etc/security ] ; then
224 cp -a /etc/security roottree/etc/
228 # Pull a few files needed by PAM
230 if [ -f /lib/libnss_files.so.1 ] ; then
231 cp -fp /lib/libnss_files.so.1 roottree/lib/
233 cp -fp /lib/libnss_files.so.* roottree/lib/
234 cp -a /lib/security roottree/lib/