bootcd-4.04/0000755000000000000000000000000012276205075007607 5ustar bootcd-4.04/bootcd-run.lib0000644000000000000000000003725212051371736012363 0ustar # bootcd-run.lib # vim: set filetype=sh : # version: $Version: $ # copyright: Bernd Schumacher (2007) # license: GNU General Public License, version 2 # comment: use ANSW to change the next point from external # description: To understand what to do with this library you can download # the test programs with wget # RUN_INTERACT="no" LANG=C LC_ALL=C IGNORE="" STDOUT="" msg() { echo "--- MESSAGE ---" | tee -a $ERRLOG >&2 echo "$@" | tee -a $ERRLOG >&2 } set +u if [ ! "$ERRLOG" ]; then ERRLOG=/var/log/bootcd.errlog touch "$ERRLOG" >/dev/null 2>&1 [ $? -ne 0 ] && ERRLOG=/tmp/bootcd.errlog msg "ERRLOG was unset. It is set to $ERRLOG now." fi set -u # function dbg prints DEBUG Messages to stderr. # It is very fast because no if-check has to be done # functions dbgoff, dbgon, and dbgtoggle switches dbg on or off dbgoff() { eval "dbg() { :; }" } if [ "$(type dbg 2>&1| grep "not found")" ]; then dbgoff fi dbgon() { eval "dbg() { echo \"DEBUG \$@\" >&2; }" } # with option -v dbtoggle is more verbose dbgtoggle() { if [ "$(dbg 2>&1)" ]; then dbgoff [ "$1" = "-v" ] && echo "debug off" >&2 else dbgon [ "$1" = "-v" ] && echo "debug on" >&2 fi } # function run: run given command and output error # get: $IGNORE -- regexp for error messages, generate no output, no question # (set from function ignore) # $STDOUT -- regexp for error messages, only output, no question # (set from function stdout) # $ERRORLOG -- write to this file # # $RUN_INTERACT -- "yes" meens run from interactiv # comment: by default, all errors (stdout, error) generates output and questions # # Attention: do not try to set global variables in a command called by run !!! # run() { local ERR C T A #echo >&2 "IGNORE $IGNORE" #echo >&2 "STDOUT $STDOUT" while : do > $ERRLOG.tmp ( eval "$@" 2>&1 ERR=$? if [ "$ERR" != "0" ]; then echo "exit=$ERR" fi ) | if [ "$IGNORE" != "" ]; then C="grep -v $IGNORE" tee $ERRLOG.tmp | tee -a $ERRLOG | eval "$C" else tee -a $ERRLOG.tmp | tee -a $ERRLOG fi T=`cat $ERRLOG.tmp` if [ "$IGNORE" != "" ]; then C="grep -v $IGNORE" T=`echo "$T" | eval "$C"` fi if [ "$STDOUT" != "" ]; then C="grep -v $STDOUT" T=`echo "$T" | eval "$C"` fi if [ "$T" != "" ]; then A="" while [ "$A" != "e" -a "$A" != "r" -a "$A" != "i" -a "$A" != "s" ] do echo "--- OUTPUT from <$@> ---" | tee -a $ERRLOG echo "$T" | tee -a $ERRLOG if [ "$RUN_INTERACT" = "yes" ]; then echo -n "--- (e)xit (r)edo (i)gnore (s)witch interactive --- " | tee -a $ERRLOG else echo -n "--- (e)xit (r)edo (i)gnore --- " | tee -a $ERRLOG fi read A # Next line handles EOF from a pipe as "(e)xit" [ $? -ne 0 ] && A="e" echo "$A" >> $ERRLOG done if [ "$A" = "e" ]; then exit 1 elif [ "$A" = "i" ]; then break # switch to interactive mode elif [ "$A" = "s" -a "$RUN_INTERACT" = "yes" ]; then echo echo "switching to interactive mode to point ($ntrctv_ANSW) which failed" echo ntrctv_ANSW=$(($ntrctv_ANSW-1)) ntrctv_y="" break fi else break fi done IGNORE="" STDOUT="" } # function: build stdout for interactive # get: $1 -- number # $2 -- stdout string in_stdout() { local nr=$1 shift eval STDOUT${nr}=\"\$STDOUT${nr} -e \\\"\$@\\\"\" } # function: build ignore for interactive stdout() { STDOUT="$STDOUT -e \"$@\"" } # function: build ignore for interactive # get: $1 -- number # $2 -- ignore string in_ignore() { local nr=$1 shift eval IGNORE${nr}=\"\$IGNORE${nr} -e \\\"\$@\\\"\" } ## example #mm=0 #mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" #in_ignore $mm "error bla" #in_ignore $mm "^bluber sumsel .*" #in_stdout $mm "no error but but a useful comment" #mm=$(($mm+1)); eval IGNORE${mm}=\"\" #in_norun $mm #echo $IGNORE1 -- $IGNORE2 #exit # function: run interactiv -r without run for this menu point # get: $1 -- number # comment: please update norunstring also in interactive! in_norun() { local norunstring="interactive_without_run" local nr=$1 eval IGNORE${nr}=\"$norunstring\" eval STDOUT${nr}=\"$norunstring\" } ignore() { IGNORE="$IGNORE -e \"$@\"" } warn() { if [ $# -gt 0 ]; then A="" while [ "$A" != "e" -a "$A" != "i" ] do echo "--- WARNING ---" | tee -a $ERRLOG echo "$@" | tee -a $ERRLOG echo -n "--- (e)xit (i)gnore --- " | tee -a $ERRLOG if [ "$SCRIPT" ]; then A="i" echo "$A (SCRIPT)" echo "$A (SCRIPT)" >> $ERRLOG echo else read A # Next line handles EOF from a pipe as "(e)xit" [ $? -ne 0 ] && A="e" echo "$A" >> $ERRLOG fi done if [ "$A" = "e" ]; then exit 1 fi fi } err() { ( echo "--- FATAL ERROR ---" echo "$@" ) | if [ "$(set | grep ^ERRLOG=)" ]; then tee -a $ERRLOG >&2 else cat >&2 fi exit 1 } # create_host_keys # if ssh_host_key, ssh_host_rsa or ... exists in # then recreate it. create_host_keys() { # Now only ssh versions which support Option -t are supported F=ssh_host_key if [ -f $1/$F ]; then echo "Creating OpenSSH_2 $F" >>$ERRLOG run "rm -f $1/$F $1/$F.pub" run "ssh-keygen -b 1024 -f $1/$F -N '' -t rsa1 >>$ERRLOG 2>&1" fi F=ssh_host_rsa_key if [ -f $1/$F ]; then echo "Creating OpenSSH_2 $F" >>$ERRLOG run "rm -f $1/$F $1/$F.pub" run "ssh-keygen -b 1024 -f $1/$F -N '' -t rsa >>$ERRLOG 2>&1" fi F=ssh_host_dsa_key if [ -f $1/$F ]; then echo "Creating OpenSSH_2 $F" >>$ERRLOG run "rm -f $1/$F $1/$F.pub" run "ssh-keygen -b 1024 -f $1/$F -N '' -t dsa >>$ERRLOG 2>&1" fi } # syntax: interactive [-y] [-e] [-h ] ... # description: interactive evaluates the listed functioncalls. If the first # argument is not -y an interactive menu will be given. This menu # can get a header with -h. An extra evaluation of # and can be forced with option -e. # The can contain the special # character sequences "<-i>" and "". "<-i>" will be translated # either to "-i" or to "". This can be toggled with the key "i". # # -y -- run without interaction # -e -- evaluate each function call one times more # -h -- print as menu head # -r -- run command with "run" # # helper functions for "run" (-r given to interactive): # in_stdout -- ignore stdout+stderr # in_ignore -- ignore stdout+stderr, don't print # in_norun -- run menupoint without run! # # interactive() { local ntrctv_ANSW ntrctv_A="" ntrctv_i ntrctv_y="" ntrctv_t="-i " ntrctv_head="" ntrctv_e="" ntrctv_run="" ntrctv_c local ntrctv_cmd local norunstring="interactive_without_run" # get all options while [ $# -ge 1 ]; do if [ "$1" = "-y" ]; then ntrctv_y="$1" ntrctv_t="" shift elif [ "$1" = "-e" ]; then ntrctv_e="$1" shift elif [ "$1" = "-h" -a $# -gt 2 ]; then ntrctv_head="$2" shift 2 elif [ "$1" = "-r" ]; then ntrctv_run="yes" shift 1 else break fi done # read the function calls if [ $# -gt 0 ]; then ntrctv_ANSW="1" while :; do if [ ! "$ntrctv_y" ]; then # print head if [ "$ntrctv_head" ]; then ntrctv_c="$ntrctv_head" # evaluate the head [ "$ntrctv_e" ] && ntrctv_c="$(eval echo "$ntrctv_c")" echo "$ntrctv_c" fi ntrctv_i=1 # build menu while [ $ntrctv_i -le $# ]; do ntrctv_c=$(echo "$ntrctv_i $(eval echo "\${$ntrctv_i}")" | sed "s/<-i>[[:space:]]*/$ntrctv_t/g") [ "$ntrctv_e" ] && ntrctv_c="$(eval echo "$ntrctv_c")" echo "$ntrctv_c" ntrctv_i=$(($ntrctv_i+1)) done # dbg exists, print flag (do not use declare to be posix konform) [ "$(type dbg 2>&1| grep "not found")" ] || echo "d toggle dbg() function on and off" # i flag can be toggled [ "$(echo "$*"|grep "<-i>")" ] && echo "i toggle -i flag" # menu point "continue" [ "$ntrctv_ANSW" != "q" ] && [ $ntrctv_ANSW -lt $# ] && echo "c continue without questions" echo "q quit" echo -n "? [$ntrctv_ANSW]" read ntrctv_A # Next line handles EOF from a pipe as "q" [ $? -ne 0 ] && ntrctv_A="q" [ "$ntrctv_A" -a "$ntrctv_A" != "c" -a "$ntrctv_A" != "i" -a "$ntrctv_A" != "d" ] && ntrctv_ANSW="$ntrctv_A" fi if [ "$ntrctv_ANSW" = "q" ]; then return elif [ "$ntrctv_A" = "d" ]; then dbgtoggle -v elif [ "$ntrctv_A" = "i" ]; then [ "$ntrctv_t" ] && ntrctv_t="" || ntrctv_t="-i " elif [ "$(echo "$ntrctv_ANSW" | sed 's/[0-9]//g')" ]; then ntrctv_ANSW="?" elif [ "$ntrctv_ANSW" -ge 1 -a "$ntrctv_ANSW" -le $# ]; then [ "$ntrctv_A" = "c" ] && ntrctv_y="-y" # build the command and set -i, if needed ntrctv_cmd="$(echo "$(eval echo "\${${ntrctv_ANSW}}")" | sed -e "s/<-i>/$ntrctv_t/g")" # eval function call again [ "$ntrctv_e" ] && ntrctv_cmd="$(eval echo "$ntrctv_cmd")" # call function if [ "$ntrctv_run" ]; then local IGNORE="" STDOUT="" [ "$(set | grep "^IGNORE${ntrctv_ANSW}=")" ] && eval IGNORE=\"\$IGNORE${ntrctv_ANSW}\" [ "$(set | grep "^STDOUT${ntrctv_ANSW}=")" ] && eval STDOUT=\"\$STDOUT${ntrctv_ANSW}\" # run is on but run this menu point without run! if [ "$IGNORE" = "$STDOUT" -a "$STDOUT" = "$norunstring" ]; then eval "$ntrctv_cmd" else [ "$ntrctv_y" ] && local RUN_INTERACT="yes" || local RUN_INTERACT="no" run "$ntrctv_cmd" fi else eval "$ntrctv_cmd" fi ntrctv_ANSW=$(($ntrctv_ANSW+1)) [ $ntrctv_ANSW -gt $# ] && ntrctv_ANSW=q fi done fi } ## examples ... comment out and try it # #a() { A="called: a"; [ $# -ge 1 ] && A="$A <$1>"; [ $# -ge 2 ] && A="$A <$2>"; [ $# -ge 3 ] && A="$A <$3>"; [ $# -ge 4 ] && A="$A <$4>"; echo "$A" ;} #interactive a "a -x # with arg and comment" "a -x \"one two\" # 2 args, one with spaces" #exit 0 # #interactive -y a "a -x # with arg and comment" "a -x \"one two\" # 2 args, one with spaces" #exit 0 # #interactive "a A" "a B" "a C" "a D" "a E" "a F" "a G" "a H" "a I" "a J" "a K" #exit 0 # #f="a \"a -x # with arg and comment\" \"a -x \\\"one two\\\" # 2 args, one with spaces\"" #eval "interactive $f" #exit 0 # #interactive # should return without doing anything #exit 0 # #interactive "a <-i> A" "a B" "a <-i> C" #exit 0 # #f1() { IANAME="$IANAME/f1" interactive -e -h "=== \$IANAME \(opts=-e\) n=\<\$n\> ===" "n=$((n+1))" f1; } #n=""; IANAME="main" interactive -e -h "=== \$IANAME \(opts=-e\) n=\<\$n\> ===" "n=$(($n+1)" f1 #exit 0 # #interactive -r "sh -c \"exit 0\"" "echo \"error auf stdout\"" "echo \"error auf stderr\" >&2" "sh -c \"exit 1\"" #exit 0 # #interactive -y -r "sh -c \"exit 0\"" "echo \"error auf stdout\"" "echo \"error auf stderr\" >&2" "sh -c \"exit 1\"" #exit 0 # # function: ask_user -- ask user # get: question = string # default = y|n # ret: 1 == yes | 0 == no ask_user() { local quest=$1 [ "$2" = "y" -o "$2" = "n" ] && local default=$2 || local default="" while [ 1 ]; do echo "$quest" read a # Next line handles EOF from a pipe as "default" [ $? -ne 0 ] && a="" [ "$a" = "" ] && a=$default if [ "$a" = "Y" -o "$a" = "y" -o "$a" = "J" -o "$a" = "j" ]; then # echo "yes" return 1; fi if [ "$a" = "N" -o "$a" = "n" ]; then # echo "no" return 0; fi echo >&2 "Error: \"$a\" is not a allowed answer!" done } # function: do_dir -- create directory # get: $1 -- directory # $2 -- permissions (optional) do_dir() { local dir=$1 local perm=""; [ $# -ge 2 ] && perm=$2 if [ -d "$dir" ]; then ask_user "Directory \"$dir\" exist's, remove it [Y|n] " "y" [ $? = 0 ] && err "Can't work without directory \"$dir\"." rm -rf $dir fi mkdir -p $dir [ "$perm" ] && chmod $perm $dir echo "" } # function: check_tools -- check if tools exist # use ./ to search in local directory # get: $1..$n -- tools check_tools() { while [ $# -gt 0 ]; do echo -n >&2 " check for \"$1\" ..." if [ "$(echo $1 |cut -c1-2)" = "./" ]; then [ ! -f "$1" ] && err "Can't find file \"$1\"!" else [ ! "$(which $1)" ] && err "Can't find tool \"$1\" in PATH!" fi echo >&2 "ok" shift done } # function: prepare_chroot [-i] # globals: IAHEAD prepare_chroot() { local workdir="$1" local interact=""; [ $# -ge 2 ] && interact="$2" local TODO="" mm=0 if [ "$(env | grep "^IAHEAD=")" ]; then local IAHEAD="$IAHEAD / prepare_chroot" else local IAHEAD="prepare_chroot" fi mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"mount --bind /dev $workdir/dev\"" mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"mount -t proc none $workdir/proc\"" mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"mount -t sysfs none $workdir/sys\"" mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"mount -t devpts none $workdir/dev/pts\"" mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"chroot $workdir sh -c \\\"[ -f /etc/mtab ] && mv /etc/mtab /etc/mtab.bootcd || rm -f /etc/mtab.bootcd\\\"\"" mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"chroot $workdir sh -c \\\"grep -v -e \\\\\\\"^sunrpc\>\\\\\\\" -e \\\\\\\"^rootfs\>\\\\\\\" /proc/mounts >/etc/mtab\\\"\"" # we need selinux mounted to install openssh_server without # error "chage: Permission denied." if [ "$(cat /proc/mounts | grep selinux)" ]; then mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"mount -t selinuxfs none $workdir/selinux\"" fi [ "$interact" ] && interact="" || interact="-y" eval "interactive -h \"=== \$IAHEAD ===\" $interact -r $TODO" } # unprepare_chroot [-i] # globals IAHEAD unprepare_chroot() { local workdir="$1" local interact=""; [ $# -ge 2 ] && interact="$2" local TODO="" mm=0 if [ "$(env | grep "^IAHEAD=")" ]; then local IAHEAD="$IAHEAD / unprepare_chroot" else local IAHEAD="unprepare_chroot" fi mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"chroot $workdir sh -c \\\"[ -f /etc/mtab.bootcd ] && mv /etc/mtab.bootcd /etc/mtab || rm -f /etc/mtab\\\"\"" if [ "$(cat /proc/mounts | grep selinux)" ]; then mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"umount $workdir/selinux\"" fi mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"umount $workdir/dev/pts\"" mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"umount $workdir/sys\"" mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"umount $workdir/proc\"" mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"umount $workdir/dev\"" [ "$interact" ] && interact="" || interact="-y" eval "interactive -h \"=== \$IAHEAD ===\" $interact -r $TODO" } bootcd-4.04/bootcd2disk.conf.50000644000000000000000000001474112216615054013033 0ustar .IX Title "boocd2disk" .TH BOOTCD2DISK.CONF 5 "2007-04-04" "bootcd2disk.conf" "bootcd utils" .SH NAME bootcd2disk.conf \- configuration file for bootcd2disk .SH DESCRIPTION The file .B bootcd2disk.conf contains configuration option for the .B bootcd2disk(1) program of the same named package. The file must be located in the configuration directory which is usually /etc/bootcd. Blank lines are ignored and lines with leading # are comments. Values have to be set with .B name=value You can use a wildcard named .B DISK to specify partitions instead of e.g. /dev/hda. DISK was replaced by $DISK, which can be set by the same named parameter. .SH FORMAT .TP .B ERRLOG= Write all errors to this file. Required. .TP .B DISK= Specify the disk you want to use for the installation, e.g. /dev/hda for the first IDE drive in the system. If you use "auto", .I bootcd2disk automatically try to use the first hard disk in the system. Required. .TP .B SFDISK= .br Configuration options for sfdisk, which creates the partitions for us. If you use "auto", we create default partitions "/", "/boot" and a swap partition. Required. .TP .B VFAT= .br Configure vfat partitions there, if you need some. Optional. .TP .B EXT2FS= .br Specify partitions for ext2 FS. This partitions will be created with an ext2 filesystem. If auto is used, auto has to be used for EXT2FS, EXT3FS and EXT4FS. Auto means, that first ext4 will be tried, if this is not available ext3 is tried, and if this is not available ext2 is tried and used for "/" and "/boot" partition. .TP .B EXT3FS= .br See EXT2FS. .TP .B EXT4FS= .br See EXT2FS. .TP .B SWAP= .br The partitions configured there are created as swap. If you use "auto", one swap partition is been created. Required. .TP .B MOUNT= ; ... |auto> .br Insert here the mount command line to mount your partitions or use "auto". Required. Example: .br .RS 8 .PP MOUNT="mount /dev/hda3 /mnt/bootcd.disc; .br mkdir /mnt/bootcd.disc/boot; .br mount /dev/hda1 /mnt/bootcd.disc/boot" .br .RE .TP .B BIND= ; ... |auto> .br Insert here the mount command line to mount your partitions in a chroot environment or use "auto". Required. .TP .B UMOUNT=; ... |auto> .br Insert here the mount command line to umount your partitions or use "auto". Required. .TP .B FSTAB= .br Configure here all partitions you need to mount after target systems startup in the fstab syntax or use "auto". Required. .TP .B LILO= .br This variable includes the complete configuration file for the lilo bootloader on the target system. Use "auto" for automatically generated file. Only required, if you want LILO. Make sure GRUB and GRUB2 are defined as empty if you want to use LILO. .TP .B GRUB= .br This variable includes the complete configuration file for the grub bootloader on the target system. Use "auto" for automatically generated file. Only required, if you want GRUB. .TP .B GRUB2= .br This variable includes the complete configuration file for the grub2 bootloader on the target system. Use "auto" for automatically generated file. Only required, if you want GRUB 2. .TP .B GRUBBOOTDIR= .br This variable defines the partition where the grub bootloader information is stored. You want to use this if you have defined your own partition layout and the grub information is not on the first partition. Remember that grub starts counting partitions at 0. So if you decided that /boot is on partition /dev/sda2 you need to set the parameter to 1. .TP .B GRUBBOOTDISK= .br This should be "hd0". Only if your BIOS sees another disk as the first disk you may have to change it. .TP .B GRUBDEVICEMAP=> GRUBDEVICEMAP="auto" means, bootcd2disk deletes the original device.map, so that it will be auto-created by grub again. This should work also when installing on different hardware with different disks. GRUBDEVICEMAP="no" means bootcd2disk does not change device.map. This should work if a bootcd is installed on the original hardware Everything else will be used as new value for device.map. .TP .B SSHOSTKEY= .br If you are using ssh it is helpful to have a unique ssh hostkey for each system installed with bootcd2disk. This will be generated if this option is set to "yes". Required. .TP .B UDEV_FIXNET= .br If you are using the udev filesystem and want to install the image on other machines, you need to set this to "yes" because the network interfaces are hardwired in /etc/udev/rules.d/z25_persistent-net.rules (etch) or in /etc/udev/rules.d/70-persistent-net.rules (lenny) and we must remove them. Required. .TP .B IMAGEURL= .br If \fBbootcd2disk\fR is slow on your system (because of a slow CD/DVD drive or the HP ILO virtual CD interface), you can use a image server to get the bootcdimage from. .br \fBbootcd2disk\fR use the swap partition of your upcoming system as temporary space and copy the image from the configured image server to this partition and use it as image. May be overwritten from command line "\-url". Need the following parameter "IMAGEURL". Required. The is used with \fBwget\fR, all url syntax from \fBwget\fR are possible. Please use a ip because of failed DNS and you need also the configured ip interface. May be overwritten from command line (\-url). Required. .br .RS 8 .IP "\fBexample:\fR" 4 IMAGEPURL="https://192.168.1.1:81/cdimage.iso" .PP .RE .TP .B function before_copy() { .br .B return .br .B } .br If you want some action before copying the system to the target disk, like remount or other thinks, you can write this action to the body of this function. Optional. .TP .B function after_copy() { .br .B return .br .B } .br If you want some action after copying the system to the target disk, like remount or other thinks, you can write this action to the body of this function. Optional. .SH "SEE ALSO" .br bootcd2disk(1), bootcd(1), bootcdflopcp(1), bootcdwrite(1) .SH AUTHOR This manual page was written by Carsten Dinkelmann <\ficarsten.dinkelmann@foobar-cpa.de\fR>, for the Debian GNU/Linux system (but may be used by others). bootcd-4.04/default.txt0000644000000000000000000000010511417611742011766 0ustar To select a cdrom specify "hda", "hdb", "hdc, "hdd", "sr0" or "sr1". bootcd-4.04/bootcdwrite.conf0000644000000000000000000001167512216615054013011 0ustar # # bootcdwrite.conf # # look for man bootcdwrite.conf(5) for more informations # # this path was added as prefix to KERNEL, INITRD, DISABLE_CRON, NOT_TO_CD # and NOT_TO_RAM, if this are relativ paths (without starting "/") SRCDISK=/ # Define the kernel which is used KERNEL=vmlinuz # additional options for the kernel # If you boot bootcd via HP ILO you might get the message: # "Monitor is in graphics mode or an unsupported text mode" # even if only text is displayed. To prevent this: # APPEND="vga=normal nomodeset" is configured. APPEND="vga=normal nomodeset" # path to initrd INITRD="initrd.img" # define multiple kernels with KERNEL and label KLABEL # default label is "linux # KLABEL1=686-3 # KERNEL1=/boot/vmlinuz-2.6.18-3-686-bigmem # INITRD1=/boot/initrd.img-2.6.18-3-686-bigmem # APPEND1= # Text to Display at Boottime (see syslinux doku) # display info files on boot prompt (F1 = DISPLAY, F2 = DISPLAY2 ...) # (kernelinfo is replaced with a file which includes the kernelinfo) DISPLAY="/usr/share/bootcd/default.txt" DISPLAY2="kernelinfo" # typ is CD or DVD TYP=DVD # specify one or more CD devices to boot from, first is default # "auto" try to find the bootcd on all SCSI and IDE CDROMS CDDEV="auto /dev/hda /dev/hdb /dev/hdc /dev/hdd /dev/sr0 /dev/sr1" # do some checks or not DO_CHECK=yes # exclude some files or directories from writing to cd NOT_TO_CD="" # If you are using ssh it is helpful to have a unique ssh hostkey for # each CD. SSHHOSTKEY=yes # If you are using udev filesystem and install the image only on other # machines you need to set this to "yes" because the network interfaces are # hardwired in /etc/udev/rules.d/z25_persistent-net.rules (etch) or in # /etc/udev/rules.d/70-persistent-net.rules (lenny) and we must remove # them. You can do this also on bootcd2disk. UDEV_FIXNET="yes" # logfile ERRLOG=/var/log/bootcdwrite.log # where the image resists after build VAR=/var/spool/bootcd # FLOPPY_RUNTIME_DEV=|"" # When you boot from cd you read changes from this device. FLOPPY_RUNTIME_DEV=/dev/fd0 # BOOTFLOPPY=yes|no # If you want to boot from FLOPPY specify BOOTFLOPPY=yes. This reduces # space on floppy used by bootcdflopcp. For this to work FLOPPY_CREATE_DEV # has to be specified. # Default: # BOOTFLOPPY=no BOOTFLOPPY=no # If you want to boot several machines from the same cdrom, you must have # the individual configuartion (exp: /etc/network/interfaces) on floppy. # If one can not be mounted it is a good idea to stop booting and to wait # for manual interaction instead of comming up with a wrong configuration. BOOT_ONLY_WITH_FLOPPY=no # delete some chached files in /var CLEAN_VAR=yes # addiditionel entries to fstab # TO_FSTAB="/dev/hdc1 /home ext3 defaults 1 1 # /dev/usb0 /mnt/usb ext3 defaults 1 1 " TO_FSTAB="" # Files or Directory-Trees that should never be compressed on CD can be listed # here. NOTCOMPRESSED="" # Files listed in DISABLE_CRON will be on the cdrom with a .no_run_on_bootcd # suffix so run-parts won't execute them. The original file will be a link to # /bin/true. # DISABLE_CRON="etc/cron.daily/find etc/cron.daily/standard etc/cron.daily/security" # With this variable you can add or delete some options # given to mkisofs by bootcdwrite. # Please create debian-bugreports if you have to use special # options, not mentioned here. Then I can list this options here. # MKISOFS_CHNG="" # extra_changes() # It is possible to define a function called extra_changes to have some # files modified on the ISO image. Here is an example: # # extra_changes() { # echo "noname" >$VAR/changes/etc/hostname # # mkdir -p $VAR/changes/etc/network # ( echo "auto lo" # echo "iface lo inet loopback" # echo "" # echo "auto eth0" # echo "iface eth0 inet static" # echo " address 0.0.0.0" # echo " netmask 255.255.255.0" # ) >$VAR/changes/etc/network/interfaces # # echo "127.0.0.1 localhost noname" >$VAR/changes/etc/hosts # # cat $SRCDISK/etc/passwd | # grep -v -e "^bs:" -e "^bianca:" -e "^tim:" >$VAR/changes/etc/passwd # # cat $SRCDISK/etc/shadow | # grep -v -e "^bs:" -e "^bianca:" -e "^tim:" >$VAR/changes/etc/shadow # # cat $SRCDISK/etc/group | # grep -v -e "^bs:" -e "^bianca:" -e "^tim:" >$VAR/changes/etc/group # } # # # BOOTCDMODPROBE=standard|bootcd|auto # If booted from initrd bootcd has to load the necessary modules. # If only modules provided by initramfs-tools are needed you can # specify "standard" here. If bootcd should try extra hard to load # neccessary modules you can specify "bootcd" here. # Bootcd will use discover for this purpose. So discover has to be installed. # If you specify auto, bootcd will check if discover is installed. # If it is installed # BOOTCDMODPROBE=bootcd will be set, if not # BOOTCDMODPROBE=standard will be set. # Be aware that people have reported, that sometimes BOOTCDMODPROBE=bootcd # may not work but sometimes it is needed. BOOTCDMODPROBE=standard bootcd-4.04/bootcd2disk.conf0000644000000000000000000002221412216615054012662 0ustar ERRLOG=/var/log/bootcd2disk.log # function do_first # If you want to do some things first before doing anythin else (e.g. load # additional modules), you can add this to this function. # function do_first() { # return # } # To define the disk that will be newly partitioned before copying the cd to it # DISK0="/dev/hda" # If you don't want do partition any disk # DISK0="" # If you want bootcd2disk to find a disk (bootcd tries to use the first disk) DISK0="auto" # It is possible to define more disks. The disk number must be increased by 1. #DISK1="auto" #DISK2="auto" # Syntax: # LVMGRP=" [ ...][][\n ...]" # # Example1: # LVMGRP="vg00 DISK0P1 # vg01 DISK0P2 # vg02 DISK0P3 DISK0P4" # # Example2 which is the same as Example1 because it used the default schema # LVMGRP="vg00 DISK0P1 vgcreate vg00 DISK0P1 # vg01 DISK0P2 vgcreate vg01 DISK0P2 # vg02 DISK0P3 vgcreate vg02 DISK0P3 DISK0P4" # # hint: Each volume group definition needs a new line! # # Default: # LVMGRP="" LVMGRP="" # Syntax: # LVMVOL=" [][\n ...]" # # size in vgcreate syntax, e.g.: 100 means 100 MByte # # Example1: # LVMVOL="lv00 2000 vg00" # # Example2 which is the same as Example1 because it used the default schema # LVMVOL="lv00 2000 vg00 lvcreate -n lv00 -L 2000 vg00" # # Example3 uses striping for the second volume # LVMVOL="lv00 2000 vg00 # lv01 100 vg00 lvcreate -n lv01 -i 3 -I 8 -L 100 vg00" # # hint: Each logical volume definition needs a new line! # # Default: # LVMVOL="" LVMVOL="" # If DISK0="auto" is defined, the first disk found will be used. To change # this order TRYFIRST can be defined for example to use SCSI Disks first: # TRYFIRST="/dev/sda /dev/hda" # Most people will not need this option and will define: # TRYFIRST="" TRYFIRST="" # If you don't want to repartition anything use: # SFDISK0="" # If you want to specify yourself: see man sfdisk # If no unit is defined in SFDISK0 MB will be used with sfdisk option "-uM" # SFDISK0=" # ,50 # ,100,S # ; # " # If you want to do it automatically. There will be 3 partitions # /boot, swap and /. /boot is created first to be sure the bios can load # the kernel also on very large disks. Sectors will be used as unit # SFDISK0=" # unit: sectors # 2048,102400,L # 102401,307201,S # 307202,+,L # " SFDISK0="auto" # For each defined DISK there must be one SFDISK Line # SFDISK1="auto" # SFDISK2="auto" # VFAT is normally only needed on ia64 for EFI files. # Do not run mkdosfs: # VFAT="" # Create partitions defined in VFATFS with mkdosfs # VFAT="/dev/sdb4" VFAT="" # Do not not create ext2 filesystems: # EXT2FS="" # Create partitions defined in EXT2FS with mke2fs: # EXT2FS="/dev/hda1 # /dev/hda3" # hint: Each device or logical volume definition needs a new line! # # To create partitions needed automatically: # EXT2FS="auto" # if also EXT3FS="auto" then ext3 will be used if possible EXT2FS="auto" # Do not not create ext3 filesystems: # EXT3FS="" # Create partitions defined in EXT3FS with mke2fs -j: # EXT3FS="/dev/hda1 # /dev/hda3" # hint: Each device or logical volume definition needs a new line! # # To create partitions needed automatically: # EXT3FS="auto" # if also EXT4FS="auto" then ext4 will be used if possible EXT3FS="auto" # Do not not create ext4 filesystems: # EXT4FS="" # Create partitions defined in EXT4FS as ext4 filesystems: # EXT4FS="/dev/hda1 # /dev/hda3" # hint: Each device or logical volume definition needs a new line! # # To create partitions needed automatically: # EXT4FS="auto" EXT4FS="auto" # If you don't want to run mkswap use: # SWAP="" # If you want to specify partitions for mkswap: # SWAP="/dev/hda2" # hint: Each swap device definition needs a new line! # If you want to automatically use mke2fs: SWAP="auto" # If you don't want to mount anything, before copying the cd to /mnt # BIND="" # MOUNT="" # UMOUNT="" # If you want to mount everything yourself: # MOUNT="mount /dev/hda3 /mnt/bootcd.disc; \ # mkdir /mnt/bootcd.disc/boot; mount /dev/hda1 /mnt/bootcd.disc/boot" # In a chroot bootcdbackupwizard has to rebind existing mountpoints: # BIND="mount --bind / /mnt/bootcd.disc; \ # mount --bind /boot /mnt/bootcd.disc/boot" # UMOUNT="umount /mnt/bootcd.disc/boot; umount /mnt/bootcd.disc" # If you want to automatically mount: MOUNT="auto" BIND="auto" UMOUNT="auto" # If you don't want to change the /etc/fstab copied form cd: # FSTAB="" # If You want to define it yourself: # FSTAB=" # /dev/sda1 /boot ext2 defaults 0 1 # /dev/sda2 none swap sw 0 0 # /dev/sda3 / ext2 defaults,errors=remount-ro 0 1 # proc /proc proc defaults 0 0 # " # The string DISK0P1 will be automatically changed to . The string UUID!DISK1P3 will be automacally # changed to the . # # If You want to do it automatically: FSTAB="auto" # If you don't want to use GRUB2: # GRUB2="" # If GRUB2 and GRUB and LILO is defined and installed, GRUB2 will be used # If GRUB2 is auto grub-mkconfig will be used to create it automatically. # If you want to define it yourself: # GRUB2=" # set lang=en # insmod gettext # set timeout=5 # set menu_color_normal=cyan/blue # set menu_color_highlight=white/blue # # menuentry 'Debian GNU/Linux' --class debian --class gnu-linux --class gnu --class os { # insmod ext2 # set root='(hd0,1)' # linux /\$(basename \$KERNEL) root=DISK0P3 ro # initrd /\$(basename \$INITRD) # } # " # Attention grub2 starts counting partitions at 1 and grub1 starts at 0 GRUB2="auto" # If you don't want to use GRUB: # GRUB="" # If GRUB2 is not installed or defined and GRUB is defined and grub is # installed it will be used and # LILO will be ignored. # If you want to define it yourself: # GRUB=" # default 0 # timeout 5 # color cyan/blue white/blue # title Debian GNU/Linux # root (hd0,0) # kernel /vmlinuz-2.4.27-2-386 root=/dev/hda3 ro # initrd /initrd.img-2.4.27-2-386 # savedefault # boot # " # If You want to do it automatically: GRUB="auto" # Only if you BIOS sees another disk as the first disk you may # have to change the next line. GRUBBOOTDISK="hd0" # If /boot is not the first partition on disk # we need to know which one it is to install # grub properly. Attention: bootcd starts counting with 0 like # grub1 ! GRUBBOOTDIR="0" # GRUBDEVICEMAP=auto|no| # GRUBDEVICEMAP="auto" means, bootcd2disk deletes the original # device.map, so that it will be auto-created by grub again. # This should work also when installing on different hardware with # different disks.. # GRUBDEVICEMAP="no" means bootcd2disk does not change device.map. # This should work if a bootcd is installed on the original hardware # Everything else will be used as new value for device.map. GRUBDEVICEMAP="auto" # If GRUB is defined and installed LILO will be ignored. # If you don't want to change the /etc/lilo.conf copied from cd: # LILO="" # If you want to define it yourself: # LILO=" # boot=DISK0 # delay=20 # vga=0 # image=/vmlinuz # root=DISK0P3 # initrd=/initrd.img # label=Linux # read-only # " # If You want to do it automatically: LILO="auto" # SSHOSTKEY=yes|no # If you are using ssh it is helpful to have a unique ssh hostkey for # each PC installed with bootcd2disk. This will be generated with # SSHHOSTKEY="yes" SSHHOSTKEY=yes # UDEV_FIXNET=yes|no # If you are using udev filesystem and install the image on other machines # you need to set this to "yes" because the network interfaces are hardwired # in /etc/udev/rules.d/z25_persistent-net.rules (etch) or in # /etc/udev/rules.d/70-persistent-net.rules (lenny) and we must remove them. # UDEV_FIXNET="yes" UDEV_FIXNET="yes" # IMAGEURL="" | IMAGEURL="" # If bootcd2disk is slow on your system (because of a slow CD/DVD drive or # the HP ILO virtual CD interface), you can use a image server to get the # image from. # bootcd2disk use the SWAP partition of your upcoming system as temporary # space and copy the image from the configured image server (IMAGEURL or # cmdline -url) to this partition and use it as image. # The "url" is used with "wget" so all url from wget are possible. # e.g: http://192.168.100.10/cdimage.iso # hint: Please use a ip because of failed DNS and you need also the # configured ip interface. # hint: the option may be overwritten from command line (-url) # IMAGEURL="" IMAGEURL="" # PARTITIONLABEL="" # If you want the filesystem or swap partitions to have labels you can define # them here. Example: # PARTITIONLABEL="/dev/sda1:/ # /dev/sda2:SWAP-sda2" PARTITIONLABEL="" # function after_copy # If you want to do some things after copying the files (e.g. remount of # directories ...), you can add this to this function. # function after_copy() { # return # } # # Examples: # # IF you only want to copy the cd to an already existing Partition /dev/hda2 # You can now specify: # DISK0=""; SFDISK0=""; SWAP=""; FSTAB=""; LILO="" # EXTFS2="/dev/hda2" # MOUNT="mount /dev/hda2 /mnt/bootcd.disc" bootcd-4.04/bootcdmk2diskconf.tst70000755000000000000000000002751112271451750014046 0ustar #!/bin/sh VERBOSE="" # VERBOSE="" means silent; VERBOSE="1" means verbose if [ "$1" = "-v" ];then VERBOSE="1" fi ############################ ### 1. define Test Input ### ############################ export RIFSTAB=" # # /etc/fstab # Created by anaconda on Tue Dec 4 13:22:52 2012 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/vg_nnm1-lv_root / ext4 defaults 1 1 UUID=bf9f3951-dc31-46b5-b726-f3aeab98d22a /boot ext4 defaults 1 2 /dev/mapper/vg_nnm1-var_log /var/log ext4 defaults 1 2 /dev/mapper/vg_nnm1-fmip /fmip ext4 defaults 1 2 /dev/mapper/vg_nnm1-nnmi_backup /nnmi_backup ext4 defaults 1 2 /dev/mapper/vg_nnm1-nnmi_config /nnmi_config ext4 defaults 1 2 /dev/mapper/vg_nnm1-opt_ov /opt/OV ext4 defaults 1 2 /dev/mapper/vg_nnm1-tmp /tmp ext4 defaults 1 2 /dev/mapper/vg_nnm1-var_opt_ov /var/opt/OV ext4 defaults 1 2 /dev/mapper/vg_nnm1-var_opt_ov_shared /var/opt/OV/shared ext4 defaults 1 2 /dev/mapper/vg_nnm1-lv_swap swap swap defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0" export RIGRUB="# grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/mapper/vg_nnm1-lv_root # initrd /initrd-[generic-]version.img #boot=/dev/sda default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title Red Hat Enterprise Linux Server (2.6.32-358.23.2.el6.x86_64) root (hd0,0) kernel /vmlinuz-2.6.32-358.23.2.el6.x86_64 ro root=/dev/mapper/vg_nnm1-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_nnm1/lv_root KEYBOARDTYPE=pc KEYTABLE=de-latin1-nodeadkeys rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=128M rd_LVM_LV=vg_nnm1/lv_swap rd_NO_DM initrd /initramfs-2.6.32-358.23.2.el6.x86_64.img title Red Hat Enterprise Linux Server (2.6.32-358.18.1.el6.x86_64) root (hd0,0) kernel /vmlinuz-2.6.32-358.18.1.el6.x86_64 ro root=/dev/mapper/vg_nnm1-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_nnm1/lv_root KEYBOARDTYPE=pc KEYTABLE=de-latin1-nodeadkeys rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=128M rd_LVM_LV=vg_nnm1/lv_swap rd_NO_DM initrd /initramfs-2.6.32-358.18.1.el6.x86_64.img title Red Hat Enterprise Linux (2.6.32-220.el6.x86_64) root (hd0,0) kernel /vmlinuz-2.6.32-220.el6.x86_64 ro root=/dev/mapper/vg_nnm1-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_nnm1/lv_root KEYBOARDTYPE=pc KEYTABLE=de-latin1-nodeadkeys rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=128M rd_LVM_LV=vg_nnm1/lv_swap rd_NO_DM initrd /initramfs-2.6.32-220.el6.x86_64.img" export RIGRUB2="" export RILV="lv_nnm_pkg:vg_gm:153596 fmip:vg_nnm1:10240 lv_root:vg_nnm1:25000 lv_swap:vg_nnm1:32000 nnmi_backup:vg_nnm1:51200 nnmi_config:vg_nnm1:20000 opt_ov:vg_nnm1:20480 tmp:vg_nnm1:10000 var_log:vg_nnm1:10240 var_opt_ov:vg_nnm1:50000 var_opt_ov_shared:vg_nnm1:50000" export RIPV="/dev/mapper/3600508b1001c9e14b850ec3afd0d1fccp2:vg_nnm1 /dev/mapper/nnm-pkg:vg_gm" export RIDF="/dev/mapper/vg_nnm1-lv_root:24608 /dev/mapper/3600508b1001c9e14b850ec3afd0d1fccp1:485 /dev/mapper/vg_nnm1-var_log:10080 /dev/mapper/vg_nnm1-fmip:10080 /dev/mapper/vg_nnm1-nnmi_backup:50397 /dev/mapper/vg_nnm1-nnmi_config:19686 /dev/mapper/vg_nnm1-opt_ov:20162 /dev/mapper/vg_nnm1-tmp:9843 /dev/mapper/vg_nnm1-var_opt_ov:49215 /dev/mapper/vg_nnm1-var_opt_ov_shared:49215 /dev/mapper/vg_gm-lv_nnm_pkg:151186" export RILABEL="" export RIUUID="/dev/mapper/3600508b1001c9e14b850ec3afd0d1fccp1:bf9f3951-dc31-46b5-b726-f3aeab98d22a" export RIPARTITION=" /dev/dm-0:153600 /dev/dm-10:51200 /dev/dm-1:1024 /dev/dm-11:50000 /dev/dm-12:20480 /dev/dm-13:10240 /dev/dm-14:10240 /dev/dm-15:153596 /dev/dm-2:572140 /dev/dm-3:500 /dev/dm-4:571639 /dev/dm-5:25000 /dev/dm-6:32000 /dev/dm-7:20000 /dev/dm-8:10000 /dev/dm-9:50000 /dev/mapper/3600508b1001c9e14b850ec3afd0d1fcc:572140 /dev/mapper/3600508b1001c9e14b850ec3afd0d1fccp1:500 /dev/mapper/3600508b1001c9e14b850ec3afd0d1fccp2:571639 /dev/mapper/nnm-pkg:153600 /dev/mapper/quorum:1024 /dev/mapper/vg_gm-lv_nnm_pkg:153596 /dev/mapper/vg_nnm1-fmip:10240 /dev/mapper/vg_nnm1-lv_root:25000 /dev/mapper/vg_nnm1-lv_swap:32000 /dev/mapper/vg_nnm1-nnmi_backup:51200 /dev/mapper/vg_nnm1-nnmi_config:20000 /dev/mapper/vg_nnm1-opt_ov:20480 /dev/mapper/vg_nnm1-tmp:10000 /dev/mapper/vg_nnm1-var_log:10240 /dev/mapper/vg_nnm1-var_opt_ov:50000 /dev/mapper/vg_nnm1-var_opt_ov_shared:50000 /dev/sda:572140 /dev/sdc:153600 /dev/sdd:1024 /dev/sdf:153600 /dev/sdg:1024 /dev/sdi:153600 /dev/sdj:1024 /dev/sdl:153600 /dev/sdm:1024 /dev/sdo:153600 /dev/sdp:1024 /dev/sdr:153600 /dev/sds:1024 /dev/sdu:153600 /dev/sdv:1024 /dev/sdx:153600 /dev/sdy:1024" ################################# ### 2. define expected Output ### ################################# EXPECTED_DISK0="auto" EXPECTED_DISK1="auto" EXPECTED_LVMGRP=" vg_gm DISK1 vg_nnm1 DISK0P2 " EXPECTED_LVMVOL=" lv_nnm_pkg 153596 vg_gm fmip 10240 vg_nnm1 lv_root 25000 vg_nnm1 lv_swap 32000 vg_nnm1 nnmi_backup 51200 vg_nnm1 nnmi_config 20000 vg_nnm1 opt_ov 20480 vg_nnm1 tmp 10000 vg_nnm1 var_log 10240 vg_nnm1 var_opt_ov 50000 vg_nnm1 var_opt_ov_shared 50000 vg_nnm1 " EXPECTED_SFDISK0=" ,500 ; " EXPECTED_SFDISK1=" ,0 " EXPECTED_VFAT="" EXPECTED_EXT2FS=" " EXPECTED_EXT3FS=" " EXPECTED_EXT4FS=" /dev/mapper/vg_nnm1-lv_root DISK0P1 /dev/mapper/vg_nnm1-var_log /dev/mapper/vg_nnm1-fmip /dev/mapper/vg_nnm1-nnmi_backup /dev/mapper/vg_nnm1-nnmi_config /dev/mapper/vg_nnm1-opt_ov /dev/mapper/vg_nnm1-tmp /dev/mapper/vg_nnm1-var_opt_ov /dev/mapper/vg_nnm1-var_opt_ov_shared " EXPECTED_SWAP="/dev/mapper/vg_nnm1-lv_swap" EXPECTED_MOUNT=" mkdir -p /tstmount/; mount /dev/mapper/vg_nnm1-lv_root /tstmount/ mkdir -p /tstmount/boot; mount DISK0P1 /tstmount/boot mkdir -p /tstmount/var/log; mount /dev/mapper/vg_nnm1-var_log /tstmount/var/log mkdir -p /tstmount/fmip; mount /dev/mapper/vg_nnm1-fmip /tstmount/fmip mkdir -p /tstmount/nnmi_backup; mount /dev/mapper/vg_nnm1-nnmi_backup /tstmount/nnmi_backup mkdir -p /tstmount/nnmi_config; mount /dev/mapper/vg_nnm1-nnmi_config /tstmount/nnmi_config mkdir -p /tstmount/opt/OV; mount /dev/mapper/vg_nnm1-opt_ov /tstmount/opt/OV mkdir -p /tstmount/tmp; mount /dev/mapper/vg_nnm1-tmp /tstmount/tmp mkdir -p /tstmount/var/opt/OV; mount /dev/mapper/vg_nnm1-var_opt_ov /tstmount/var/opt/OV mkdir -p /tstmount/var/opt/OV/shared; mount /dev/mapper/vg_nnm1-var_opt_ov_shared /tstmount/var/opt/OV/shared " EXPECTED_BIND=" mkdir -p /tstmount/; mount --bind / /tstmount/ mkdir -p /tstmount/boot; mount --bind /boot /tstmount/boot mkdir -p /tstmount/var/log; mount --bind /var/log /tstmount/var/log mkdir -p /tstmount/fmip; mount --bind /fmip /tstmount/fmip mkdir -p /tstmount/nnmi_backup; mount --bind /nnmi_backup /tstmount/nnmi_backup mkdir -p /tstmount/nnmi_config; mount --bind /nnmi_config /tstmount/nnmi_config mkdir -p /tstmount/opt/OV; mount --bind /opt/OV /tstmount/opt/OV mkdir -p /tstmount/tmp; mount --bind /tmp /tstmount/tmp mkdir -p /tstmount/var/opt/OV; mount --bind /var/opt/OV /tstmount/var/opt/OV mkdir -p /tstmount/var/opt/OV/shared; mount --bind /var/opt/OV/shared /tstmount/var/opt/OV/shared " EXPECTED_UMOUNT=" umount /tstmount/var/opt/OV/shared umount /tstmount/nnmi_config umount /tstmount/nnmi_backup umount /tstmount/var/opt/OV umount /tstmount/var/log umount /tstmount/opt/OV umount /tstmount/fmip umount /tstmount/boot umount /tstmount/tmp umount /tstmount/ " EXPECTED_FSTAB=" # # /etc/fstab # Created by anaconda on Tue Dec 4 13:22:52 2012 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/vg_nnm1-lv_root / ext4 defaults 1 1 UUID=UUID!DISK0P1 /boot ext4 defaults 1 2 /dev/mapper/vg_nnm1-var_log /var/log ext4 defaults 1 2 /dev/mapper/vg_nnm1-fmip /fmip ext4 defaults 1 2 /dev/mapper/vg_nnm1-nnmi_backup /nnmi_backup ext4 defaults 1 2 /dev/mapper/vg_nnm1-nnmi_config /nnmi_config ext4 defaults 1 2 /dev/mapper/vg_nnm1-opt_ov /opt/OV ext4 defaults 1 2 /dev/mapper/vg_nnm1-tmp /tmp ext4 defaults 1 2 /dev/mapper/vg_nnm1-var_opt_ov /var/opt/OV ext4 defaults 1 2 /dev/mapper/vg_nnm1-var_opt_ov_shared /var/opt/OV/shared ext4 defaults 1 2 /dev/mapper/vg_nnm1-lv_swap swap swap defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 " EXPECTED_GRUB2=" " EXPECTED_GRUB=" # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/mapper/vg_nnm1-lv_root # initrd /initrd-[generic-]version.img #boot=/dev/sda default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title Red Hat Enterprise Linux Server (2.6.32-358.23.2.el6.x86_64) root (hd0,0) kernel /vmlinuz-2.6.32-358.23.2.el6.x86_64 ro root=/dev/mapper/vg_nnm1-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_nnm1/lv_root KEYBOARDTYPE=pc KEYTABLE=de-latin1-nodeadkeys rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=128M rd_LVM_LV=vg_nnm1/lv_swap rd_NO_DM initrd /initramfs-2.6.32-358.23.2.el6.x86_64.img title Red Hat Enterprise Linux Server (2.6.32-358.18.1.el6.x86_64) root (hd0,0) kernel /vmlinuz-2.6.32-358.18.1.el6.x86_64 ro root=/dev/mapper/vg_nnm1-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_nnm1/lv_root KEYBOARDTYPE=pc KEYTABLE=de-latin1-nodeadkeys rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=128M rd_LVM_LV=vg_nnm1/lv_swap rd_NO_DM initrd /initramfs-2.6.32-358.18.1.el6.x86_64.img title Red Hat Enterprise Linux (2.6.32-220.el6.x86_64) root (hd0,0) kernel /vmlinuz-2.6.32-220.el6.x86_64 ro root=/dev/mapper/vg_nnm1-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_nnm1/lv_root KEYBOARDTYPE=pc KEYTABLE=de-latin1-nodeadkeys rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=128M rd_LVM_LV=vg_nnm1/lv_swap rd_NO_DM initrd /initramfs-2.6.32-220.el6.x86_64.img " EXPECTED_GRUBBOOTDISK="hd0" EXPECTED_GRUBBOOTDIR="0" EXPECTED_GRUBDEVICEMAP="auto" EXPECTED_LILO="" EXPECTED_SSHHOSTKEY="unchanged" EXPECTED_UDEV_FIXNET="no" EXPECTED_IMAGEURL="" EXPECTED_PARTITIONLABEL=" " ################################ ### 3. Run bootcdmk2diskconf ### ################################ if [ ! -f bootcdmk2diskconf ]; then echo "ERROR: bootcdmk2diskconf not found" >&2 exit 1 fi RESULT="$(./bootcdmk2diskconf -t)" #RESULT="$(./bootcdmk2diskconf -t -d)" [ "$VERBOSE" ] && echo "$RESULT" BOOTCDMP=/tstmount eval "$RESULT" ######################## ### 4. Check Results ### ######################## for i in DISK0 DISK1 LVMGRP LVMVOL SFDISK0 SFDISK1 VFAT EXT2FS EXT3FS EXT4FS SWAP MOUNT BIND \ UMOUNT FSTAB GRUB2 GRUB SWAP MOUNT BIND UMOUNT FSTAB GRUB2 GRUB; do eval "a=\$$i" eval "b=\$EXPECTED_$i" if [ "$a" != "$b" ]; then echo "==== ERROR $i ====" echo "OUTPUT=<$a>" echo "EXPECTED=<$b>" fi done bootcd-4.04/bootcdaufs0000755000000000000000000000377012006721744011672 0ustar #!/bin/sh # if necessary mount iso image loopback # use aufs to make iso image "writable" # See manpage initramfs-tools(8) [ -f /scripts/functions ] && . /scripts/functions PREREQ="" prereqs() { echo "$PREREQ" } case $1 in prereqs) prereqs exit 0 ;; esac # chkerr chkerr() { e=$1 shift if [ $e -ne 0 ]; then echo "bootcdaufs: ERROR $e while running: $*" echo "try to fix and exit" /bin/sh fi } getiso() { sed -n "s/^.*\.*$/\2/p" } if [ "$(grep "\" iso="$(cat /proc/cmdline | getiso)" if [ "$iso" ]; then mkdir /bootcd.disk_with_iso mount --move ${rootmnt} /bootcd.disk_with_iso chkerr $? "mount --move ${rootmnt} /bootcd.disk_with_iso" modprobe loop mount -o loop -t iso9660 /bootcd.disk_with_iso/${iso} ${rootmnt} chkerr $? "mount -o loop -t iso9660 /bootcd.disk_with_iso/${iso} ${rootmnt}" fi mkdir /bootcd.aufs mount none -t tmpfs /bootcd.aufs chkerr $? "mount none -t tmpfs /bootcd.aufs" mkdir /bootcd.ro mount --move ${rootmnt} /bootcd.ro chkerr $? "mount --move ${rootmnt} /bootcd.ro" mkdir /aufs mount none -t aufs -o dirs=/bootcd.aufs:/bootcd.ro=ro /aufs chkerr $? "mount none -t aufs -o dirs=/bootcd.aufs:/bootcd.ro=ro /aufs" mkdir -p /aufs/mnt/bootcd.ro mount --move /bootcd.ro /aufs/mnt/bootcd.ro chkerr $? "mount --move /bootcd /aufs/mnt/bootcd.ro" if [ "$iso" ]; then mkdir -p /aufs/mnt/bootcd.disk_with_iso mount --move /bootcd.disk_with_iso /aufs/mnt/bootcd.disk_with_iso chkerr $? "mount --move /bootcd.disk_with_iso /aufs/mnt/bootcd.disk_with_iso" fi mkdir -p /aufs/mnt/bootcd.aufs mount --move /bootcd.aufs /aufs/mnt/bootcd.aufs chkerr $? "mount --move /bootcd.aufs /aufs/mnt/bootcd.aufs" mount --move /aufs ${rootmnt} chkerr $? "mount --move /aufs ${rootmnt}" fi exit 0 bootcd-4.04/bootcd2disk0000755000000000000000000011665112216615054011752 0ustar #!/bin/sh # # bootcd2disk # # DISK=auto, we will build an boot partition with size defined in BOOTS TODOY="-y" TODO="" mm=0 IAHEAD="bootcd2disk" IMAGEURL="" IMAGEURLCMD="" SCRIPT="" CONFDIR="/etc/bootcd" ONLYMOUNT="" ONLYUNMOUNT="" CHROOTDIR="" MNTBOOTCDDISC="mnt/bootcd.disc" COPYDEST="/$MNTBOOTCDDISC" IGNORE="" STDOUT="" ROOT="" ORIGINALDISKNAME="" ISOLOOPBACK="" DEBUG="" # function: usage # get: $1 -- error string usage() { [ "$1" ] && echo >&2 "$1" echo >&2 " $(basename $0) copy a system running from bootcd to a disk." echo >&2 " syntax: -i -- interactiv operation" echo >&2 " -d -- turn debug on" echo >&2 " -s -- be silent and no interaction" echo >&2 " -c -- use another configuration directory" echo >&2 " -url -- url from imageserver" echo >&2 " (overwrite IMAGEURL from config)" echo >&2 " -onlymount -- only mount disks" echo >&2 " -onlyunmount -- only unmount disks" echo >&2 " -r -- debian root" echo >&2 " -o -- use original disk names for only[un]mount" echo >&2 " -mkchroot -- bootcd will be copied to /chroot" echo >&2 "" exit 1 } domount() { echo "--- mounting DISK ---" dbg "COPYDEST=<$COPYDEST>" dbg "MOUNT=<$MOUNT>" mkdir -p $COPYDEST eval "$MOUNT" } dobind() { echo "--- binding mounted DISK ---" dbg "COPYDEST=<$COPYDEST>" dbg "BIND=<$BIND>" eval "$BIND" } todo_domount() { # use global TODO mm ... if [ "$ROOT" -a "$BIND" ]; then # we are in chroot and BIND is defiled mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" if [ "$SCRIPT" ]; then in_ignore $mm "^--- .* ---$" else in_stdout $mm "^--- .* ---$" fi TODO="$TODO \"dobind # binding all partitions to $COPYDEST\"" else mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" if [ "$SCRIPT" ]; then in_ignore $mm "^--- .* ---$" else in_stdout $mm "^--- .* ---$" fi TODO="$TODO \"domount # mount all partitions to $COPYDEST\"" fi } dounmount() { echo "--- unmounting DISK ---" dbg "UMOUNT=<$UMOUNT>" eval "$UMOUNT" } todo_dounmount() { # use global TODO mm mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" if [ "$SCRIPT" ]; then in_ignore $mm "^--- .* ---$" else in_stdout $mm "^--- .* ---$" fi TODO="$TODO \"dounmount\"" } # get options while [ "$1" ]; do case "$1" in "-h"|"--help") usage ;; "-i") TODOY="" shift ;; "-url") IMAGEURLCMD="$2" ISOLOOPBACK="/tmp/isoloopback" shift 2 ;; "-d") DEBUG="$1" shift ;; "-c") CONFDIR="$2" [ "$CONFDIR" = "." ] && CONFDIR="$PWD" shift 2 ;; "-s") SCRIPT="$1" shift ;; "-onlymount") ONLYMOUNT="$1" shift ;; "-onlyunmount") ONLYUNMOUNT="$1" shift ;; "-o") ORIGINALDISKNAME="$1" shift ;; "-r") ROOT="$2" BOOTCDMP="$ROOT/$MNTBOOTCDDISC" # This may change mount and unmount commands in bootcd2disk.conf shift 2 ;; "-mkchroot") CHROOTDIR="$2" COPYDEST="$CHROOTDIR/chroot" shift 2 ;; *) usage "ERROR: option \"$1\" unknown!" ;; esac done # Set variables that are not forced in bootcd2disk.conf for now MD="" # Read bootcd2disk.conf CONFVARS="DISK0 SFDISK0 EXT2FS EXT3FS EXT4FS SWAP BIND MOUNT UMOUNT FSTAB LILO SSHHOSTKEY \ UDEV_FIXNET IMAGEURL TRYFIRST GRUB GRUB2 LVMGRP LVMVOL \ GRUBBOOTDISK GRUBDEVICEMAP GRUBBOOTDIR PARTITIONLABEL" unset $CONFVARS [ ! -f $ROOT/$CONFDIR/bootcd2disk.conf ] && err "No file $ROOT/$CONFDIR/bootcd2disk.conf" . $ROOT/$CONFDIR/bootcd2disk.conf # read bootcd-run.lib # bootcd-run.lib must be read after bootcd2disk.conf because it needs ERRLOG # bootcd-run.lib must be read before using its functions exp: err if [ -f ./bootcd-run.lib ]; then echo "Using local ./bootcd-run.lib" >&2 . ./bootcd-run.lib elif [ -f $ROOT/usr/share/bootcd/bootcd-run.lib ]; then . $ROOT/usr/share/bootcd/bootcd-run.lib else echo "Error: Mandatory lib bootcd-run.lib not found! ABORT!" exit 1 fi [ "$DEBUG" ] && dbgon for i in $CONFVARS; do [ "`set | grep ^$i=`" ] || err "$i is not set in $ROOT/$CONFDIR/bootcd2disk.conf" done # Overwrite Config with Commandline [ "$IMAGEURLCMD" ] && IMAGEURL="$IMAGEURLCMD" # read bootcd2disk.lib BOOTCD2DISKLIB=./bootcd2disk.lib if [ -f $BOOTCD2DISKLIB ]; then [ "$SCRIPT" ] || echo "Using local $BOOTCD2DISKLIB" >&2 . $BOOTCD2DISKLIB else BOOTCD2DISKLIB=$ROOT/usr/share/bootcd/bootcd2disk.lib if [ -f $BOOTCD2DISKLIB ];then . $BOOTCD2DISKLIB else echo "Error: Mandatory lib $BOOTCD2DISKLIB not found! ABORT!" exit 1 fi fi # useoriginaldisk - sets DISK0,DISK1,... to ORIG_DISK0,ORIG_DISK1,... useoriginaldisk() { if [ "$ORIGINALDISKNAME" ]; then for i in $DISKVARS; do eval "DISK$i=\$ORIG_DISK$i" done fi } getdiskvars # sets DISKVARS check_auto # Has to be checked before setting DISKS check_DISK0 # sets DISKS found on booted system useoriginaldisk # with -o: sets DISK0,DISK1,... to ORIG_DISK0,ORIG_DISK1,... check_SWAP_MD_MOUNT_UMOUNT_VFAT_OPT_FSTAB_PARTITIONLABEL if [ "$ONLYMOUNT" ]; then todo_domount eval "interactive $TODOY -r -h \"=== \$IAHEAD ===\" $TODO" exit $? elif [ "$ONLYUNMOUNT" ]; then todo_dounmount eval "interactive $TODOY -r -h \"=== \$IAHEAD ===\" $TODO" exit $? fi # run functions from bootcd2disk.lib read_thisboot check_kern check_SFDISK0 check_EXT check_GRUB2_GRUB_LILO check_OPT_LVM DO_BEFORE_COPY=$(egrep "^[[:space:]]*(function)*[[:space:]]*before_copy" $ROOT/$CONFDIR/bootcd2disk.conf) DO_AFTER_COPY=$(egrep "^[[:space:]]*(function)*[[:space:]]*after_copy" $ROOT/$CONFDIR/bootcd2disk.conf) # getdata - print without empty lines and comments getdata() { echo "$*" | sed "s/#.*$//" | grep -v "^$" } ### Main ### A="" while [ "$A" != "y" -a "$A" != "n" -a "$SCRIPT" = "" ] do if [ "$CHROOTDIR" ]; then echo "Directory $CHROOTDIR will be deleted and created again! " | tee -a $ERRLOG >&2 [ "$DO_BEFORE_COPY" ] && echo "do_before_copy is defined." | tee -a $ERRLOG >&2 [ "$DO_AFTER_COPY" ] && echo "do_after_copy is defined." | tee -a $ERRLOG >&2 [ "$RESTORECMD" ] && echo "RESTORECMD is defined." | tee -a $ERRLOG >&2 else for i in $DISKVARS; do echo "Harddisk $i ($(eval "echo \"\$DISK$i\"")) will be erased!!!" | tee -a $ERRLOG >&2 done [ "$SWAP" ] && echo "Partition $SWAP will be newly created as SWAP !!!" | tee -a $ERRLOG >&2 [ "$EXT2FS" ] && echo "Partition $EXT2FS will be newly created as ext2 !!!" | tee -a $ERRLOG >&2 [ "$EXT3FS" ] && echo "Partition $EXT3FS will be newly created as ext3 !!!" | tee -a $ERRLOG >&2 [ "$EXT4FS" ] && echo "Partition $EXT4FS will be newly created as ext4 !!!" | tee -a $ERRLOG >&2 [ "$VFAT" ] && echo "Partition $VFAT will be newly created as vfat !!!" | tee -a $ERRLOG >&2 fi echo "(y/n) " | tee -a $ERRLOG >&2 if [ "$SCRIPT" ]; then A="y" else read A # Next line handles EOF from a pipe as (e)xit [ $? -ne 0 ] && A="n" fi echo "$A" >> $ERRLOG done if [ "$A" = "n" ]; then exit 1 fi trap cleanup 2 # zerodsk [ ...] zerodsk() { local DELPV local dsk DELPV="$@" echo "--- Destroy old disk infos $DELPV ---" for dsk in $DELPV; do dd if=/dev/zero of=$dsk bs=1k count=1 conv=notrunc done } lvmreset() { local IAHEAD="$IAHEAD/lvmreset" local TODO="" mm=0 if [ "$LVMGRP" -a "$LVMVOL" ]; then # delete all pvdisplay | grep "PV Name" ALLPV="$(pvdisplay -c 2>/dev/null | sed -n "s|[[:blank:]]*\(/dev/[^:]*\):.*|\1|p")" echo "All physical Volumes ALLPV=<$ALLPV>" >>$ERRLOG for i in $DISKVARS; do # Search for old Partitions on reused disks DELPV="$(echo "$ALLPV" | grep "^$(eval "echo \"\$DISK$i\"")")" # All on one line DELPV="$(echo $DELPV|awk '{printf("%s ",$0)}')" if [ "$(echo "$DELPV" | grep "[[:alnum:]]")" ]; then # Try to use pvremove first (ignore anything, only write to log) mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_ignore $mm ".*" TODO="$TODO \"pvremove -ff -y $DELPV\"" fi # Add the disk itself DELPV="$DELPV $(eval "echo \"\$DISK$i\"")" mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_stdout $mm "^--- .* ---$" in_ignore $mm "^[[:digit:]]\++[[:digit:]]\+ records in$" in_ignore $mm "^[[:digit:]]\++[[:digit:]]\+ records out$" in_ignore $mm "^[[:digit:]]\+ bytes\>.*\" TODO="$TODO \"zerodsk $DELPV\"" done fi eval "interactive $TODOY -r -h \"=== \$IAHEAD ===\" $TODO" } if [ \( ! "$CHROOTDIR" \) -a "$LVMGRP" -a "$LVMVOL" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_norun $mm TODO="$TODO \"lvmreset # deactivate lvm, delete lvm info on disk\"" fi unreadable() { local unreadable="" local err for i in $DISKVARS; do d=$(eval "echo \"\$DISK$i\"") # Sometimes it just takes longer for j in 1 2 3 4 5 6 7; do err="$(sfdisk -R $d 2>&1)" if [ "$(echo "$err" | grep "Device or resource busy")" ]; then if [ $j -eq 7 ]; then echo "$d was not readable ($j); giving up" >&2 unreadable="=== begin output of \"sfdisk -R $d\" === $err === end output of \"sfdisk -R $d\" ===" break 2 else sleep 1 echo "$d was not readable ($j); retrying" >&2 fi else if [ $j -ne 1 ]; then echo "$d is now readable ($j); ok" >&2 fi break fi done done echo "$unreadable" } zerodisk_if_unreadable() { local IAHEAD="$IAHEAD/lvmreset" local TODO="" mm=0 local DELPV="" if [ "$(unreadable)" ]; then for i in $DISKVARS; do DELPV="$(eval "echo \"\$DISK$i\"")" mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_stdout $mm "^--- .* ---$" in_ignore $mm "1+0 records in" in_ignore $mm "1+0 records out" in_ignore $mm "1024 bytes.*copied.*" TODO="$TODO \"zerodsk $DELPV\"" done eval "interactive $TODOY -r -h \"=== \$IAHEAD ===\" $TODO" fi } if [ ! "$CHROOTDIR" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_norun $mm TODO="$TODO \"zerodisk_if_unreadable\"" fi ask_for_reboot() { local err err="$(unreadable)" if [ "$err" ]; then echo "$err" echo "Rereading the partition says \"Device or resource busy\"" echo "The partition tabel is now deleted." echo "After reboot bootcd2disk should work!" echo " ------------------------ " echo "( Press RETURN to reboot )" echo " ------------------------ " read dummy reboot exit fi } if [ ! "$CHROOTDIR" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_norun $mm TODO="$TODO \"ask_for_reboot # (if neccessary)\"" fi partdisk() { local d s o i for i in $DISKVARS; do d=$(eval "echo \"\$DISK$i\"") s=$(eval "echo \"\$SFDISK$i\"") o=$(eval "echo \"\$SFDISKOPTS$i\"") echo "--- Partitioning DISK$i ($d) ---" echo "$s" | sfdisk $o --force -qL -uM $d >/dev/null done # Maybe we have to Reboot now, because of # BLKRRPART: Device or resource busy # The command to re-read the partition table failed # Reboot your system now, before using mkfs # so first do a sync sync } if [ ! "$CHROOTDIR" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_ignore $mm "unrecognized partition table type" in_ignore $mm "^sfdisk: ERROR: sector .* does not have an msdos signature" in_ignore $mm "^No partitions found" in_ignore $mm "^$" in_stdout $mm ".*" TODO="$TODO \"partdisk # partition disks $(for i in $DISKVARS; do echo -n "$(eval "echo \"\$DISK$i\"") "; done; echo "")\"" fi # wait until new device files from sfdisk are available if [ -x /sbin/udevadm ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" TODO="$TODO \"/sbin/udevadm settle\"" fi # We have systems even at this point where reboot was needed # But this should be rarely needed ask_for_reboot2() { local err err="$(unreadable)" if [ "$err" ]; then echo "$err" echo "Rereading the partition after partitioning says \"Device or resource busy\"" echo "The partition tabel is now created as needed." echo "After reboot bootcd2disk should work!" echo " ------------------------ " echo "( Press RETURN to reboot )" echo " ------------------------ " read dummy reboot exit fi } if [ ! "$CHROOTDIR" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_norun $mm TODO="$TODO \"ask_for_reboot2 # (if neccessary)\"" fi mddisk() { local IAHEAD="$IAHEAD/mddisk" local TODO="" mm=0 echo "--- mddisk ---" | tee -a $ERRLOG >&2 # while ... gives a subshell, to set vars we have to eval the set commands eval "$( getdata "$MD" | while read mddev level dsks; do dsks="$(echo "$dsks" |sed "s/mdadm.*//")" cat <<'END' mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_stdout $mm "^--- .* ---$" in_ignore $mm "^[[:digit:]]\++[[:digit:]]\+ records in$" in_ignore $mm "^[[:digit:]]\++[[:digit:]]\+ records out$" in_ignore $mm "^[[:digit:]]\+ bytes\>.*\" END echo "TODO=\"\$TODO \\\"zerodsk $dsks\\\"\"" done getdata "$MD" | while read mddev level dsks; do cmd="$(echo "$dsks"|sed -n "s/.*\(mdadm.*\)/\1/p")" dsks="$(echo "$dsks" |sed "s/mdadm.*//")" nr="$(echo "$dsks"|wc -w)" cat <<'END' mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_ignore $mm "mdadm: array .* started" in_ignore $mm "^mdadm: .* appears to contain an ext2fs file system" in_ignore $mm "^[[:space:]]\+ size=" in_ignore $mm "^mdadm: .* appears to be part of a raid array" in_ignore $mm "^[[:space:]]\+ level=" in_ignore $mm "^Continue creating array?" END if [ "$cmd" ]; then echo "TODO=\"\$TODO \\\"$cmd\\\"\"" else echo "TODO=\"\$TODO \\\"echo y | mdadm --create $mddev --level=$level --raid-devices=$nr --quiet --force $dsks\\\"\"" fi done )" eval "interactive $TODOY -r -h \"=== \$IAHEAD ===\" $TODO" } if [ \( ! "$CHROOTDIR" \) -a "$MD" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_norun $mm TODO="$TODO \"mddisk\"" fi lvm_pvcreate() { local IAHEAD="$IAHEAD/lvm_pvcreate" local TODO="" mm=0 echo "--- pvcreate ---" | tee -a $ERRLOG >&2 # while ... gives a subshell, to set vars we have to eval the set commands eval "$( getdata "$LVMGRP" | sed "s/vgcreate.*//" | while read grp dsks; do for dsk in $dsks; do # After Disk Partitioning, there could be new places with old # LVM Info, so we delete it with pvremove and dd before running pvcreate cat <<'END' mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_ignore $mm ".*" END echo "TODO=\"\$TODO \\\"pvremove -ff -y $dsk\\\"\"" cat <<'END' mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_ignore $mm "WARNING: Forcing physical volume creation on .* of volume group \".*\"" in_ignore $mm "^[[:digit:]]\++[[:digit:]]\+ records in$" in_ignore $mm "^[[:digit:]]\++[[:digit:]]\+ records out$" in_ignore $mm "^[[:digit:]]\+ bytes\>.*\" END echo "TODO=\"\$TODO \\\"dd if=/dev/zero of=$dsk bs=1k count=1 conv=notrunc\\\"\"" cat <<'END' mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_ignore $mm "WARNING: Forcing physical volume creation on .* of volume group \".*\"" in_ignore $mm "Physical volume \".*\" successfully created" in_ignore $mm "Writing physical volume data to disk \".*\"" END echo "TODO=\"\$TODO \\\"pvcreate --quiet -d -ff -y $dsk\\\"\"" done done )" eval "interactive $TODOY -r -h \"=== \$IAHEAD ===\" $TODO" } if [ \( ! "$CHROOTDIR" \) -a "$LVMGRP" -a "$LVMVOL" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_norun $mm TODO="$TODO \"lvm_pvcreate\"" fi lvm_vgcreate() { local IAHEAD="$IAHEAD/lvm_vgcreate" local TODO="" mm=0 echo "--- vgcreate ---" | tee -a $ERRLOG >&2 # while ... gives a subshell, to set vars we have to eval the set commands eval "$( getdata "$LVMGRP" | while read grp dsks; do cmd="$(echo "$dsks"|sed "s/.*\(vgcreate.*\)/\1/"|grep vgcreate)" cat <<'END' mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_ignore $mm "Volume group \".*\" successfully created" END if [ "$cmd" ]; then echo "TODO=\"\$TODO \\\"$cmd\\\"\"" else echo "TODO=\"\$TODO \\\"vgcreate --quiet $grp $dsks\\\"\"" fi cat <<'END' mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_ignore $mm "0 logical volume(s) in volume group \".*\" now active" END echo "TODO=\"\$TODO \\\"vgchange --quiet -aey $grp\\\"\"" done )" eval "interactive $TODOY -r -h \"=== \$IAHEAD ===\" $TODO" } if [ \( ! "$CHROOTDIR" \) -a "$LVMGRP" -a "$LVMVOL" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_norun $mm TODO="$TODO \"lvm_vgcreate\"" fi lvm_lvcreate() { local IAHEAD="$IAHEAD/lvm_lvcreate" local TODO="" mm=0 echo "--- lvcreate ---" | tee -a $ERRLOG >&2 # while ... gives a subshell, to set vars we have to eval the set commands eval "$( getdata "$LVMVOL" | while read vol s grp cmd; do cat <<'END' mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_ignore $mm "Logical volume \".*\" created" in_ignore $mm "/dev/cdrom: open failed: Read-only file system$" in_stdout $mm "Rounding up size to full physical extent" END if [ "$cmd" ]; then echo "TODO=\"\$TODO \\\"$cmd\\\"\"" else echo "TODO=\"\$TODO \\\"lvcreate -n $vol -L $s $grp\\\"\"" fi done )" eval "interactive $TODOY -r -h \"=== \$IAHEAD ===\" $TODO" } if [ \( ! "$CHROOTDIR" \) -a "$LVMGRP" -a "$LVMVOL" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_norun $mm TODO="$TODO \"lvm_lvcreate\"" fi lvm_vgchange() { local IAHEAD="$IAHEAD/lvm_vgchange" local TODO="" mm=0 echo "--- Activate LVM ---" | tee -a $ERRLOG >&2 mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_ignore $mm "Reading all physical volumes. This may take a while..." in_ignore $mm "Found volume group \".*\" using metadata type lvm2" in_ignore $mm "/dev/cdrom: open failed: Read-only file system" in_ignore $mm "Attempt to close device '/dev/cdrom' which is not open." TODO="$TODO \"vgscan --quiet\"" mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_ignore $mm "[1-9][0-9]* logical volume(s) in volume group \".*\" now active" TODO="$TODO \"vgchange --quiet -ay\"" eval "interactive $TODOY -r -h \"=== \$IAHEAD ===\" $TODO" } if [ \( ! "$CHROOTDIR" \) -a "$LVMGRP" -a "$LVMVOL" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_norun $mm TODO="$TODO \"lvm_vgchange\"" fi vfat() { local IAHEAD="$IAHEAD/vfat" local TODO="" mm=0 for i in $VFAT; do echo "--- Building Filesystem $i with mkdosfs ---" | tee -a $ERRLOG >&2 mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_stdout $mm "^mkdosfs " TODO="$TODO \"mkdosfs $i\"" done eval "interactive $TODOY -r -h \"=== \$IAHEAD ===\" $TODO" } if [ \( ! "$CHROOTDIR" \) -a "$VFAT" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_norun $mm TODO="$TODO \"vfat # mkdosfs $VFAT\"" fi extfs() { local IAHEAD="$IAHEAD/extfs" local TODO="" mm=0 l="" for i in $EXT2FS; do l="$(echo "$PARTITIONLABEL" | grep "^$i:" | sed "s|.*:||")" [ "$l" ] && l="-L $l" echo "--- Building Filesystem $i with mke2fs -t ext2 $l ---" | tee -a $ERRLOG >&2 mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_stdout $mm "^mke2fs " TODO="$TODO \"mke2fs -t ext2 $l -q $i\"" done for i in $EXT3FS; do l="$(echo "$PARTITIONLABEL" | grep "^$i:" | sed "s|.*:||")" [ "$l" ] && l="-L $l" echo "--- Building Filesystem $i with mke2fs -t ext3 -j $l ---" | tee -a $ERRLOG >&2 mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_stdout $mm "^mke2fs " TODO="$TODO \"mke2fs -t ext3 -j $l -q $i\"" done for i in $EXT4FS; do l="$(echo "$PARTITIONLABEL" | grep "^$i:" | sed "s|.*:||")" [ "$l" ] && l="-L $l" echo "--- Building Filesystem $i with mke2fs -t ext4 $l ---" | tee -a $ERRLOG >&2 mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_stdout $mm "^mke2fs " TODO="$TODO \"mke2fs -t ext4 $l -q $i\"" done eval "interactive $TODOY -r -h \"=== \$IAHEAD ===\" $TODO" } if [ \( ! "$CHROOTDIR" \) -a "${EXT2FS}${EXT3FS}${EXT4FS}" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_norun $mm TODO="$TODO \"extfs # mke2fs ${EXT2FS}${EXT3FS}${EXT4FS}\"" fi if [ ! "$CHROOTDIR" ]; then todo_domount fi if [ "$CHROOTDIR" -a "$CHROOTDIR" != "/" -a "$CHROOTDIR" != "." ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" TODO="$TODO \"rm -rf $CHROOTDIR\"" mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" TODO="$TODO \"mkdir -p $COPYDEST\"" fi # remove all interfaces from udev persistent rules file # needed if you install on other machines udev_fixnet() { local f for f in \ /etc/udev/rules.d/z25_persistent-net.rules \ /etc/udev/rules.d/70-persistent-net.rules do # if we can find the rules file, and change it sucessfull, we leave # the loop with break and exit this function with return 0, else return 1 [ -e "$f" ] && sed -i "s/^\([^#]\+.*\)/#\1 # disabled by bootcd2disk/" $f && break done return 0 } if [ "$UDEV_FIXNET" = "yes" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" TODO="$TODO udev_fixnet" fi # use image from a image server and copy it to the later swap-partion # the partition must be large enough to hold the whole disk image copyfromserver_before() { # timeout for dns-query and connection timeout (seconds) local timeout=30 local IAHEAD="$IAHEAD/copyfromserver_before" local TODO="" mm=0 local url echo "--- copying image from image server ---" | tee -a $ERRLOG >&2 mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_stdout $mm "^mke2fs " TODO="$TODO \"mke2fs -q $SWAP\"" mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"mkdir -p /tmp/swapfs\"" mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"mount $SWAP /tmp/swapfs\"" if [ "$(echo "$IMAGEURL" | grep "^file://")" ]; then url="$(echo "$IMAGEURL" | sed "s|^file://\(.*\)$|\1|")" if [ -b "$url" ]; then mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_stdout $mm "records in$" in_stdout $mm "records out$" in_stdout $mm "bytes .* copied" TODO="$TODO \"dd if=$url of=/tmp/swapfs/cdimage.iso\"" elif [ -f "$url" ]; then mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"cp $url /tmp/swapfs/cdimage.iso\"" else echo "No file <$url>" | tee -a $ERRLOG >&2 exit 3 fi else mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_stdout $mm "^--[[:digit:]:]*--.*" in_stdout $mm "^[[:space:]]*=> .*" in_stdout $mm "^Resolving .*" in_stdout $mm "^Connecting .*" in_stdout $mm "^Logging .*" in_stdout $mm "^==> SYST .*" in_stdout $mm "^==> TYPE .*" in_stdout $mm "^==> PASV .*" in_stdout $mm "^Length: .*" in_stdout $mm "^[[:space:]]*OK.*" in_stdout $mm "^Length .*" in_stdout $mm "^$" in_stdout $mm "^[[:digit:]:]* .*" in_stdout $mm "^[[:space:]]*[[:digit:]:K]* .*" in_stdout $mm "^HTTP request sent, .* 200 OK[[:space:]]*$" in_stdout $mm "^==> SIZE " in_stdout $mm "^Saving to: ./tmp/swapfs/cdimage.iso.*" in_stdout $mm "^.*/tmp/swapfs/cdimage.iso. saved.*" in_stdout $mm "^--....-..-.. ..:..:..-- $IMAGEURL$" TODO="$TODO \"wget --no-check-certificate --dns-timeout=$timeout --connect-timeout=$timeout -O /tmp/swapfs/cdimage.iso $IMAGEURL\"" fi mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"mkdir -p $ISOLOOPBACK\"" mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_stdout $mm "^mount: warning: /tmp/isoloopback seems to be mounted read-only\.$" TODO="$TODO \"mount -o loop /tmp/swapfs/cdimage.iso $ISOLOOPBACK\"" eval "interactive $TODOY -r -h \"=== \$IAHEAD ===\" $TODO" } if [ "$IMAGEURL" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_norun $mm TODO="$TODO copyfromserver_before" fi do_before_copy() { echo "--- do function before_copy ---" | tee -a $ERRLOG >&2 before_copy } # only call the function, if it is defined if [ "$DO_BEFORE_COPY" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_norun $mm TODO="$TODO \"do_before_copy # run function before_copy defined in bootcd2disk.conf\"" fi handling_udev() { local IAHEAD="$IAHEAD/handling_udev" local TODO="" mm=0 echo "--- handling udev ---" # -- udev -- # The filesystem has static device files in /dev. # But tmpfs is mounted over /dev and hides the static device files. # The static device files are mounted again in /dev/.static/dev/. # This means bootcd has only to copy /dev/.static/dev. mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"cp -a -x /ram1/dev/.static/dev $COPYDEST\"" mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"mkdir -p $COPYDEST/dev/.static\"" mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"chown root:root $COPYDEST/dev/.static\"" mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"chmod 700 $COPYDEST/dev/.static\"" eval "interactive $TODOY -r -h \"=== \$IAHEAD ===\" $TODO" } copycdram() { local IAHEAD="$IAHEAD/copycdram" local TODO="" mm=0 echo "--- copying CD and RAM to $COPYDEST ---" | tee -a $ERRLOG >&2 # Normally $ISOLOOPBACK is / but it could be changed by the functions # copyfromserver_before() or before_copy mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"cd /$ISOLOOPBACK; find . -mount | cpio --quiet -pdum $COPYDEST\"" mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"rm -rf $COPYDEST/rr_moved/ $COPYDEST/isolinux/\"" mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"rm $COPYDEST/usr/bin/bootcd2disk \ $COPYDEST/usr/bin/bootcdflopcp \ $COPYDEST/etc/bootcd/bootcd2disk.conf \ $COPYDEST/etc/bootcd/thisbootcd.conf\"" # restore /etc/securetty mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"cat $COPYDEST/etc/securetty | awk 'BEGIN {cut=0} /added by bootcdwrite BEGIN/ { cut=1 } {if (cut==0) {print}} /added by bootcdwrite END/ {cut=0}' >$COPYDEST/etc/securetty.tmp; mv $COPYDEST/etc/securetty.tmp $COPYDEST/etc/securetty\"" # files that do not always exist mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"rm -f $COPYDEST/usr/bin/bootcdmk2diskconf\"" eval "interactive $TODOY -r -h \"=== \$IAHEAD ===\" $TODO" } if [ ! "$RESTORECMD" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_norun $mm TODO="$TODO \"copycdram # copy cd and ram to $COPYDEST, delete unneeded stuff\"" fi if [ "$RESTORECMD" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_stdout $mm "^star: [[:digit:]]\+ blocks + [[:digit:]]\+ bytes (total of [[:digit:]]\+ bytes = .*)\." TODO="$TODO \"$RESTORECMD\"" fi # configure the swap-partition back to swap give_swappartition_free() { # timeout for dns-query and connection timeout (seconds) local timeout=30 local IAHEAD="$IAHEAD/give_swappartition_free" local TODO="" mm=0 echo "--- copying image from image server ---" | tee -a $ERRLOG >&2 # cleanup again mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_ignore $mm "loop: can.t delete device /dev/loop0" TODO="$TODO \"umount -d $ISOLOOPBACK\"" # free loopdevice # mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" # TODO="$TODO \"losetup -d /dev/loop0\"" # cleanup again mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" TODO="$TODO \"umount /tmp/swapfs\"" # rebuild swap mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_norun $mm TODO="$TODO \"swap\"" eval "interactive $TODOY -r -h \"=== \$IAHEAD ===\" $TODO" } if [ "$IMAGEURL" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_norun $mm TODO="$TODO give_swappartition_free" fi swap() { local IAHEAD="$IAHEAD/swap" local TODO="" mm=0 l="" for i in $SWAP; do l="$(echo "$PARTITIONLABEL" | grep "^$i:" | sed "s|.*:||")" [ "$l" ] && l="-L $l" echo "--- making SWAP $i with mkswap $l ---" | tee -a $ERRLOG >&2 mm=$(($mm+1)); eval local IGNORE${mm}=\"\"; eval local STDOUT${mm}=\"\" in_stdout $mm "^Setting up swapspace" in_stdout $mm "^no label, " in_stdout $mm "^LABEL=" # we need option -f for mkswap on logical volumes, to prevent the warning # mkswap: /dev/mapper/vg_rh6-lv_swap: warning: # don't erase bootbits sectors # on whole disk. Use -f to force. TODO="$TODO \"mkswap -f $l $i\"" done eval "interactive $TODOY -r -h \"=== \$IAHEAD ===\" $TODO" } if [ \( ! "$CHROOTDIR" \) -a "$SWAP" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_norun $mm TODO="$TODO \"swap # mkswap $SWAP\"" fi # The next function is usefull if we run in interactive # mode and want to run chroot for some reason on another tty mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_norun $mm TODO="$TODO \"prepare_chroot $COPYDEST <-i>\"" do_after_copy() { echo "--- do function after_copy ---" after_copy } # only call the function, if it is defined if [ ! -z "$DO_AFTER_COPY" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_norun $mm TODO="$TODO \"do_after_copy # run function after_copy defined in bootcd2disk.conf\"" fi do_fstab() { if [ "$FSTAB" = "unchanged" ]; then echo "--- Will let fstab unchanged ---" else echo "--- Building fstab ---" FSTAB="$(real2uuid "$FSTAB")" dbg FSTAB="<$FSTAB>" echo "$FSTAB" > $COPYDEST/etc/fstab fi } mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_stdout $mm "^--- .* ---$" TODO="$TODO \"do_fstab # create $COPYDEST/etc/fstab\"" bootloadercfg() { local IAHEAD="$IAHEAD/bootloadercfg" local TODO="" mm=0 if [ "$GRUB2" = "unchanged" ]; then dbg GRUB2="<$GRUB2>" echo "--- Will let grub/grub.cfg unchanged ---" | tee -a $ERRLOG >&2 #elif [ "$GRUB2" = "auto" ]; then # mkdir -p $COPYDEST/boot/grub # grub-mkconfig | sed "s|/boot/|/|g" > $COPYDEST/boot/grub/grub.cfg # I do not know how tu use grub-mkconfig. It seems not to support # a separate /boot partition elif [ "$GRUB2" ]; then GRUB2="$(real2uuid "$GRUB2")" dbg GRUB2="<$GRUB2>" echo "--- Building grub/grub.cfg ---" | tee -a $ERRLOG >&2 mkdir -p $COPYDEST/boot/grub echo "$GRUB2" > $COPYDEST/boot/grub/grub.cfg fi if [ "$GRUB" = "unchanged" ]; then dbg GRUB="<$GRUB>" echo "--- Will let grub/menu.lst unchanged ---" | tee -a $ERRLOG >&2 elif [ "$GRUB" ]; then GRUB="$(real2uuid "$GRUB")" dbg GRUB="<$GRUB>" echo "--- Building grub/menu.lst ---" | tee -a $ERRLOG >&2 mkdir -p $COPYDEST/boot/grub echo "$GRUB" > $COPYDEST/boot/grub/menu.lst fi if [ "$LILO" = "unchanged" ]; then echo "--- Will let lilo.conf unchanged ---" | tee -a $ERRLOG >&2 elif [ "$LILO" ]; then echo "--- Building lilo.conf ---" | tee -a $ERRLOG >&2 echo "$LILO" > $COPYDEST/etc/lilo.conf fi } mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_stdout $mm "^--- .* ---$" in_stdout $mm "^Generating grub.cfg" in_stdout $mm "^Found linux image" in_stdout $mm "^Found initrd image" in_stdout $mm "^done$" TODO="$TODO bootloadercfg" createsshkeys() { if [ "$SSHHOSTKEY" = "unchanged" ]; then echo "--- Will let ssh keys unchanged ---" | tee -a $ERRLOG >&2 elif [ "$SSHHOSTKEY" = "yes" ]; then # each installed PC gets a unique hostkey (only if hostkey already existed) TODO="$TODO \"create_host_keys $COPYDEST/etc/ssh\"" elif [ "$SSHHOSTKEY" != "no" ]; then echo 'SSHHOSTKEY is not defined as "yes" or "no".' \ 'It will be treated as "no".' fi } mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_stdout $mm "^--- .* ---$" TODO="$TODO createsshkeys" enablecron() { echo "--- Enabling turned off stuff ---" | tee -a $ERRLOG >&2 for f in $DISABLE_CRON; do if [ -f $COPYDEST/$f.no_run_on_bootcd ]; then rm $COPYDEST/$f mv $COPYDEST/$f.no_run_on_bootcd $COPYDEST/$f fi done } if [ ! "$RESTORECMD" ]; then if [ "$DISABLE_CRON" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_stdout $mm "^--- .* ---$" TODO="$TODO enablecron" fi fi dogrub2() { [ -z "$GRUBBOOTDIR" ] && GRUBBOOTDIR=0 [ -z "$GRUBBOOTDISK" ] && GRUBBOOTDISK="hd0" if [ "$GRUBDEVICEMAP" = "auto" -o "$GRUBDEVICEMAP" = "" ]; then # Automatic handling. rm -f $COPYDEST/boot/grub/device.map grub-mkdevicemap -m $COPYDEST/boot/grub/device.map elif [ "$GRUBDEVICEMAP" = "no" ]; then # Do nothing. # We do not change device.map # This should work if a bootcd is installed on the original hardware : elif [ "$GRUBDEVICEMAP" ]; then # We explicit set a value to device.map # This is needed if nothing else helps echo "$GRUBDEVICEMAP" > $COPYDEST/boot/grub/device.map fi #grub-install --root-directory=$COPYDEST --force --no-floppy "($GRUBBOOTDISK)" chroot $COPYDEST grub-install --force --no-floppy "($GRUBBOOTDISK)" } if [ \( ! "$CHROOTDIR" \) -a "$GRUB2" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" # To much text in_stdout $mm ".*" TODO="$TODO \"dogrub2 # ($GRUBBOOTDISK)\"" fi dogrub1_chroot() { echo "--- Running grub1 chroot ---" | tee -a $ERRLOG >&2 [ -z "$GRUBBOOTDIR" ] && GRUBBOOTDIR=0 [ -z "$GRUBBOOTDISK" ] && GRUBBOOTDISK="hd0" if [ "$GRUBDEVICEMAP" = "auto" -o "$GRUBDEVICEMAP" = "" ]; then # Automatic handling. rm -f $COPYDEST/boot/grub/device.map # grub-mkdevicemap does not work always # grub-mkdevicemap -m $COPYDEST/boot/grub/device.map elif [ "$GRUBDEVICEMAP" = "no" ]; then # Do nothing. # We do not change device.map # This should work if a bootcd is installed on the original hardware : elif [ "$GRUBDEVICEMAP" ]; then # We explicit set a value to device.map # This is needed if nothing else helps echo "$GRUBDEVICEMAP" > $COPYDEST/boot/grub/device.map fi chroot $COPYDEST grub-install --no-floppy "($GRUBBOOTDISK)" } prepare_grub_stage_files() { echo "--- Preparing grub stage files ---" | tee -a $ERRLOG >&2 # We need the corresponding grub files of the running kernel # This files should already be installed, but may not work with the # bootcd kernel when restoring a system backed up with bootcdbackupwizard. # On a restored system the original files can normally be installed again, # with grub-install. # if [ ! -d $COPYDEST/boot/grub.tmp ]; then # mkdir $COPYDEST/boot/grub.tmp # mv $COPYDEST/boot/grub/stage1 $COPYDEST/boot/grub/stage2 \ # $COPYDEST/boot/grub/*stage1_5 $COPYDEST/boot/grub.tmp cp /usr/lib/grub/*/stage1 /usr/lib/grub/*/stage2 \ /usr/lib/grub/*/*stage1_5 $COPYDEST/boot/grub/ # fi } dogrub1_manual() { [ -z "$GRUBBOOTDIR" ] && GRUBBOOTDIR=0 [ -z "$GRUBBOOTDISK" ] && GRUBBOOTDISK="hd0" # grub-install (the next 12 commandlines) is no longer used. # # Most of the time the command did not return 0 and so grub was used directly # anyway. # But now I got bug reports, that grub-install did not work, but returned 0. # This resulted in an unbootable installation, because in this case grub was # not used directy. # #echo "--- Running grub-install ---" | tee -a $ERRLOG >&2 #grub-install --no-floppy --root-directory=$COPYDEST $GRUBBOOTDISK # #if [ $? -eq 0 ]; then # return 0 #fi #echo "--- grub-install did not work trying option --recheck ---"| tee -a $ERRLOG >&2 #grub-install --recheck --no-floppy --root-directory=$COPYDEST $GRUBBOOTDISK # #if [ $? -eq 0 ]; then # return 0 #fi if [ "$GRUBDEVICEMAP" = "auto" -o "$GRUBDEVICEMAP" = "" ]; then # Automatic handling. # We delete device.map. So it will then be auto-created by grub. # This should work on different target hardware rm -f $COPYDEST/boot/grub/device.map elif [ "$GRUBDEVICEMAP" = "no" ]; then # Do nothing. # We do not change device.map # This should work if a bootcd is installed on the original hardware : elif [ "$GRUBDEVICEMAP" ]; then # We explicit set a value to device.map # This is needed if nothing else helps echo "$GRUBDEVICEMAP" > $COPYDEST/boot/grub/device.map fi echo "--- Running grub1 manual ---" | tee -a $ERRLOG >&2 ( for i in $GRUBBOOTDISK; do echo "root ($i,$GRUBBOOTDIR) setup ($i)" done echo "quit" ) | grub --no-floppy --batch --device-map=$COPYDEST/boot/grub/device.map } # Do not restore grub_stage_files. # Grub needs this files to boot. This Problem may not be seen # immediately, because the files may be on disk for a long time. # The "restore" will be done when grub-install runs on the # new system, with files from /usr/lib/grub/... #restore_grub_stage_files() #{ # rm $COPYDEST/boot/grub/stage1 $COPYDEST/boot/grub/stage2 \ # $COPYDEST/boot/grub/*stage1_5 # mv $COPYDEST/boot/grub.tmp/* $COPYDEST/boot/grub # rmdir $COPYDEST/boot/grub.tmp #} #if [ \( ! "$CHROOTDIR" \) -a "$GRUB" ]; then # mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" # # To many text # in_stdout $mm ".*" # TODO="$TODO \"restore_grub_stage_files\"" #fi dogrub1() { dogrub1_chroot g1_cr_err=$? if [ $g1_cr_err -ne 0 ]; then echo "--- Retry manual ---" | tee -a $ERRLOG >&2 prepare_grub_stage_files dogrub1_manual fi } if [ \( ! "$CHROOTDIR" \) -a "$GRUB" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" # To many text in_stdout $mm ".*" TODO="$TODO \"dogrub1 # root ($GRUBBOOTDISK,$GRUBBOOTDIR)\"" fi dolilo() { echo "--- Running lilo ---" | tee -a $ERRLOG >&2 chroot $COPYDEST lilo -w } if [ \( ! "$CHROOTDIR" \) -a "$LILO" ]; then mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_stdout $mm "^Added " in_stdout $mm "^--- .* ---$" TODO="$TODO dolilo" fi check_selinux() { if [ -f $COPYDEST/etc/selinux/config ]; then dbg "found $COPYDEST/etc/selinux/config" if [ "$(grep "^SELINUX=enforcing[[:space:]]*$" $COPYDEST/etc/selinux/config)" ]; then sed -i "s/^SELINUX=enforcing[[:space:]]*$/SELINUX=permissive/" $COPYDEST/etc/selinux/config echo "SELINUX set from enforcing to permissive" echo "(please turn back after first boot in /etc/selinux/config)" fi else dbg "no file $COPYDEST/etc/selinux/config" fi } mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_stdout $mm "^DEBUG " TODO="$TODO check_selinux" mm=$(($mm+1)); eval IGNORE${mm}=\"\"; eval STDOUT${mm}=\"\" in_norun $mm TODO="$TODO \"unprepare_chroot $COPYDEST <-i>\"" if [ ! "$CHROOTDIR" ]; then todo_dounmount fi eval "interactive $TODOY -r -h \"=== \$IAHEAD ===\" $TODO" echo "Please Reboot now !" | tee -a $ERRLOG >&2 bootcd-4.04/isolinux.cfg0000644000000000000000000000004210131513667012133 0ustar default linux timeout 50 prompt 1 bootcd-4.04/bootcdinitramfshook0000755000000000000000000000414612006721744013607 0ustar #!/bin/sh # See manpage initramfs-tools(8) . /usr/share/initramfs-tools/hook-functions PREREQ="" prereqs() { echo "$PREREQ" } case $1 in prereqs) prereqs exit 0 ;; esac printbin() { if [ -f /sbin/discover ]; then echo "/sbin/discover" elif [ -f /bin/discover ]; then echo "/bin/discover" elif [ -f /usr/bin/discover ]; then echo "/usr/bin/discover"; fi ls /bin/grep ls /usr/share/discover/*.lst 2>/dev/null ls /usr/share/bootcd/bootcdmodprobe 2>/dev/null # see prerm ls /usr/share/bootcd/bootcdproberoot 2>/dev/null # see prerm ls $MODULESDIR/kernel/drivers/usb/host/*.*o 2>/dev/null # match *.o and *.ko ls $MODULESDIR/kernel/drivers/usb/core/usbcore.*o 2>/dev/null # used for 2.6 ls $MODULESDIR/kernel/drivers/usb/usbcore.*o 2>/dev/null # used for 2.4 ls $MODULESDIR/kernel/drivers/usb/storage/usb-storage.*o 2>/dev/null ls $MODULESDIR/kernel/drivers/cdrom/cdrom.*o 2>/dev/null ls $MODULESDIR/kernel/drivers/scsi/scsi_mod.*o 2>/dev/null ls $MODULESDIR/kernel/drivers/scsi/sr_mod.*o 2>/dev/null ls $MODULESDIR/kernel/fs/nls/*.*o 2>/dev/null ls $MODULESDIR/kernel/fs/aufs/aufs.ko 2>/dev/null # extra data for discover 2 for i in libdiscover2 discover-data discover; do [ -f /var/lib/dpkg/info/$i.list ] || continue ( cat /var/lib/dpkg/info/$i.list | grep -v "^/usr/share/doc" | # no docu grep -v "^/usr/share/man" | # no manpages grep -v "^/lib/" | grep -v "^/usr/lib/" | grep -v "^/bin/" | # goes to exe if needed grep -v "^/usr/bin/" | # goes to exe if needed grep -v "^/sbin/" | # goes to exe if needed grep -v "^/usr/sbin/" # goes to exe if needed cat /var/lib/dpkg/info/$i.list | grep "/lib/discover/" # we need discover xml data ) | while read f; do [ -d $f ] && continue # no dirs echo "$f" done done } # Begin real processing below this line manual_add_modules isofs manual_add_modules cdrom manual_add_modules aufs for i in $(printbin); do if [ ! -e $DESTDIR/$i ]; then mkdir -p $DESTDIR/$(dirname $i) copy_exec $i $i fi done bootcd-4.04/bootcdflopcp.10000644000000000000000000000345310611135414012342 0ustar .TH BOOTCD 1 "Wed Feb 23 00:00:00 EET 2000" "" "bootcd utils" .SH NAME bootcdflopcp \- copy changes made after booting from bootcd to floppy .SH SYNOPSIS .\" The general command line .B bootcdflopcp [-v] [-d ] .SH DESCRIPTION .B bootcdflopcp will copy changes made in ram to the floppy disk. .B bootcdflopcp will be available as soon as your system is running from cd. The floppy has to have a filesystem already. (See mke2fs or mformat). If you have to boot from floppy, because your cd-drive or bios does not support to boot from cd a msdos filesystem is used to run syslinux. When .B bootcdflopcp is called it searches for differences between RAM and CD. For each different file, it checks if it is listed in the files ignore, remove or change on floppy. If it is listed in change it will be saved to change.tgz on floppy. If it is listed in remove the file will be removed from ram next boot time. If it is listed in ignore it will be ignored. If it is not listed at all you will be interactively asked what to do. .SH OPTIONS .IP "\fB\-v\fR" 4 .IX Item "-v" The option "\fB\-v\fR" (verbose) adds messages on running. .IP "\fB\-d \fR" 4 .IX Item "-d " Use another device instead of "/dev/fd0" to save changes. .SH FILES .TP .I FLOPPY:/remove If a file is listed here the file will be deleted from ram next boot time. .TP .I FLOPPY:/change If a file is listed here bootcdflopcp will save it in change.tgz. .TP .I FLOPPY:/ignore If a file is listed here bootcdflopcp will ignore changes to this file. .TP .I FLOPPY:/change.tgz Here all changed files are stored in gzipped tar format. .SH "SEE ALSO" bootcd(1), bootcd2disk(1), bootcdwrite(1) .SH AUTHOR This manual page was written by Bernd Schumacher , for the Debian GNU/Linux system (but may be used by others). bootcd-4.04/bootcd2disk.10000644000000000000000000000522011062413051012062 0ustar .IX Title "boocd2disk" .TH BOOTCD2DISK 1 "2007-04-04" "bootcd2disk" "bootcd utils" .SH NAME bootcd2disk \- copy a system running from bootcd to a disk .SH SYNOPSIS .\" The general command line .B bootcd2disk [-i] [-s] [-c ] [-url ] .SH DESCRIPTION With .B bootcd2disk a CD build with bootcdwrite can be copied to one or more .I Disk Partitions from the running cd-based system. Therefore .I bootcd could be used to make rescue disks. .PP It is also possible to let .B bootcd2disk automatically find a disk, make partitions on it, copy the cd to the disk and make the disk bootable. .B bootcd2disk will be available as soon as your system is running from cd. .SH OPTIONS .IX Header "OPTIONS" .IP "\fB\-i\fR" 4 .IX Item "i" With this option the complete bootcd2disk runs in interactive mode and you can run each function manually. This option is useful for debugging. .IP "\fB\-v\fR" 4 .IX Item "-v" The option "\fB\-v\fR" (verbose) adds messages on running. .IP "\fB\-s\fR" 4 .IX Item "-s" This option can be used to disable interactive questions and to try to ignore errors. .IP "\fB\-c \fR" 4 .IX Item "-c " The configuration directory which normally is "/etc/bootcd" can be changed with this. .IP "\fB\-url \fR" 4 .IX Item "-url " If bootcd2disk is slow on your system (because of a slow CD/DVD drive or the HP ILO virtual CD interface), you can use an image server to get the image from. .B bootcd2disk use the SWAP partition of your upcoming system as temporary space and copy the image from the configured image server to this partition and use it as image. The image server url is configured with this option. .RS 4 .IP "\fBexample install from imagesserver:\fR" 4 bootcd2disk \-url http://192.168.1.1/cdimage.iso .PP Another way the increase the performance is the use of the mounted CD/DVD itself for the copy. The option "\-url" is the same, the url starts with "file:///" .IP "\fBexample install from CD/DVD drive sdc0:\fR" 4 bootcd2disk \-url file:///dev/sdc0 .PP The swap partition of the upcoming system must have enough space to get the whole image! .PP .RE Currently no other options can be specified on command line. All other configuration has to be done in the config files. .SH FILES .TP .I /etc/bootcd/bootcd2disk.conf .PP Configuration for bootcd2disk. .SH "SEE ALSO" Documentation in bootcd2disk.conf .br bootcd2disk.conf(5), bootcd(1), bootcdflopcp(1), bootcdwrite(1) .SH AUTHOR This manual page was written by Bernd Schumacher <\fIbernd.schumacher@hp.com\fR> and Carsten Dinkelmann <\fICarsten.Dinkelmann@foobar-cpa.de\fR> for the Debian GNU/Linux system (but may be used by others). bootcd-4.04/bootcdwrite0000755000000000000000000005612012247056070012063 0ustar #!/bin/sh # # $Source: /home/bs/src/bootcd/backupcvs/bootcd/bootcd/bootcdwrite,v $ # $Id: bootcdwrite,v 1.83 2011-03-03 15:38:33 bs Exp $ # author: Bernd Schumacher # start: long time ago # topic: build cd image # # chng_opts() { O="$(echo " $1 " | sed "s/[[:blank:]]\+/ /g")" C="$(echo " $2 " | sed "s/[[:blank:]]\+/ /g")" CNOT="$(echo "$C" | sed -e "s/!//g" -e "s/ [^ -]\+//g" -e "s/^ //" -e "s/ $//")" CADD="$(echo "$C"| sed -e "s/ ![^ ]\+//g" -e "s/^ //" -e "s/ $//")" # echo "DEBUG O=<$O>" >&2 # echo "DEBUG C=<$C>" >&2 # echo "DEBUG CNOT=<$CNOT>" >&2 # echo "DEBUG CADD=<$CADD>" >&2 for i in $CNOT; do # echo "DEBUG i=<$i>" >&2 O="$(echo "$O" | sed "s/ $i [^-]*/ /g")" # echo "DEBUG O=<$O>" >&2 done O="$(echo "$O"| sed -e "s/^ //" -e "s/ $//")" # echo "DEBUG O=<$O>" >&2 echo "$O $CADD" } #echo "test: chng_opts \"-one -two 2 -three drei -four\" \"!-three !-one -two -five 5\"" >&2 #echo "expect: -four -two -five 5" >&2 #echo "result: $(chng_opts "-one -two 2 -three drei -four" "!-three !-one -two -five 5")" >&2 #echo "test: chng_opts \"--one --two 7 --three 8\" \"--three 9\"" #echo "result: $(chng_opts "--one --two 7 --three 8" "--three 9")" #echo "test: chng_opts \"-a -b\" \"\"" #echo "result: $(chng_opts "-a -b" "")" #exit 0 isoneword() { [ $# -eq 1 ] && return 0 return 1 } #for i in "a b" "a" "a #b"; do #if isoneword "$i"; then echo "<$i> ok"; else echo "<$i> nok"; fi #done #exit 1 cleanup() { echo "--- Cleanup ---" | tee -a $ERRLOG # Be sure that VAR and SRCDISK have no spaces # to not accidently remove anything (for example VAR="/ /var") if ! isoneword "$VAR"; then echo "Error in VAR <$VAR>" >&2 exit 1 fi if ! isoneword "$SRCDISK"; then echo "Error in SRCDISK <$SRCDISK>" >&2 exit 1 fi rm -f "$VAR/cdimage" rm -rf "$VAR/input_dir" rm -rf "$VAR/compressed_dir" umount "$VAR/mnt" 2>/dev/null [ -d $VAR/mnt ] && rmdir "$VAR/mnt" # do not use "rm -r $VAR" rm -f "$ERRLOG.tmp" rm -rf "$CHANGES" [ -d $VAR -a ! -f $VAR/cdimage.iso ] && rmdir "$VAR" } oneline() { if [ $# -gt 0 ]; then echo "$*" else cat fi | awk '{printf("%s ",$1)} END {printf("\n")}' | sed "s/ *$//" } # df_file - How much free space has the filesystem on which file $1 resides ? df_file() { df -k -P | awk '{printf("%s %s\n",$4,$6)}' | while read size filesys do if [ "`echo $1 | grep ^$filesys`" ]; then namelen=`echo $filesys | wc -c` echo "$namelen $filesys $size" fi done | sort -n | tail -1 | awk '{print $3}' } #df_file /home/bianca/daten #exit 0 # ex_proc - exclude SRCDI/proc # - exclude SRCDI/sys (kernel 2.6.x) ex_proc() { if [ $# -gt 0 ]; then for i in $*; do if [ "$(realpath $i)" = "$SRCDISK" ]; then find $SRCDISK -maxdepth 1 | grep -v -e "^$SRCDISK$" -e "^$SRCDI/proc$" -e "^$SRCDI/sys$" -e "^$SRCDI/run$" else realpath $i fi done | oneline fi } #SRCDISK="/"; SRCDI="" #echo "SRCDISK=/; ex_proc / -> /home /etc /bin ... (without /proc and /sys)" #ex_proc / #echo "SRCDISK=/; ex_proc /tmp /etc -> /tmp /etc" #ex_proc /tmp /etc #exit 0 # du_dir - How much space do given dirs need togehter du_dir() { if [ $# -gt 0 ]; then LIST1="$(for i in $(realpath $*); do echo $i; done | sort)" LAST=""; LIST2="" for i in $LIST1; do if [ "$LAST" ]; then if [ "$LAST" = "/" ]; then [ "$(echo "$i" | grep "^/")" ] && i="" else [ "$(echo "$i" | grep "^$LAST\>")" ] && i="" fi fi if [ "$i" ]; then LIST2="$LIST2 $i" LAST="$i" fi done LIST3=$(ex_proc "$LIST2") echo "du -klsc $LIST3" >> $ERRLOG du -klsc $LIST3 | tee -a $ERRLOG | tail -1 | awk '{print $1}' fi } #ERRLOG=/var/log/errlog #echo "du_dir /etc; du_dir /tmp; du_dir /etc /tmp -> A + B = C" #du_dir /etc; du_dir /tmp; du_dir /etc /tmp #exit 0 #echo "du_dir /etc; du_dir /etc /etc/network -> A = B" #du_dir /etc; du_dir /etc /etc/network #exit 0 trapfunc() { echo "trap" >> $ERRLOG trap "" 0 2 # Ignore Traps cleanup exit 1 } mk_grep() { if [ $# -gt 0 ]; then echo "$*" | sed 's/\(^\| \)*\([^ ]*\)/-e ^\2 /g' | # Insert all "-e" sed "s/[[:space:]]*$//" | # Delete trailing spaces sed "s/^/grep -v /" # Insert "grep -v" else echo "cat" fi } #echo "mk_grep /usr/lib /usr/share -> grep -v -e ^/usr/lib\> -e ^/usr/share\>" #echo "<$(mk_grep /usr/lib /usr/share)>" #echo "mk_grep "" -> cat" #echo "<$(mk_grep "")>" #exit 0 # #t=$(mk_grep /x) #echo "t=<$t>" #echo "a/x/b: $(echo "a/x/b" | $t)" #echo "/xb: $(echo "/xb" | $t)" #echo "/x/b: $(echo "/xb" | $t)" #exit 0 # chnglist [-add_ro] [-no_mnt] # -add_ro = add ".ro" to directory following # -no_mnt = path without # -rel = start without / chnglist() { ADD_RO="" NO_MNT="" REL="" OPT="1" while [ "$OPT" ]; do if [ "$1" = "-no_mnt" ]; then NO_MNT="1" shift elif [ "$1" = "-add_ro" ]; then ADD_RO="1" shift elif [ "$1" = "-rel" ]; then REL="1" shift else OPT="" fi done [ $# -ne 2 ] && err "Internal Error calling Function chnglist" S="$(echo "$1" | sed "s|/\+|/|g")" # change // to / [ "$S" = "/" ] && S="" echo " $2" | sed "s|/\+|/|g" | # change // to / if [ "$ADD_RO" ]; then if [ "$NO_MNT" ]; then sed "s|[[:space:]]$S/\([^/]*\)\>| \1.ro|g" | sed "s/[[:space:]]*//" else sed "s|[[:space:]]$S\(/[^/]*\)\>| $S\1.ro|g" | sed "s/[[:space:]]*//" fi else if [ "$NO_MNT" ]; then sed "s|[[:space:]]$S/\([^/]*\)\>| \1|g" else cat fi fi | sed 's|[^[:graph:]]/\+\([[:graph:]]\+\)| \1|g' | # without leading / if [ "$REL" ]; then cat else sed 's|\([[:graph:]]\+\)|/\1|g' fi | sed "s/[[:space:]]*//" | # remove leading space sed "s|/\+|/|g" # change // to / } #echo 'chnglist -add_ro "/" "/etc/a /etc/b /root" -> /etc.ro/a /etc/.ro/b /root.ro' #echo " <$(chnglist -add_ro "/" "/etc/a /etc/b /root")>" #echo 'chnglist -add_ro "/mnt" "/mnt/etc/a /mnt/root" -> /mnt/etc.ro/a /mnt/root.ro' #echo " <$(chnglist -add_ro "/mnt" "/mnt/etc/a /mnt/root")>" #echo 'chnglist -add_ro -no_mnt "/" "/home/a /root" -> /home.ro/a /root.ro' #echo " <$(chnglist -add_ro -no_mnt "/" "/home/a /root")>" #echo 'chnglist -add_ro -no_mnt "/mnt" "/mnt/home/b /mnt/root" -> /home.ro/b /root.ro' #echo " <$(chnglist -add_ro -no_mnt "/mnt" "/mnt/home/b /mnt/root")>" #echo 'chnglist -no_mnt "/" "/etc/a ///etc/b /root" -> /etc/a /etc/b /root' #echo " <$(chnglist -no_mnt "/" "/etc/a ///etc/b /root")>" #echo 'chnglist -no_mnt "/mnt" "/mnt/etc/a /mnt/root" -> /etc/a /root' #echo " <$(chnglist -no_mnt "/mnt" "/mnt/etc/a /mnt/root")>" #echo 'chnglist -rel -no_mnt "/" "/etc/a /etc/b /root" -> etc/a etc/b root' #echo " <$(chnglist -rel -no_mnt "/" "/etc/a /etc/b /root")>" #echo 'chnglist -no_mnt -rel "/mnt" "/mnt/etc/a /mnt/root" -> etc/a root' #echo " <$(chnglist -no_mnt -rel "/mnt" "/mnt/etc/a /mnt/root")>" #echo 'chnglist -add_ro "/////" "/etc/a /////etc/b /root" -> /etc.ro/a /etc/.ro/b /root.ro' #echo " <$(chnglist -add_ro "/////" "/etc/a /////etc/b /root")>" #exit 0 # function: do_isolinux -- configure isolinux bootloader do_isolinux() { local kname="" local initrd="" local append="" local infofile="kinfo.txt" local ctrlL=" " local blue="09" local green="0a" local yellow="0e" local white="0f" local back="07" local graphics="" local text="" local version="" run mkdir /$CHANGES/isolinux run cp /usr/lib/syslinux/isolinux.bin /$CHANGES/isolinux # copy isolinux configuration run cp $CONFDIR/isolinux.cfg $CHANGES/isolinux/isolinux.cfg cat </$CHANGES/isolinux/$infofile ${ctrlL} ${yellow} Informations about the available kernels: -----------------------------------------${back} END # copy all kernels # we must change the name, because isolinux does name mangling for # the dos 8.3 filename format !!!! for i in "" $(set | sed -n "s/^KERNEL\([[:digit:]]\+\)=.*/\1/p"); do [ ! "$(eval echo \$KERNEL$i 2>/dev/null)" ] && continue [ ! -e "$(eval echo \$KERNEL$i)" ] && err "Can't find kernel \"$(eval echo \$KERNEL$i)\" !" echo "add kernel $(eval echo \$KERNEL$i)" >>$ERRLOG run cp $(eval echo \$KERNEL$i) /$CHANGES/isolinux/vmlinuz$i initrd="" if [ "$(eval echo \$INITRD$i 2>/dev/null)" ]; then [ ! -e "$(eval echo \$INITRD$i)" ] && err "Can't find initrd \"$(eval echo \$INITRD$i)\" !" run cp $(eval echo \$INITRD$i) /$CHANGES/isolinux/initrd$i initrd="initrd=/isolinux/initrd$i" fi klabel=$(eval echo linux$i) [ "$(eval echo \$KLABEL$i 2>/dev/null)" ] && klabel=$(eval echo \$KLABEL$i) append="" [ "$(eval echo \$APPEND$i 2>/dev/null)" ] && append=$(eval echo \$APPEND$i) cat <>/$CHANGES/isolinux/isolinux.cfg # KERNEL$i: $(eval echo \$KERNEL$i) $(eval echo \$INITRD$i) label $klabel kernel /isolinux/vmlinuz$i append $initrd root=$CDDEV1 bootcd=$BOOTCDMODPROBE $append END cat <>/$CHANGES/isolinux/$infofile Pressing ${white}${back} or Entering ${white}$klabel${back} uses kernel ${white}$(eval basename \$KERNEL$i)${back} and expands to: /isolinux/vmlinuz initrd=/isolinux/initrd root=auto bootcd=$BOOTCDMODPROBE $APPEND END done # only for the first kernel for i in $CDDEVR; do # KERNEL$i echo "label $(basename $i)" echo " kernel /isolinux/vmlinuz" [ "$INITRD" ] && echo " append initrd=/isolinux/initrd root=$i bootcd=$BOOTCDMODPROBE $APPEND" done >>$CHANGES/isolinux/isolinux.cfg add_display add_credits } # function: add_display -- add display text and help add_display() { local addhelp="" local ctrlL=" " local white="0f" local back="07" # configure help pages for the boot prompt if [ "$DISPLAY" ]; then cat <>/$CHANGES/isolinux/isolinux.cfg # display config display display.txt F0 credits.txt F1 display.txt END for i in $(seq 2 9); do [ ! "$(eval echo \$DISPLAY$i 2>/dev/null)" ] && continue if [ "$(eval echo \$DISPLAY$i)" = "kernelinfo" ]; then echo "F${i} $infofile" >>/$CHANGES/isolinux/isolinux.cfg addhelp="yes" continue fi [ ! -e "$(eval echo \$DISPLAY$i)" ] && err "Can't find file \"$(eval echo \$DISPLAY$i)\"" run cp $(eval echo \$DISPLAY$i) /$CHANGES/isolinux/display$i echo "F${i} display${i}" >>/$CHANGES/isolinux/isolinux.cfg addhelp="yes" done # add display file ( [ "$addhelp" ] && echo "${ctrlL}${white}Use function keys F1-F10 to get informations!${back}" echo "" cat $DISPLAY ) >/$CHANGES/isolinux/display.txt fi } # function: add_credits -- add the credit file to isolinux add_credits() { local ctrlL=" " local blue="09" local green="0a" local yellow="0e" local white="0f" local back="07" local graphics="" local text="" local version="" local creditfile=/$CHANGES/isolinux/credits.txt version=$(dpkg-query -W -f='${Version}' bootcd 2>/dev/null) [ ! "$version" ] && version=$(zcat /usr/share/doc/bootcd/changelog.gz |head -1 2>/dev/null |sed -e "s|.*(\(.*\)).*|\1|") # create credits file # ${graphics}tt.lss cat <> $creditfile ${ctrlL} ${yellow} bootcd version ${version}${back} ${white} Thanks to all developers and testers for usefull hints (see changelog.gz): ${back} END # add all users if [ -e "/usr/share/doc/bootcd/changelog.gz" ]; then echo $(count=1; a=""; zcat /usr/share/doc/bootcd/changelog.gz | sed -ne "s|.*[[:space:]]\+\([^[:space:]]\+\)[[:space:]]\+\([^[:space:]]\+\)[[:space:]]*\(.*<.*@.*>\).*|\1 \2 \3|p" | sort | while read i; do if [ "$a" = "" ]; then a=$i continue; fi if [ "$(echo $i| cut -d" " -f2)" = "$(echo $a| cut -d" " -f2)" ]; then count=$(expr $count + 1); else echo "$count $a"; count=1; a=$i; fi done | sort -n -r | head -50 | sed -e "s|\([^[:space:]]*\)[[:space:]]*\(.*\)|\2(\1);|") >> $creditfile else echo "Bernd Schumacher " >> $creditfile fi echo "" >> $creditfile } # function: compress_dir -- compress files compress_dir() { # if $EXCLUDE and $MKISOFS equals -x /home/bs # then ZFTREEX will become: -e "s|\x00/home/bs\>[^\x00]*||g" if [ "$EXCLUDE" -o "$MKISO_NOT" ]; then ZFTREEEX="$(echo $EXCLUDE $MKISO_NOT | sed "s|-x[[:space:]]\+\([^[:space:]]\+\)|-e \"s\|\\\\x00\1\\\\>[^\\\\x00]*\|\|g\"|g")" fi echo "--- Building input_dir for compression ---" | tee -a $ERRLOG # ignore output, if we try to link instead copy, to save disk space, # but it does not work most of the time ignore "^cpio: cannot link .* to .*: Invalid cross-device link$" stdout "^cpio: File selinux/poicy grew" run "cd $SRCDISK; rm -rf $VAR/input_dir; mkdir $VAR/input_dir; find $(ex_proc $SRCDISK) -print0 | sed -e \"s|^|\\x00|\" | # all files do start and end with \x00 now sed -e \"s|\\x00$VAR[^\\x00]*||g\" | sed -e \"s|\\x00$ERRLOG[^\\x00]*||g\" | sed -e \"s|\\x00$SRCDI/tmp[^\\x00]*||g\" $ZFTREEEX | sed -e \"s|\\x00$SRCDI/|\\x00|g\" | sed -e \"s|^\\x00||\" | # first file does not start with \x00 now cpio --null --quiet -pldum $VAR/input_dir/" run "cd $CHANGES; find . -print0 | cpio --null --quiet -pldum $VAR/input_dir/" # save files that should not be compressed for i in $*; do run "mkdir -p $VAR/nocompress_dir/$(dirname $i)" run "mv $VAR/input_dir/$i $VAR/nocompress_dir/$i" done # compress files echo "--- Compressing input_dir to compressed_dir ---" | tee -a $ERRLOG run "rm -rf $VAR/compressed_dir; mkzftree $VAR/input_dir $VAR/compressed_dir" # copy not compressed files for i in $*; do run "mv $VAR/nocompress_dir/$i $VAR/compressed_dir/$i" done run rm -rf $VAR/nocompress_dir run rm -r $VAR/input_dir } mkisofs_ignore() { stdout "Warning: using transparent compression" stdout "The resulting filesystem can only be transparently" stdout "On other operating systems you need to call" stdout "mkzftree by hand to decompress the files" ignore "^Using .* for" ignore "^Total " ignore "estimate finish" ignore "^Path table size" ignore "^Max brk space used" ignore "^$" stdout "^Size of boot image is" stdout "extents written" stdout "Unable to open directory .*/dev/pts" stdout "Unknown file type (unallocated) .*/\.\. - ignoring and continuing." stdout "Warning: Creating ISO-9660:1999 (version 2) filesystem." stdout "Warning: ISO-9660 filenames longer than 31 may cause buffer overflows in the OS." } # cdimage_compressed_isolinux cdimage_compressed_isolinux() { compress_dir isolinux $* mkisofs_ignore MKISOFS_OPTS="-z -R -b isolinux/isolinux.bin -c isolinux/boot.cat \ -no-emul-boot -boot-load-size 4 -boot-info-table -o $VAR/cdimage" MKISOFS_OPTS="$(chng_opts "$MKISOFS_OPTS" "$MKISOFS_CHNG")" MKISOFS_OPTS="$MKISOFS_OPTS $VAR/compressed_dir" echo "cdimage_compressed_isolinux=<$MKISOFS $MKISOFS_OPTS>" >>$ERRLOG run $MKISOFS $MKISOFS_OPTS run rm -r $VAR/compressed_dir } CONFDIR="/etc/bootcd" ONLY_FLOPPY="" DEVELOPE="" SCRIPT="" while [ $# -gt 0 ]; do if [ "$1" = "-only_floppy" ]; then shift ONLY_FLOPPY="yes" elif [ "$1" = "-c" -a $# -gt 1 ]; then CONFDIR=$2 shift 2 elif [ "$1" = "-d" ]; then DEVELOPE=1 shift elif [ "$1" = "-s" ]; then SCRIPT="$1" shift else echo "Usage: bootcdwrite [-only_floppy] [-c ] [-s]" echo " use man bootcdwrite to get help" echo " and see $CONFDIR/bootcdwrite.conf" exit 1 fi done if [ "`whoami`" != "root" ]; then echo "You have to run bootcdwrite as root" exit 1 fi if [ ! -f $CONFDIR/bootcdwrite.conf ]; then echo "No file $CONFDIR/bootcdwrite.conf" >&2 exit 1 fi CONFVARS="SRCDISK KERNEL APPEND NOT_TO_CD SSHHOSTKEY \ ERRLOG VAR DO_CHECK CDDEV DISPLAY FLOPPY_RUNTIME_DEV BOOTFLOPPY \ BOOT_ONLY_WITH_FLOPPY CLEAN_VAR INITRD \ TO_FSTAB TYP DISABLE_CRON MKISOFS_CHNG NOTCOMPRESSED BOOTCDMODPROBE \ UDEV_FIXNET" OBSOLETE="BLANKING CDSCSI CDSPEED FLOPPY_CREATE_DEV ISO_ONLY NOT_TO_RAM FASTBOOT DEVFS" unset $CONFVARS . $CONFDIR/bootcdwrite.conf # add SRCDISK to variables if [ "$SRCDISK" ]; then [ "$SRCDISK" = "/" ] && s="" || s="$SRCDISK" for v in DISPLAY DISABLE_CRON NOT_TO_CD $(for i in "" $(set | sed -n "s/^KERNEL\([[:digit:]]\+\)=.*/\1/p"); do echo KERNEL$i INITRD$i; done); do n="" for i in $(eval echo \$$v); do if [ "$(echo "$i" | cut -c1-1)" != "/" ]; then [ "$n" ] && n=$(echo "$n $s/$i") || n="$s/$i" else [ "$n" ] && n=$(echo "$n $i") || n="$i" fi done eval $v="\$n" done fi mkdir -p $VAR if [ -f ./bootcd-run.lib -a "$DEVELOPE" ]; then . ./bootcd-run.lib else . /usr/share/bootcd/bootcd-run.lib fi if [ -f ./bootcd-check.lib -a "$DEVELOPE" ]; then . ./bootcd-check.lib else . /usr/share/bootcd/bootcd-check.lib fi if [ "$(set | grep ^ERRLOG=)" ]; then date "+--- $0 %d.%m.%Y ---" > $ERRLOG echo "To see full output: tail -f $ERRLOG" | tee -a $ERRLOG fi find_mkisofs for i in $CONFVARS; do [ "`set | grep ^$i=`" ] || err "$i is not set in $CONFDIR/bootcdwrite.conf" done PROBLEM="is set in $CONFDIR/bootcdwrite.conf, but is obsolete. It will be ignored." for i in $OBSOLETE; do [ "`set | grep ^$i=`" ] && warn "$i $PROBLEM" done check_config warn_user # by din trap trapfunc 0 2 cleanup check_locatedb # We have to get the sizes (get_sizes) before before the final # check (check_sizes), because some variables with the value "auto" # need the information to become either "yes" or "no". get_sizes check_file_rc check_compress check_cdfiles check_kernel check_initrd check_sizes echo "--- Building Modifications ---" | tee -a $ERRLOG run mkdir -p $VAR/mnt $CHANGES/proc $CHANGES/sys $CHANGES/run $CHANGES/tmp if [ "$CLEAN_VAR" = "yes" -a ! "$ONLY_FLOPPY" ]; then run apt-get clean # to clear some diskspace in /var fi # Make sure /etc/securetty accepts devices not seen in /dev run mkdir -p $CHANGES/etc run "cp $SRCDI/etc/securetty $CHANGES/etc" run "echo \"# added by bootcdwrite BEGIN\" >> $CHANGES/etc/securetty" run "echo \"/dev/console\" >> $CHANGES/etc/securetty" run "echo \"# added by bootcdwrite END\" >> $CHANGES/etc/securetty" # Disable persistent-net-rules for i in z25_persistent-net.rules 70-persistent-net.rules; do if [ "$UDEV_FIXNET" = "yes" -a -e "$SRCDI/etc/udev/rules.d/$i" ]; then run mkdir -p $CHANGES/etc/udev/rules.d/ run "sed \"s/^\([^#]\+.*\)/#\1 # disabled by bootcdwrite/\" \ $SRCDI/etc/udev/rules.d/$i > $CHANGES/etc/udev/rules.d/$i" fi done run mkdir -p $CHANGES/usr/bin $CHANGES/etc/bootcd $CHANGES/usr/share/bootcd mkdir -p $CHANGES/etc/init.d run mkdir -p $CHANGES/usr/bin $CHANGES/etc/bootcd $CHANGES/usr/share/bootcd run cp /usr/share/bootcd/bootcd2disk $CHANGES/usr/bin/ [ -e "/usr/share/bootcd/bootcdmk2diskconf" ] && run cp /usr/share/bootcd/bootcdmk2diskconf $CHANGES/usr/bin/ [ -e "/usr/share/bootcd/bootcdbackup" ] && run cp /usr/share/bootcd/bootcdbackup $CHANGES/usr/bin/ run cp /usr/share/bootcd/bootcdflopcp $CHANGES/usr/bin/ run "cat /etc/init.d/bootcdflop | sed \"s|^\(BOOT_ONLY_WITH_FLOPPY=\).*$|\1$BOOT_ONLY_WITH_FLOPPY|\" | sed \"s|^FLOPPY=.*$|FLOPPY=$FLOPPY_RUNTIME_DEV|\" | cat >$CHANGES/etc/init.d/bootcdflop" run "chmod 755 $CHANGES/etc/init.d/bootcdflop" run cp /usr/share/bootcd/bootcd2disk.conf $CHANGES/etc/bootcd/ run cp /usr/share/bootcd/bootcd-run.lib $CHANGES/usr/share/bootcd/ run cp /usr/share/bootcd/bootcd2disk.lib $CHANGES/usr/share/bootcd/ if [ -d $SRCDI/dev/.static/dev -a -x $SRCDI/etc/init.d/udev ]; then # -- udev -- # The filesystem has static device files in /dev. # But tmpfs is mounted over /dev and hides the static device files. # The static device files are mounted again in /dev/.static/dev/. # This means bootcd has only to copy /dev/.static/dev as /dev, but # this directory does not contain the subdir .static, so we create it. run mkdir -p $CHANGES/dev/.static run chown root:root $CHANGES/dev/.static run chmod 700 $CHANGES/dev/.static fi # appending .no_run_on_bootcd disables the files in DISABLE_CRON for run-parts # also set a link to /bin/true to "overwrite" the original file for f in $DISABLE_CRON; do if [ -f $f ]; then CHANGESCRON=$(chnglist -add_ro -no_mnt "$SRCDISK" "$f") run install -p -D $f $CHANGES/$CHANGESCRON.no_run_on_bootcd run ln -s /bin/true $CHANGES/$CHANGESCRON fi done ( echo "KERNEL=$REL_KERNEL" echo "INITRD=$REL_INITRD" echo "DISABLE_CRON=\"$(chnglist -no_mnt "$SRCDISK" "$DISABLE_CRON")\"" ) >$CHANGES/etc/bootcd/thisbootcd.conf run "cat < $CHANGES/etc/fstab $CDDEV1 / iso9660 defaults,rw 0 0 #proc /proc proc defaults 0 0 $TO_FSTAB END" if [ ! "$ONLY_FLOPPY" ]; then if [ "$SSHHOSTKEY" = "yes" ]; then # each CD gets a unique hostkey" # create_host_keys will only recreate keys, if they already exist. # So keys will be touched in new dir, if they existed in old dir. for i in ssh_host_key ssh_host_rsa_key ssh_host_dsa_key do if [ -f $SRCDI/etc/ssh/$i ]; then run mkdir -p $CHANGES/etc/ssh touch $CHANGES/etc/ssh/$i fi done create_host_keys $CHANGES/etc/ssh elif [ "$SSHHOSTKEY" != "no" ]; then warn 'SSHHOSTKEY is not defined as "yes" or "no".' \ 'It will be treated as "no".' fi fi do_isolinux # only create fastboot file, if there are no additional mount points if [ ! "$TO_FSTAB" ]; then run touch $CHANGES/fastboot fi # only call the function, if it is defined doit=$(egrep "^[[:space:]]*(function)*[[:space:]]*extra_changes" $CONFDIR/bootcdwrite.conf) if [ ! -z "$doit" ]; then echo "--- do function extra_changes ---" | tee -a $ERRLOG extra_changes fi if [ ! "$ONLY_FLOPPY" ]; then echo "--- Creating CD-Image ---" | tee -a $ERRLOG MKISO_NOT="" if [ "$NOT_TO_CD" != "" ]; then MKISO_NOT=`echo "$NOT_TO_CD" | sed "s/\(^\| \)*\([^ ]*\)/-x \2 /g"` echo "NOT_TO_CD arguments for $MKISOFS = <$MKISO_NOT>" >>$ERRLOG fi # Are there Files in $SRCDI that we have in $CHANGES too # If so we have to exclude them EXCLUDE="" for i in `(cd $CHANGES; find . ! -type d)`; do # i=./etc.ro/mtab j=`echo $i|sed "s|^\.||"` # j=/etc.ro/mtab k=`echo $j|sed "s|\.ro/|/|"` # k=/etc/mtab if [ -f $SRCDI$k ]; then EXCLUDE="$EXCLUDE -x $SRCDI$k" fi done # since mkisofs 1.13 and genisoimage we have to use the option -graft-points if [ "$(basename "$MKISOFS")" = "genisoimage" ]; then GRAFTPOINTS="-graft-points" else GRAFTPOINTS=`$MKISOFS --version | head -1 | awk '{if($2>1.12) {print "-graft-points"}}'` fi echo "MKISOFS=<$MKISOFS> GRAFTPOINTS=<$GRAFTPOINTS>" >>$ERRLOG # Exclude .udev directory if [ -d $SRCDI/dev/.udev ]; then MKISO_NOT="${MKISO_NOT}-x $SRCDI/dev/.udev " echo "NOT_TO_CD arguments with .udev for $MKISOFS = <$MKISO_NOT>" >>$ERRLOG fi cdimage_compressed_isolinux $NOTCOMPRESSED echo "--- Testing CD-Image ---" | tee -a $ERRLOG run mount $VAR/cdimage $VAR/mnt -o ro -o loop -t iso9660 ignore ".*" run ls -l $VAR/mnt run umount $VAR/mnt losetup -d /dev/loop0 2>/dev/null mv $VAR/cdimage $VAR/cdimage.iso fi [ -e "/$CHANGES/cdboot.img" ] && cp /$CHANGES/cdboot.img $VAR/floppy.img echo "work is done... find images in \"$VAR\" now!" echo bootcd-4.04/Makefile0000644000000000000000000000731512216615054011251 0ustar # Makefile # BIN= bootcdwrite USRLIBS= bootcd-run.lib bootcdbackup.lib bootcd-check.lib \ bootcd2disk.conf bootcd2disk.lib \ default.txt USREXLIBS= bootcd2disk bootcdflopcp bootcdmodprobe bootcdproberoot \ bootcdmk2diskconf bootcdbackup CONFFILES= bootcdwrite.conf isolinux.cfg syslinux.cfg bootcdbackup.conf INITTOP= runbootcdmodprobe LOCALBOTTOM= bootcdaufs INITPREMOUNT= runbootcdproberoot INITHOOK= bootcdinitramfshook INITRAMFSDEST= $(DESTDIR)/usr/share/initramfs-tools VERSION=version=$$(sed -ne "s|^bootcd (\([^)]*\)).*|\1|p;q" debian/changelog) # /bin/echo is needed instead of echo. Because /bin/echo it behaves like # bash-echo and does not interpret \n as dash-echo would do. REPLVERSION=($(VERSION); \ version2=$$(/bin/echo "$${version}" | sed "s/\./_/"); \ sed -e "s|\#\#BOOTCD\.VERSION\#\#|$${version}|" -e "s|\#\#BOOTCD_VERSION\#\#|$${version2}|") INSERT=( \ F=$$(cat); \ lines=$$(/bin/echo "$$F" | sed -e "$$SEARCH" |wc -l); \ elines=$$(expr $$(/bin/echo "$$F" |wc -l) - $$lines + 1); \ /bin/echo "$$F" | head -n $$lines; \ cat $$FILE; \ /bin/echo "$$F" | tail -n -$$elines \ ) all: bootcddebootstrap bootcdbackupwizard bootcdmkbackwiztar ${USREXLIBS} ${INITTOP} bootcdbackwiz: bootcdbackwiz_extract ../bootcd_*_all.deb README.bootcdbackwiz_extract sh -c '$(VERSION); \ mkdir bootcdbackupwizard_$${version}; \ for i in $^; do \ cp $$i bootcdbackupwizard_$${version}/; \ done; \ tar -cvzf bootcdbackupwizard_$${version}.tar.gz bootcdbackupwizard_$${version}; \ rm -rf bootcdbackupwizard_$${version}' clean: @rm -f ChangeLog.gz @rm -f bootcddebootstrap bootcdbackupwizard bootcdmk2diskconf \ bootcdbackwiz_extract bootcdmkbackwiztar @rm -rf bootcdbackupwizard_*.tar.gz @rm -f bootcdmodprobe runbootcdmodprobe install: all @install -m 755 -o root -g root $(BIN) $(DESTDIR)/usr/bin/ @install -m 644 -o root -g root $(CONFFILES) $(DESTDIR)/etc/bootcd/ @install -m 644 -o root -g root $(USRLIBS) $(DESTDIR)/usr/share/bootcd/ @install -m 755 -o root -g root $(USREXLIBS) $(DESTDIR)/usr/share/bootcd/ @install -m 755 -o root -g root $(INITTOP) $(INITRAMFSDEST)/scripts/init-top/ @install -m 755 -o root -g root $(INITPREMOUNT) $(INITRAMFSDEST)/scripts/init-premount/ @install -m 755 -o root -g root $(LOCALBOTTOM) $(INITRAMFSDEST)/scripts/local-bottom/ @install -m 755 -o root -g root $(INITHOOK) $(INITRAMFSDEST)/hooks/ bootcddebootstrap: bootcddebootstrap.src bootcd-run.lib sh -c ' \ cat $< | \ ( SEARCH="\|\#\#\# BOOTCD-RUN_LIB|q"; FILE="bootcd-run.lib"; $(INSERT) ) | \ $(REPLVERSION) >$@' chmod 755 $@ bootcdbackupwizard: bootcdbackupwizard.src bootcd-run.lib bootcdbackup.lib sh -c ' \ cat $< | \ ( SEARCH="\|\#\#\# BOOTCD-RUN_LIB|q"; FILE="bootcd-run.lib" ; $(INSERT) ) | \ ( SEARCH="\|\#\#\# BOOTCDBACKUP_LIB|q"; FILE="bootcdbackup.lib" ; $(INSERT) ) | \ $(REPLVERSION) >$@' chmod 755 $@ bootcdbackwiz_extract: bootcdbackwiz_extract.src ../bootcd_*_all.deb sh -c ' \ bootcddeb=$$(cd ..; /bin/ls bootcd_*_all.deb); \ sed -e "s|\#\#BOOTCDDEB\#\#|$${bootcddeb}|" $< | \ $(REPLVERSION) >$@' chmod 755 $@ bootcdmk2diskconf: bootcdmk2diskconf.src bootcd2disk.conf bootcd-run.lib sh -c ' \ cat $< | \ ( SEARCH="\|\#\#\# BOOTCD-RUN_LIB|q"; FILE="bootcd-run.lib" ; $(INSERT) ) | \ ( SEARCH="\|\#\#\# BOOTCD2DISK.CONF|q"; FILE="bootcd2disk.conf"; $(INSERT) ) | \ $(REPLVERSION) >$@' chmod 755 $@ ./$@ -checktemplate bootcdmkbackwiztar: bootcdmkbackwiztar.src sh -c 'cat $< | $(REPLVERSION) >$@' chmod 755 $@ bootcdmodprobe: bootcdmodprobe.src sh -c 'cat $< | $(REPLVERSION) >$@' chmod 755 $@ runbootcdmodprobe: runbootcdmodprobe.src sh -c 'cat $< | $(REPLVERSION) >$@' chmod 755 $@ bootcd-4.04/bootcdbackup.conf.50000644000000000000000000000144710643172377013273 0ustar .IX Title "boocd2disk" .TH BOOTCDBACKUP.CONF 5 "2007-07-05" "bootcdbackup.conf" "bootcd utils" .SH NAME bootcdbackup.conf \- configuration file for bootcdbackup .SH DESCRIPTION The file .B bootcdbackup.conf contains configuration option for the .B bootcdbackup(1) program. The file must be located in the configuration directory which is usually "/etc/bootcd". Blank lines are ignored and lines with leading # are comments. Values have to be set with .B name=value .SH FORMAT .TP .B ERRLOG= Write all errors to this file. Required. .SH "SEE ALSO" .br bootcdbackup(1), bootcd2disk(1), bootcd(1), bootcdflopcp(1), bootcdwrite(1) .SH AUTHOR This manual page was written by Carsten Dinkelmann <\ficarsten.dinkelmann@foobar-cpa.de\fR>, for the Debian GNU/Linux system (but may be used by others). bootcd-4.04/bootcdflopcp0000755000000000000000000000460312006721744012213 0ustar #!/bin/sh # bootcdflopcp # History # 28.07.2000 - Recognize empty files too. # - Do not depend on diff flag -N any longer. # - Ignore symbolic links to same target. set -e LANG=C VERBOSE="" FLOPPY=/dev/fd0 err() { echo "ERROR: $1" >&2 exit 1 } while [ "$*" ]; do if [ "$1" = "-v" ]; then VERBOSE="-v" shift elif [ "$1" = "-d" ]; then FLOPPY=$2 shift 2 elif [ "$*" ]; then echo "Usage: bootcdflopcp [-v] [-d ]" echo " use man bootcdflopcp to get help" >&2 echo " device can be another device instead of /dev/floppy" >&2 exit 1 fi done TMP=/tmp/flopcp$$ MNTP=/mnt/floppy mkdir -p $MNTP || exit 1 mount $FLOPPY $MNTP || exit 1 trap "umount $MNTP; rmdir $MNTP; rm -f $TMP" 0 touch $MNTP/remove $MNTP/change $MNTP/ignore $MNTP/execute chmod 755 $MNTP/execute IGNORE="" CHANGE="" REMOVE="" mkdir -p /mnt/bootcd.root [ "$(mount | grep "on /mnt/bootcd.root\>")" ] || mount --bind / /mnt/bootcd.root [ "$(mount | grep "on /mnt/bootcd.ro\>")" ] || err "/mnt/bootcd.ro is not mounted" # Search all Files that differ find /mnt/bootcd.aufs -type f|grep -v "/\.wh\.\.wh\."|sed "s|/\.wh\.|/|" >$TMP for f in `cat $TMP`; do if [ "`grep ^$f$ $MNTP/ignore`" ]; then IGNORE="$f $IGNORE" continue fi if [ -e "$f" ]; then if [ "`grep ^$f$ $MNTP/change`" ]; then CHANGE="$f $CHANGE" continue fi while : do echo -n "change $f (y/n) " read a # Next line handles EOF from a pipe as "n" [ $? -ne 0 ] && a="n" if [ "$a" = "y" ]; then echo $f >> $MNTP/change CHANGE="$f $CHANGE" break elif [ "$a" = "n" ]; then echo $f >> $MNTP/ignore IGNORE="$f $IGNORE" break fi done else if [ "`grep ^$f$ $MNTP/remove`" ]; then REMOVE="$f $REMOVE" continue fi while : do echo -n "remove $f (y/n) " read a # Next line handles EOF from a pipe as "n" [ $? -ne 0 ] && a="n" if [ "$a" = "y" ]; then echo $f >> $MNTP/remove REMOVE="$f $REMOVE" break elif [ "$a" = "n" ]; then echo $f >> $MNTP/ignore IGNORE="$f $IGNORE" break fi done fi done if [ "$VERBOSE" ]; then echo "Changing $CHANGE." >&2 echo "Removing $REMOVE." >&2 echo "Ignoring $IGNORE." >&2 fi (cd /; tar cz -T $MNTP/change -f $MNTP/change.tgz) exit 0 bootcd-4.04/bootcdmkbackwiztar.src0000755000000000000000000000210310723535402014176 0ustar #!/bin/sh # bootcdmkbackupwiz # # Create a tar package with all files needed to backup # a debian or alien linux distribution. # Alternatively you can download a prebuild tar package with: # wget ftp://bootcd.alioth.debian.org/pub/bootcd/bootcdbackupwizard.tar.gz # # Please see README.Debian for more info set -e VERSION=##BOOTCD.VERSION## D="bootcdbackwiztar" usage() { echo "Usage: bootcdmkbackwiztar [-f]" >&2 } err() { echo "$*" >&2 exit 1 } FORCE="" while [ $# -ge 1 ]; do if [ "$1" = "-f" ]; then FORCE="1" shift else usage "Unknown argument <$1>" exit 1 fi done [ -e "$D" -a ! "$FORCE" ] && err "$D already exists. Please move it away and run again" rm -rf $D mkdir $D ( cd $D apt-get source bootcd ( [ ! -d bootcd-${VERSION} ] && err "apt-get source bootcd did not install the VERSION ${VERSION}, please change /etc/apt/sources.list" cd bootcd-${VERSION} debuild binary make bootcdbackwiz ) ) cp $D/bootcd-${VERSION}/bootcdbackupwizard_${VERSION}.tar.gz . rm -r $D echo "created bootcdbackupwizard_${VERSION}.tar.gz" bootcd-4.04/bootcdmk2diskconf.src0000755000000000000000000004743612276204673013751 0ustar #!/bin/sh set -u # exit on using unset var # name = bootcdmk2diskconf - create bootcd2disk.conf for backup # autor = Bernd Schumacher # startdate = 08.05.2007 ### BOOTCD-RUN_LIB Placeholder ############## # exclude this filesystems from RIDF (readinfo from df) RIDF_EXCLUDES="-e ^/dev/shm.*/dev/shm" # only grep filesystems from fstab MOUNTGREP='grep -e "^/dev/" -e "^LABEL=" -e "^UUID=" | grep -v -e "\" -e "\" -e "\" -e "\" -e "\" -e "\" -e "\"' MNTBOOTCDDISC="mnt/bootcd.disc" ######################## nothing to configure behind this line ############### # The following parameters are defined in the order listed PARAMETERS="ERRLOG DISK0 LVMGRP LVMVOL TRYFIRST SFDISK0 VFAT EXT2FS EXT3FS EXT4FS SWAP MOUNT BIND UMOUNT FSTAB GRUB2 GRUB GRUBBOOTDISK GRUBBOOTDIR GRUBDEVICEMAP LILO SSHHOSTKEY UDEV_FIXNET IMAGEURL PARTITIONLABEL" USAGE=" Usage: bootcdmk2diskconf [-v] [-d] -v verbose -d debug -s same; same size for last partition. If this option is not used the last partition will be adjusted to actual disk size. -e exact; exact disks will be used. Normally only the disk order will be used. -b This option is needed to create a bootcd2disk.conf that can be used to restore an offline backup. -f Not the actual running system is used, but a system described by the fstab that can be found on device . . example: -f /dev/sde7 " debug() { if [ "$DEBUG" ]; then echo "DEBUG $*" >&2 fi } # label2dev