]> git.sur5r.net Git - bacula/rescue/blobdiff - rescue/linux/cdrom/makebinaries
Add new mkcdrec code
[bacula/rescue] / rescue / linux / cdrom / makebinaries
index ed6af5e1b60be4d38248d4be963d4cf36218f5b6..81bc66952f1d29d31086f61ad89f5dc22fc9b90f 100755 (executable)
@@ -10,10 +10,11 @@ R=roottree
 PATH="/sbin:/bin:/usr/sbin:/usr/bin:$PATH"
 
 
-
-rm -rf $R/sbin
+# Cleanup and make necessary directories
+rm -rf $R/sbin $R/bin
+mkdir -p $R/cdrom
 mkdir -p $R/etc $R/initrd $R/lib $R/mnt $R/mnt/cdrom
-mkdir -p $R/proc $R/root $R/sbin $R/tmp $R/var 
+mkdir -p $R/proc $R/root $R/sbin $R/tmp $R/var $R/usr
 mkdir -p $R/dev $R/sys $R/initrd $R/sysroot
 mkdir -p $R/etc/terminfo $R/etc/terminfo/l
 mkdir -p $R/var/lib $R/var/log $R/var/run $R/var/state
@@ -23,15 +24,36 @@ touch $R/var/log/news/news.crit $R/var/log/news/news.err $R/var/log/news.notice
 
 cd $R
 ln -sf sbin bin
+cd usr
+ln -sf ../sbin sbin
 cd $TOPDIR
 
+#
+# Some users have a different shell for root, so be
+#  sure to add it to the rootsbin list. Note, the shell may
+#  be copied twice, but it is not worth the effort to run uniq
+#  here.
+#
+TMPFILE=`mktemp -t bin.XXXXXXXXXX`
+if [ $? !=  0 ]; then
+   echo "Could not make temp file"
+   exit 1
+fi
+cat rootsbin.list >${TMPFILE}
+# Try to find the shell program for root
+command=`grep ^root: /etc/passwd | cut -d ':' -f 7`
+command=`basename $command`
+if [ x$command != "xbash" ] ; then
+   echo "roottree/sbin/$command" >>${TMPFILE}
+fi
+
 echo "Building root /sbin. Some Could not find messages are normal ..."
-for file in `cat rootsbin.list` ; do
+for file in `cat ${TMPFILE}` ; do
     command=`basename $file`
     fullfile=`which $command 2> /dev/null`
     if [ x$fullfile != x ] ; then
 #       echo "updating $command in roottree with $fullfile"
-        cp -fpd $fullfile $file
+        cp -fp  $fullfile $file
         if [ $? != 0 ] ; then
            echo "Update failed."
            exit 1
@@ -42,8 +64,12 @@ for file in `cat rootsbin.list` ; do
         rm -f $file
     fi
 done
+rm -f ${TMPFILE}
+
 cd roottree/sbin
 ln -sf halt reboot
+# Eliminate recursive link
+rm -f sbin
 cd $TOPDIR
 
 # Copy all needed shared libraries
