]> git.sur5r.net Git - bacula/rescue/commitdiff
Add new mkcdrec code
authorKern Sibbald <kern@sibbald.com>
Wed, 13 Sep 2006 10:18:44 +0000 (10:18 +0000)
committerKern Sibbald <kern@sibbald.com>
Wed, 13 Sep 2006 10:18:44 +0000 (10:18 +0000)
rescue/diffmkcdrec
rescue/linux/cdrom/Makefile.in
rescue/linux/cdrom/makebinaries
rescue/linux/cdrom/makekernel
rescue/linux/cdrom/mkcdrec_rd [new file with mode: 0755]
rescue/linux/cdrom/rootsbin.list
rescue/linux/cdrom/roottree/etc/inittab

index c0973fd8a00d59faf837c1a81e30846e0a8fbeb4..10b13ff127eb1544b55e4887dfc329b5543b8191 100755 (executable)
@@ -1,2 +1,2 @@
 #!/bin/sh
 #!/bin/sh
-diff -ur mkcdrec ../mkcdrec >diff
+diff -ubr ../mkcdrec mkcdrec >diff
index 721d9c972d41c2b79200ec2378954d16b5e97ec3..e242b24ef8811e097b904a4b567155cca04ccb09 100644 (file)
@@ -8,7 +8,7 @@
 MKCDREC=@BUILD_DIR@/mkcdrec
 CWD=@BUILD_DIR@/linux/cdrom
 
 MKCDREC=@BUILD_DIR@/mkcdrec
 CWD=@BUILD_DIR@/linux/cdrom
 
-first_rule: all
+first_rule: mkcdrec
 dummy:
 
 #-------------------------------------------------------------------------
 dummy:
 
 #-------------------------------------------------------------------------
@@ -54,7 +54,8 @@ bacula: dummy
 copy-bacula:
        cp -a bacula/ cdimage/
 
 copy-bacula:
        cp -a bacula/ cdimage/
 
-pre-mkcdrec:
+pre-mkcdrec:               
+       ./mkcdrec_rd    
        @echo "Patching mkcdrec Config.sh for Bacula"
        @mkdir -p tmp
        @rm -f tmp/1 tmp/2 tmp/1
        @echo "Patching mkcdrec Config.sh for Bacula"
        @mkdir -p tmp
        @rm -f tmp/1 tmp/2 tmp/1
@@ -80,12 +81,13 @@ post-mkcdrec:
        cp /tmp/CDrec.iso bootcd.iso
        chmod 644 bootcd.iso
        rm -f /tmp/CDrec.iso
        cp /tmp/CDrec.iso bootcd.iso
        chmod 644 bootcd.iso
        rm -f /tmp/CDrec.iso
+       rm -f custom-rd.img.bz2
 
 
 # This will build the old Bacula rescue
 all:   kernel binaries bacula initrd iso
 
 
 
 # This will build the old Bacula rescue
 all:   kernel binaries bacula initrd iso
 
-mkcdrec: bacula pre-mkcdrec main-mkcdrec post-mkcdrec
+mkcdrec: kernel binaries bacula pre-mkcdrec main-mkcdrec post-mkcdrec
 
 copy-static-fd: kernel binaries static-bacula initrd iso
 
 
 copy-static-fd: kernel binaries static-bacula initrd iso
 
@@ -109,7 +111,7 @@ clean:
 #
 # Clean out files that are rebuilt
 #
 #
 # Clean out files that are rebuilt
 #
-       @rm -f bootcd.iso   
+       @rm -f bootcd.iso custom-rd.img.bz2
        @rm -f 1 2 3 4
        @rm -rf mnt
        @rm -rf roottree/bin roottree/proc roottree/boot
        @rm -f 1 2 3 4
        @rm -rf mnt
        @rm -rf roottree/bin roottree/proc roottree/boot
index b0f78ea650b8c3382e913b3a8253a97c3445941f..81bc66952f1d29d31086f61ad89f5dc22fc9b90f 100755 (executable)
@@ -11,9 +11,10 @@ PATH="/sbin:/bin:/usr/sbin:/usr/bin:$PATH"
 
 
 # Cleanup and make necessary directories
 
 
 # Cleanup and make necessary directories
-rm -rf $R/sbin
+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/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
 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,6 +24,8 @@ 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 $R
 ln -sf sbin bin
+cd usr
+ln -sf ../sbin sbin
 cd $TOPDIR
 
 #
 cd $TOPDIR
 
 #
