]> git.sur5r.net Git - bacula/rescue/blob - rescue/knoppix/cdrom/makebinaries
Add new knoppix directory
[bacula/rescue] / rescue / knoppix / 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 # Eliminate recursive link
68 rm -f sbin
69 cd $TOPDIR
70
71 # Copy all needed shared libraries
72 echo "Building root shared libaries ..."
73 rm -f `find roottree/lib/ -maxdepth 1 -type f 2>/dev/null`
74 #
75 # Statically linked binaries create an error
76 # message from ldd, so we ignore those
77 #
78 for lib in `find roottree/sbin/ -type f -exec ldd {} \; | awk '{print $3}' | sort | uniq` ; do
79   if [ -e $lib ] ; then
80      cp -fp $lib roottree/lib/
81      if [ $? != 0 ] ; then
82         echo "Update failed."
83         exit 1
84      fi
85   fi
86 done
87 #
88 # Wouldn't you know, there is one so that is critical to have or
89 #  nothing will load on 2.6 kernels.
90 #
91 cp -fp /lib/ld-linux.so.* roottree/lib/
92 strip `find roottree/lib/ -maxdepth 1 -type f` 2>/dev/null
93
94 # Grub crap
95 mkdir -p roottree/usr/share/grub
96 cp -fpr /usr/share/grub/* roottree/usr/share/grub
97
98 #
99 # Get a bunch of stuff from /etc
100 #
101 echo "Building /etc ..."
102 cp -p /etc/services roottree/etc/
103 if [ $? != 0 ] ; then
104    echo "Update failed."
105    exit 1
106 fi
107
108 for file in `cat rootetc.list` ; do
109    if [ -e $file ] ; then
110       cp -fp $file roottree/etc/
111    else
112       echo "==== Could not find $file in /etc ===="
113    fi
114 done
115 if [ -e /etc/modules.conf ] ; then
116    cp -fp /etc/modules.conf roottree/etc/
117 fi
118 if [ -e /etc/modprobe.conf ] ; then
119    cp -fp /etc/modprobe.conf roottree/etc/
120 fi
121 rm -rf roottree/etc/pam.d
122 if [ -e /etc/pam.d ] ; then
123    cp -a /etc/pam.d roottree/etc/
124    if [ -e /etc/pam.conf ] ; then
125       cp -fp /etc/pam.conf roottree/etc/
126    fi
127 fi
128
129 if [ -e /etc/init.d ] ; then
130    rm -rf roottree/etc/init.d
131    cp -aL /etc/init.d roottree/etc/
132 fi
133
134 if [ -e /etc/udev ] ; then
135    rm -rf roottree/etc/udev
136    cp -aL /etc/udev roottree/etc/
137 fi
138
139
140 if [ -e /etc/ssh ] ; then
141    cp -a /etc/ssh roottree/etc/
142    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
143    echo "!!!!                                             !!!!"
144    echo "!!!! Warning your /etc/ssh directory was copied. !!!!"
145    echo "!!!! Keep this directory and the CDROM secure.   !!!!"
146    echo "!!!!                                             !!!!"
147    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
148 fi
149 if [ -e /etc/security ] ; then
150   cp -a /etc/security roottree/etc/
151 fi
152
153 #
154 # Pull a few files needed by PAM
155 #
156 if [ -f /lib/libnss_files.so.1 ] ; then
157   cp -fp /lib/libnss_files.so.1 roottree/lib/
158 fi
159 cp -fp /lib/libnss_files.so.* roottree/lib/
160 cp -a /lib/security roottree/lib/