]> git.sur5r.net Git - bacula/rescue/blob - rescue/linux/cdrom/makebinaries
f026ffb100199f92e958ab32fdd8beae8de86e8d
[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
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 echo "Building root /sbin. Some Could not find messages are normal ..."
29 for file in `cat rootsbin.list` ; do
30     command=`basename $file`
31     fullfile=`which $command 2> /dev/null`
32     if [ x$fullfile != x ] ; then
33 #       echo "updating $command in roottree with $fullfile"
34         cp -fpd $fullfile $file
35         if [ $? != 0 ] ; then
36            echo "Update failed."
37            exit 1
38         fi
39         strip $file 2>/dev/null
40     else
41         echo "==== Could not find $command on your system ===="
42         rm -f $file
43     fi
44 done
45 cd roottree/sbin
46 ln -sf halt reboot
47 cd $TOPDIR
48
49 # Copy all needed shared libraries
50 echo "Building root shared libaries ..."
51 rm -f `find roottree/lib/ -maxdepth 1 -type f 2>/dev/null`
52 #
53 # Statically linked binaries create an error
54 # message from ldd, so we ignore those
55 #
56 for lib in `find roottree/sbin/ -type f -exec ldd {} \; | awk '{print $3}' | sort | uniq` ; do
57   if [ -e $lib ] ; then
58      cp -fp $lib roottree/lib/
59      if [ $? != 0 ] ; then
60         echo "Update failed."
61         exit 1
62      fi
63   fi
64 done
65 cp -fp /lib/ld-linux.so.2 roottree/lib/
66 strip `find roottree/lib/ -maxdepth 1 -type f` 2>/dev/null
67
68
69 cp -p /etc/services roottree/etc/
70 if [ $? != 0 ] ; then
71    echo "Update failed."
72    exit 1
73 fi
74
75 #
76 # Get a bunch of stuff from /etc
77 #
78 echo "Building /etc ..."
79 for file in `cat rootetc.list` ; do
80    if [ -e $file ] ; then
81       cp -fp $file roottree/etc/
82    else
83       echo "==== Could not find $file in /etc ===="
84    fi
85 done
86 if [ -e /etc/modules.conf ] ; then
87    cp -fp /etc/modules.conf roottree/etc/
88 fi
89 if [ -e /etc/modprobe.conf ] ; then
90    cp -fp /etc/modprobe.conf roottree/etc/
91 fi
92 rm -rf roottree/etc/pam.d
93 if [ -e /etc/pam.d ] ; then
94    cp -a /etc/pam.d roottree/etc/
95    if [ -e /etc/pam.conf ] ; then
96       cp -fp /etc/pam.conf roottree/etc/
97    fi
98 fi
99
100 if [ -e /etc/init.d ] ; then
101    rm -rf roottree/etc/init.d
102    cp -aL /etc/init.d roottree/etc/
103 fi
104
105 if [ -e /etc/udev ] ; then
106    rm -rf roottree/etc/udev
107    cp -aL /etc/udev roottree/etc/
108 fi
109
110
111 if [ -e /etc/ssh ] ; then
112    cp -a /etc/ssh roottree/etc/
113    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
114    echo "!!!!                                             !!!!"
115    echo "!!!! Warning your /etc/ssh directory was copied. !!!!"
116    echo "!!!! Keep this directory and the CDROM secure.   !!!!"
117    echo "!!!!                                             !!!!"
118    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
119 fi
120 if [ -e /etc/security ] ; then
121   cp -a /etc/security roottree/etc/
122 fi
123
124 #
125 # Pull a few files needed by PAM
126 #
127 if [ -e /lib/libnss_files.so.1 ] ; then
128   cp -fp /lib/libnss_files.so.1 roottree/lib/
129 fi
130 cp -fp /lib/libnss_files.so.2 roottree/lib/
131 cp -a /lib/security roottree/lib/