@@ -37,6 +40,7 @@ if [ $? !=  0 ]; then
    exit 1
 fi
 cat rootsbin.list >${TMPFILE}
    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
 command=`grep ^root: /etc/passwd | cut -d ':' -f 7`
 command=`basename $command`
 if [ x$command != "xbash" ] ; then
@@ -49,7 +53,7 @@ for file in `cat ${TMPFILE}` ; do
     fullfile=`which $command 2> /dev/null`
     if [ x$fullfile != x ] ; then
 #       echo "updating $command in roottree with $fullfile"
     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
         if [ $? != 0 ] ; then
            echo "Update failed."
            exit 1
@@ -91,21 +95,52 @@ done
 cp -fp /lib/ld-linux.so.* roottree/lib/
 strip `find roottree/lib/ -maxdepth 1 -type f` 2>/dev/null
 
 cp -fp /lib/ld-linux.so.* roottree/lib/
 strip `find roottree/lib/ -maxdepth 1 -type f` 2>/dev/null
 
-# Grab grub crap
-if [ -e /usr/share/grub ] ; then
+# Grab grub RedHat
+if [ -d /usr/share/grub ] ; then
    mkdir -p roottree/usr/share/grub
    mkdir -p roottree/usr/share/grub
-   cp -fpr /usr/share/grub/* roottree/usr/share/grub
-elif [ -e /lib/grub ] ; then
+   cp -fpR /usr/share/grub/* roottree/usr/share/grub
+elif [ -d /lib/grub ] ; then
    mkdir -p roottree/lib/grub
    mkdir -p roottree/lib/grub
-   cp -fpr /lib/grub/* 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
 
 else
    echo "======= Warning could not find grub scripts ========"
 fi
 
+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 ..."
 #
 # 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."
 cp -p /etc/services roottree/etc/
 if [ $? != 0 ] ; then
    echo "Update failed."
@@ -113,34 +148,66 @@ if [ $? != 0 ] ; then
 fi
 
 for file in `cat rootetc.list` ; do
 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
       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
    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
    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
 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
 
    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
 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
 
 
 fi
 
 
index 9e3600fe3e54dd88ed31f4a3c06949e692817c45..151028250eb3b92f696fd33d15474e1315ce5304 100755 (executable)
@@ -30,7 +30,6 @@ cp -af /lib/modules/$KERNEL/ roottree/lib/modules/
 rm -rf roottree/lib/modules/$KERNEL/build
 rm -rf roottree/lib/modules/$KERNEL/kernel/drivers/bluetooth
 rm -rf roottree/lib/modules/$KERNEL/kernel/drivers/pcmcia
 rm -rf roottree/lib/modules/$KERNEL/build
 rm -rf roottree/lib/modules/$KERNEL/kernel/drivers/bluetooth
 rm -rf roottree/lib/modules/$KERNEL/kernel/drivers/pcmcia
-rm -rf roottree/lib/modules/$KERNEL/kernel/drivers/usb
 rm -rf roottree/lib/modules/$KERNEL/kernel/drivers/video
 rm -rf roottree/lib/modules/$KERNEL/kernel/drivers/isdn
 rm -rf roottree/lib/modules/$KERNEL/kernel/sound
 rm -rf roottree/lib/modules/$KERNEL/kernel/drivers/video
 rm -rf roottree/lib/modules/$KERNEL/kernel/drivers/isdn
 rm -rf roottree/lib/modules/$KERNEL/kernel/sound
diff --git a/rescue/linux/cdrom/mkcdrec_rd b/rescue/linux/cdrom/mkcdrec_rd
new file mode 100755 (executable)
index 0000000..fc85558
--- /dev/null
@@ -0,0 +1,115 @@
+#!/bin/sh
+#
+# This script is used to build a "custom" initrd for mkcdrec
+#   It essentially builds a full Bacula environment, but then
+#   when mkcdrec boots, it will load our initrd instead of the
+#   trimmed down mkcdrec version.
+#
+
+TOPDIR=`pwd`
+MKCDREC=../../mkcdrec
+
+LOOP2=/tmp/bacula_rescue_loop2
+rm -rf $LOOP2
+mkdir -p $LOOP2
+
+# Assume that everything to be loaded into memory with the
+# RAM disk image (initrd) is is in the roottree directory. 
+
+echo "Creating the Initial RAM disk image.... "
+
+# first find out how much space we need. 
+ISIZE=`du -s -k  roottree/ | awk '{print $1}'`
+
+# Make a copy for mkcdrec
+rm -rf mkcdrectree
+cp -dpR roottree/ mkcdrectree
+
+#
+# Now copy in the mkcdrec files
+#   Note, we use a number of the mkcdrec scripts
+#
+cp -fp ${MKCDREC}/etc/fstab mkcdrectree/etc
+#  cp -fp ${MKCDREC}/etc/inittab mkcdrectree/etc
+cp -fp ${MKCDREC}/linuxrc mkcdrectree/
+mkdir -p mkcdrectree/etc/rc.d
+cp -fdpR ${MKCDREC}/etc/rc.d/* mkcdrectree/etc/rc.d/
+touch mkcdrectree/etc/rc.d/rc.inits
+chmod +x mkcdrectree/etc/rc.d/rc.inits
+cat >>mkcdrectree/etc/rc.d/rc.local <<EOF
+# This file is sourced
+if [ ! -d /etc/recovery ] ; then
+  cd /
+  if [ -d /mnt/cdrom/recovery.tgz ] ; then
+     tar xfz /mnt/cdrom/recovery.tgz
+  fi
+fi
+EOF
+
+# add 2 Meg for extra   
+ISIZE=`expr $ISIZE + 2048`
+echo "Initial RAM disk contents will be $ISIZE KB"
+
+# delete the existing RAM disk image, if there is one
+rm -f root
+
+dd if=/dev/zero of=$TOPDIR/root bs=1k count=$ISIZE
+
+# cleanup any prior left over stuff
+umount $LOOP2  2>/dev/null >/dev/null
+losetup -d /dev/loop2 2>/dev/null >/dev/null
+
+# associate it with /dev/loop2
+losetup /dev/loop2 $TOPDIR/root
+
+# make an ext2 filesystem on it. Set reserve to 0
+mke2fs -q -m 0 /dev/loop2 $ISIZE
+if [ $? != 0 ] ; then
+  echo "Build failed."
+  exit 1
+fi
+
+# we mount it...
+mount /dev/loop2 $LOOP2
+# ... and delete the lost+found directory 
+rm -rf $LOOP2/lost+found 
+
+# then we copy the contents of our roottree to this filesystem
+cp -dpR mkcdrectree/* $LOOP2/
+cprtn=$?
+
+# and unmount and divorce /dev/loop2
+umount $LOOP2
+losetup -d /dev/loop2 
+rm -rf $LOOP2
+
+# If above copy failed, bail out
+if [ $cprtn != 0 ] ; then
+  echo "RAM disk build failed."
+  exit 1
+fi
+
+# This is a newer way of creating a ramfs, which we don't use
+# (cd roottree; find . | cpio --quiet -c -o) >root
+
+echo "Building initial RAM disk done"
+
+# Now we have the image of the RAM disk in $TOPDIR/loopfiles/root. We
+# compress this one and write the compressed image to the boot tree:
+
+echo "Compressing the RAM disk image.... "
+
+# and gzip our RAM disk image and put it in the right place.
+# Bacula  gzip -9 -c root >cdtree/boot/isolinux/initrd.img
+dd if=root bs=1k | bzip2 -v9 > custom-rd.img.bz2
+if [ $? != 0 ] ; then
+  echo "Build failed"
+  exit 1
+fi
+
+
+# we are done with the RAM disk image, delete it
+rm -f root
+rm -rf mkcdrectree
+
+echo "Initial RAM disk custom-rd.img.bz2 is built."
index e7c21ca6c55b97443949bd0734956636dcee5074..f72113ee8cec27a999cb0caab9d14e6216aaf9af 100644 (file)
@@ -1,5 +1,6 @@
 roottree/sbin/arp
 roottree/sbin/ash
 roottree/sbin/arp
 roottree/sbin/ash
+roottree/sbin/ata-id
 roottree/sbin/awk
 roottree/sbin/badblocks
 roottree/sbin/basename
 roottree/sbin/awk
 roottree/sbin/badblocks
 roottree/sbin/basename
@@ -10,6 +11,7 @@ roottree/sbin/bzip2
 roottree/sbin/cat
 roottree/sbin/cdrecord
 roottree/sbin/chattr
 roottree/sbin/cat
 roottree/sbin/cdrecord
 roottree/sbin/chattr
+roottree/sbin/checkproc
 roottree/sbin/chgrp
 roottree/sbin/chkconfig
 roottree/sbin/chmod
 roottree/sbin/chgrp
 roottree/sbin/chkconfig
 roottree/sbin/chmod
@@ -22,6 +24,7 @@ roottree/sbin/cut
 roottree/sbin/date
 roottree/sbin/dd
 roottree/sbin/debugfs
 roottree/sbin/date
 roottree/sbin/dd
 roottree/sbin/debugfs
+roottree/sbin/depmod
 roottree/sbin/df
 roottree/sbin/dhclient
 roottree/sbin/dhcpd
 roottree/sbin/df
 roottree/sbin/dhclient
 roottree/sbin/dhcpd
@@ -65,8 +68,12 @@ roottree/sbin/hdparm
 roottree/sbin/head
 roottree/sbin/hostname
 roottree/sbin/hotplug
 roottree/sbin/head
 roottree/sbin/hostname
 roottree/sbin/hotplug
+roottree/sbin/hwclock
+roottree/sbin/hwup
 roottree/sbin/id
 roottree/sbin/ifconfig
 roottree/sbin/id
 roottree/sbin/ifconfig
+roottree/sbin/ifup
+roottree/sbin/ifdown
 roottree/sbin/init
 roottree/sbin/insmod
 roottree/sbin/insmod.static
 roottree/sbin/init
 roottree/sbin/insmod
 roottree/sbin/insmod.static
@@ -125,6 +132,7 @@ roottree/sbin/nologin
 roottree/sbin/od
 roottree/sbin/parted
 roottree/sbin/passwd
 roottree/sbin/od
 roottree/sbin/parted
 roottree/sbin/passwd
+roottree/sbin/path_id
 roottree/sbin/ping
 roottree/sbin/portmap
 roottree/sbin/printenv
 roottree/sbin/ping
 roottree/sbin/portmap
 roottree/sbin/printenv
@@ -155,6 +163,7 @@ roottree/sbin/strace
 roottree/sbin/strings
 roottree/sbin/stty
 roottree/sbin/su
 roottree/sbin/strings
 roottree/sbin/stty
 roottree/sbin/su
+roottree/sbin/sulogin
 roottree/sbin/swapoff
 roottree/sbin/swapon
 roottree/sbin/sync
 roottree/sbin/swapoff
 roottree/sbin/swapon
 roottree/sbin/sync
@@ -170,11 +179,17 @@ roottree/sbin/tput
 roottree/sbin/true
 roottree/sbin/tune2fs
 roottree/sbin/udev
 roottree/sbin/true
 roottree/sbin/tune2fs
 roottree/sbin/udev
+roottree/sbin/udevcontrol
+roottree/sbin/udevd
+roottree/sbin/udevsettle
+roottree/sbin/udevtrigger
 roottree/sbin/udevstart
 roottree/sbin/umount
 roottree/sbin/uname
 roottree/sbin/usleep
 roottree/sbin/udevstart
 roottree/sbin/umount
 roottree/sbin/uname
 roottree/sbin/usleep
+roottree/sbin/vol_id
 roottree/sbin/vi
 roottree/sbin/vi
+roottree/sbin/vim
 roottree/sbin/w
 roottree/sbin/which
 roottree/sbin/who
 roottree/sbin/w
 roottree/sbin/which
 roottree/sbin/who
index 73c67cfed783a9b582753e8ebd5e9695b0c6bcab..84cfbab8a09bb4908f383f6d0e36abb5ffb8bc7f 100644 (file)
@@ -18,7 +18,7 @@
 id:2:initdefault:
 
 # System initialization.
 id:2:initdefault:
 
 # System initialization.
-si::sysinit:/etc/sysinit
+si::sysinit:/etc/rc.d/rc.sysinit
 
 #shutdown
 l0:0:wait:/sbin/halt -fd  
 
 #shutdown
 l0:0:wait:/sbin/halt -fd  
@@ -38,8 +38,13 @@ ca::ctrlaltdel:/sbin/halt -d
 
 
 # Run gettys in standard runlevels
 
 
 # Run gettys in standard runlevels
-1:2345:respawn:/sbin/mingetty tty1
-2:2345:respawn:/sbin/mingetty tty2
-3:2345:respawn:/sbin/mingetty tty3
-4:2345:respawn:/sbin/mingetty tty4
-5:2345:respawn:/sbin/mingetty tty5
+#1:2345:respawn:/sbin/mingetty tty1
+1:2345:respawn:/bin/sh
+#2:2345:respawn:/sbin/mingetty tty2
+#2:2345:respawn:/bin/sh
+#3:2345:respawn:/bin/sh
+#4:2345:respawn:/bin/sh
+#5:2345:respawn:/bin/sh
+#3:2345:respawn:/sbin/mingetty tty3
+#4:2345:respawn:/sbin/mingetty tty4
+#5:2345:respawn:/sbin/mingetty tty5