]> git.sur5r.net Git - bacula/rescue/blob - rescue/linux/cdrom/makebinaries
ed6af5e1b60be4d38248d4be963d4cf36218f5b6
[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 strip `find roottree/lib/ -maxdepth 1 -type f` 2>/dev/null
66
67
68 cp -p /etc/services roottree/etc/
69 if [ $? != 0 ] ; then
70    echo "Update failed."
71    exit 1
72 fi
73
74 #
75 # Get a bunch of stuff from /etc
76 #
77 echo "Building /etc ..."
78 for file in `cat rootetc.list` ; do
79    if [ -e $file ] ; then
80       cp -fp $file roottree/etc/
81    else
82       echo "==== Could not find $file in /etc ===="
83    fi
84 done
85 if [ -e /etc/modules.conf ] ; then
86    cp -fp /etc/modules.conf roottree/etc/
87 fi
88 if [ -e /etc/modprobe.conf ] ; then
89    cp -fp /etc/modprobe.conf roottree/etc/
90 fi
91 rm -rf roottree/etc/pam.d
92 if [ -e /etc/pam.d ] ; then
93    cp -a /etc/pam.d roottree/etc/
94    if [ -e /etc/pam.conf ] ; then
95       cp -fp /etc/pam.conf roottree/etc/
96    fi
97 fi
98
99 if [ -e /etc/init.d ] ; then
100    rm -rf roottree/etc/init.d
101    cp -aL /etc/init.d roottree/etc/
102 fi
103
104 if [ -e /etc/udev ] ; then
105    rm -rf roottree/etc/udev
106    cp -aL /etc/udev roottree/etc/
107 fi
108
109
110 if [ -e /etc/ssh ] ; then
111    cp -a /etc/ssh roottree/etc/
112    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
113    echo "!!!!                                             !!!!"
114    echo "!!!! Warning your /etc/ssh directory was copied. !!!!"
115    echo "!!!! Keep this directory and the CDROM secure.   !!!!"
116    echo "!!!!                                             !!!!"
117    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
118 fi
119 if [ -e /etc/security ] ; then
120   cp -a /etc/security roottree/etc/
121 fi
122
123 #
124 # Pull a few files needed by PAM
125 #
126 if [ -e /lib/libnss_files.so.1 ] ; then
127   cp -fp /lib/libnss_files.so.1 roottree/lib/
128 fi
129 cp -fp /lib/libnss_files.so.2 roottree/lib/
130 cp -a /lib/security roottree/lib/