@@ -62,59 +88,137 @@ for lib in `find roottree/sbin/ -type f -exec ldd {} \; | awk '{print $3}' | sor
      fi
   fi
 done
+#
+# Wouldn't you know, there is one so that is critical to have or
+#  nothing will load on 2.6 kernels.
+#
+cp -fp /lib/ld-linux.so.* roottree/lib/
 strip `find roottree/lib/ -maxdepth 1 -type f` 2>/dev/null
 
+# Grab grub RedHat
+if [ -d /usr/share/grub ] ; then
+   mkdir -p roottree/usr/share/grub
+   cp -fpR /usr/share/grub/* roottree/usr/share/grub
+elif [ -d /lib/grub ] ; then
+   mkdir -p roottree/lib/grub
+   cp -fpR /lib/grub/* roottree/lib/grub
+elif [ -d /usr/lib/grub ] ; then
+   mkdir -p roottree/usr/lib/grub
+   cp -fpR /usr/lib/grub* roottree/usr/lib/grub
+else
+   echo "======= Warning could not find grub scripts ========"
+fi
 
-cp -p /etc/services roottree/etc/
-if [ $? != 0 ] ; then
-   echo "Update failed."
-   exit 1
+if [ -d /lib/udev ] ; then
+   rm -rf $R/lib/udev
+   cp -fpR /lib/udev $R/lib/
 fi
 
 #
 # Get a bunch of stuff from /etc
 #
 echo "Building /etc ..."
+# SuSE 10.1
+if [ -f /etc/rc.status ]; then
+   cp -fp /etc/rc.status $R/etc/
+fi
+# copy the whole sysconfig directory
+if [ -d /etc/sysconfig ]; then
+   rm -rf $R/etc/sysconfig
+   cp -fpR /etc/sysconfig/ $R/etc/
+fi
+# comment out HWADDR in any ifcfg-eth* file, otherwise ifconfig won't start
+for i in `ls $R/etc/sysconfig/network*/ifcfg-eth*`
+do
+  grep ^HWADDR $i >/dev/null 2>&1
+  if [ $? -eq 0 ]; then
+     sed -e 's/HWADDR/#HWADDR/' < $i > /tmp/temp.$$
+     mv -f /tmp/temp.$$ $i
+  fi
+done
+
+if [ -d /etc/syslog-ng ] ; then
+   cp -fpR /etc/syslog-ng/ $R/etc/
+fi
+
+cp -p /etc/services roottree/etc/
+if [ $? != 0 ] ; then
+   echo "Update failed."
+   exit 1
+fi
+
 for file in `cat rootetc.list` ; do
-   if [ -e $file ] ; then
+   if [ -f $file ] ; then
       cp -fp $file roottree/etc/
    else
       echo "==== Could not find $file in /etc ===="
    fi
 done
-if [ -e /etc/modules.conf ] ; then
+
+# RedHat has a non-standard rc.d/init.d layout
+if [ -d /etc/rc.d/init.d ]; then
+   cp -a /etc/rc.d/ $R/etc/
+   (cd $R/etc; ln -sf rc.d init.d)
+   rcdtarget=$R/etc/rc.d
+elif [ -d /etc/init.d ]; then
+   cp -a /etc/init.d/ $R/etc/
+   (cd $R/etc; ln -sf init.d rc.d)
+   rcdtarget=$R/etc/init.d
+fi
+cp -f $R/etc/rc ${rcdtarget}/
+cp -a ${MKCDREC_DIR}/etc/rc.d/*  ${rcdtarget}
+cat /dev/null > $R/etc/rc.d/rc.inits
+chmod +x $R/etc/rc.d/rc.inits
+touch $R/etc/rc.d/rc.local
+
+if [ -f /etc/modules.conf ] ; then
    cp -fp /etc/modules.conf roottree/etc/
 fi
-if [ -e /etc/modprobe.conf ] ; then
+if [ -f /etc/modprobe.conf ] ; then
    cp -fp /etc/modprobe.conf roottree/etc/
 fi
+if [ -f /etc/modprobe.conf.local ] ; then
+   cp -fp /etc/modprobe.conf.local roottree/etc/
+fi
+if [ -d /etc/modprobe.d ] ; then
+   cp -a /etc/modprobe.d roottree/etc/
+fi
+
 rm -rf roottree/etc/pam.d
-if [ -e /etc/pam.d ] ; then
+if [ -d /etc/pam.d ] ; then
    cp -a /etc/pam.d roottree/etc/
    if [ -e /etc/pam.conf ] ; then
       cp -fp /etc/pam.conf roottree/etc/
    fi
 fi
 
-if [ -e /etc/init.d ] ; then
-   rm -rf roottree/etc/init.d
-   cp -aL /etc/init.d roottree/etc/
+if [ -d /etc/hotplug ] ; then
+   cp -a /etc/hotplug $R/etc
+fi
+if [ -d /etc/hotplug.d ] ; then
+   cp -a /etc/hotplug.d $R/etc
 fi
+if [ -d /etc/udev ]; then
+   cp -a /etc/udev $R/etc
+fi
+if [ -d /etc/dev.d ]; then
+   cp -a /etc/dev.d $R/etc
+fi                  
+
 
-if [ -e /etc/udev ] ; then
-   rm -rf roottree/etc/udev
-   cp -aL /etc/udev roottree/etc/
+if [ -f /etc/rc.status ] ; then
+   cp -fp /etc/rc.status roottree/etc/
 fi
 
 
 if [ -e /etc/ssh ] ; then
    cp -a /etc/ssh roottree/etc/
-   echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
-   echo "!!!!                                             !!!!"
-   echo "!!!! Warning your /etc/ssh directory was copied. !!!!"
-   echo "!!!! Keep this directory and the CDROM secure.   !!!!"
-   echo "!!!!                                             !!!!"
-   echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+   echo "====================================================="
+   echo "====                                             ===="
+   echo "==== Warning your /etc/ssh directory was copied. ===="
+   echo "==== Keep this directory and the CDROM secure.   ===="
+   echo "====                                             ===="
+   echo "====================================================="
 fi
 if [ -e /etc/security ] ; then
   cp -a /etc/security roottree/etc/
@@ -123,8 +227,8 @@ fi
 #
 # Pull a few files needed by PAM
 #
-if [ -e /lib/libnss_files.so.1 ] ; then
+if [ -f /lib/libnss_files.so.1 ] ; then
   cp -fp /lib/libnss_files.so.1 roottree/lib/
 fi
-cp -fp /lib/libnss_files.so.2 roottree/lib/
+cp -fp /lib/libnss_files.so.* roottree/lib/
 cp -a /lib/security roottree/lib/