diff --git a/TODO.txt b/TODO.txt new file mode 100644 index 0000000..9b1291d --- /dev/null +++ b/TODO.txt @@ -0,0 +1,18 @@ +TODO list for RescueBRU + +feature: save config of backup in a backup.conf file to include devices. + Check for this file when doing a new backup. Offer to use existing + config. + +feature: replace spaces with underscores in new image name. + +bug: when getting a list of images in imageselect() sometime a busy + server can make the client appear to lock up. Need a "please wait.." + message so user doesn't panic. + +bug: server may appear to lock up when using several functions. Need a + "please wait..." message for anything that might have to load data + from the CD. + +bug: settings selections submenus don't preselect the current setting as + the default-item in the dialog. diff --git a/buildtools/TODO.txt b/buildtools/TODO.txt new file mode 100644 index 0000000..f17a64c --- /dev/null +++ b/buildtools/TODO.txt @@ -0,0 +1,23 @@ +TODO list for RescueBRU-7.1.1 + +feature: save config of backup in a backup.conf file to include devices. + Check for this file when doing a new backup. Offer to use existing + config. + +feature: replace spaces with underscores in new image name. + +bug: on restore, the "original drive was" and "current drive is" info + messages may be blank due to inconsistency in how smartctl + displays the drive model. the code looks for "Device Model" and + sometimes smartctl just outputs "Device" + +bug: when getting a list of images in imageselect() sometime a busy + server can make the client appear to lock up. Need a "please wait.." + message so user doesn't panic. + +bug: server may appear to lock up when using several functions. Need a + "please wait..." message for anything that might have to load data + from the CD. + +bug: settings selections submenus don't preselect the current setting as + the default-item in the dialog. diff --git a/buildtools/buildrescuebru b/buildtools/buildrescuebru new file mode 100644 index 0000000..217c364 --- /dev/null +++ b/buildtools/buildrescuebru @@ -0,0 +1,103 @@ +#!/bin/bash + +if [ ! -e buildtools.conf ]; then + cp buildtools.conf.delivered buildtools.conf +fi +source buildtools.conf + +function buildclient() { + echo "buildrescuebru: building client iso image..." + cp /mnt/custom/customcd/isoroot/isolinux/isolinux.cfg.client /mnt/custom/customcd/isoroot/isolinux/isolinux.cfg + cp /mnt/custom/customcd/isoroot/boot/grub/grub-522.cfg.client /mnt/custom/customcd/isoroot/boot/grub/grub-522.cfg + dobuild "client" +} + +function buildserver() { + echo "buildrescuebru: building server iso image..." + cp /mnt/custom/customcd/isoroot/isolinux/isolinux.cfg.server /mnt/custom/customcd/isoroot/isolinux/isolinux.cfg + cp /mnt/custom/customcd/isoroot/boot/grub/grub-522.cfg.server /mnt/custom/customcd/isoroot/boot/grub/grub-522.cfg + dobuild "server" +} + +function dobuild() { + echo "buildrescuebru: creating squashfs for $1..." + /usr/sbin/sysresccd-custom squashfs + echo "buildrescuebru: removing stale sysresccd files from isofile directory..." + rm -fv /mnt/custom/customcd/isofile/sysresccd* + echo "buildrescuebru: generating new iso/md5 for $volname-$1..." + /usr/sbin/sysresccd-custom isogen $volname-$1 + echo "buildrescuebru: moving sysresccd iso/md5 files to volume name files in xfer directory..." + origiso=`ls /mnt/custom/customcd/isofile/sysresccd-*.iso` + origmd5=`ls /mnt/custom/customcd/isofile/sysresccd-*.md5` + mv -v $origiso /mnt/custom/isoxfer/$volname-$1.iso + mv -v $origmd5 /mnt/custom/isoxfer/$volname-$1.md5 +} + +# ------ + +echo -n "Is this a development system or a build machine? [d/b] : " +read systype +echo -n "Will this be a client CD or server CD or both or no CD? [c/s/b/n] : " +read buildtype +if [ "$buildtype" != "n" ]; then + echo -n "Enter CD volume name : " + read volname +fi +echo -n "Would you like to extract a new customcd? [y/n] : " +read ext +echo -n "Do you need to chroot into the customcd filesystem? [y/n] : " +read chrt +if [ "$ext" = "y" ]; then + echo "Moving existing customcd to customcd-`date +%Y%m%d%H%M%S`..." + mv /mnt/custom/customcd /mnt/custom/customcd-`date +%Y%m%d%H%M%S` + echo "Extracting new customcd..." + /usr/sbin/sysresccd-custom extract +fi +if [ "$buildtype" != "n" ]; then + mkdir -p /mnt/custom/isoxfer + rm -f /mnt/custom/isoxfer/* +fi +/mnt/custom/buildtools/get_distributables $systype +if [ "$REL_TYPE" = "p" ]; then + /mnt/custom/buildtools/get_documentation $systype +fi +/mnt/custom/buildtools/fixpermissions +/mnt/custom/buildtools/setsymlinks +if [ "$chrt" = "y" ]; then + /mnt/custom/buildtools/customchroot +fi +mkdir -p /mnt/custom/customcd/isoroot/rescuebru-src +rm -rf /mnt/custom/customcd/isoroot/rescuebru-src/* +cp -R /mnt/custom/rescuebru-src/* /mnt/custom/customcd/isoroot/rescuebru-src + +mkdir -p /mnt/custom/customcd/isoroot/buildtools +rm -rf /mnt/custom/customcd/isoroot/buildtools/* +cp -R /mnt/custom/buildtools/* /mnt/custom/customcd/isoroot/buildtools +case $buildtype in + "c" ) + buildclient + ;; + + "s" ) + buildserver + ;; + + "b" ) + buildclient + buildserver + ;; + "n" ) + echo "This was a file update only. Not building a new iso." + ;; +esac +if [ "$buildtype" != "n" ]; then + if [ "$systype" = "b" ]; then + echo "buildrescuebru: transferring iso/md5 files back to development system..." + /mnt/custom/buildtools/putiso + else + echo "iso/md5 file generation complete. Files are in /mnt/custom/isoxfer" + fi +else + echo "File update complete." +fi + diff --git a/buildtools/buildtools.conf.delivered b/buildtools/buildtools.conf.delivered new file mode 100644 index 0000000..402c11f --- /dev/null +++ b/buildtools/buildtools.conf.delivered @@ -0,0 +1,16 @@ +# buildtools.conf.delivered + +# type of release, c=clean or p=proprietary +REL_TYPE="c" + +# path of source files if we are build machine +BUILD_SRC_PATH="rwright@bomarc:/home/rwright/latest-rbru/" + +# path of source files if we are a development machine +DEV_SRC_PATH="/mnt/custom/rescuebru-src/" + +# path of proprietary documentation files if we are build machine +BUILD_DOC_PATH="rwright@bomarc:/home/rwright/RescueBRU/latest-docs/" + +# path on remote development machine where new isos will be put +ISO_DEST_PATH="rwright@bomarc:/home/rwright/RescueBRU/rescuebru-isos/" diff --git a/buildtools/customchroot b/buildtools/customchroot new file mode 100644 index 0000000..635724b --- /dev/null +++ b/buildtools/customchroot @@ -0,0 +1,14 @@ +#!/bin/bash +# customchroot - Modify a stock SystemRescueCD + +# Set up the chroot environment +for vfs in proc dev sys; do + mkdir -p /mnt/custom/customcd/files/$vfs + mount -o bind /$vfs /mnt/custom/customcd/files/$vfs +done +echo "Entering chroot environment. Type exit to leave." +chroot /mnt/custom/customcd/files /bin/bash +for vfs in proc dev sys; do + umount /mnt/custom/customcd/files/$vfs +done + diff --git a/buildtools/fixpermissions b/buildtools/fixpermissions new file mode 100644 index 0000000..72021a7 --- /dev/null +++ b/buildtools/fixpermissions @@ -0,0 +1,47 @@ +#!/bin/bash +executables="\ +/root/rescuebru/rbruserver.sh \ +/root/rescuebru/rescuebru.sh \ +/root/rescuebru/xrbruserver.sh \ +/root/rescuebru/xrescuebru.sh \ +/root/rescuebru/clone.sh \ +/root/rescuebru/blank.sh \ +/root/rescuebru/faultmonitor.sh \ +/root/rescuebru/showcapacitywindow.sh \ +/root/rescuebru/showfaultwindow.sh \ +/root/rescuebru/showstatuswindow.sh \ +/root/rescuebru/updatecapacity.sh \ +/root/rescuebru/updatestatus.sh \ +/root/autorun1 \ +/root/autorun2 \ +/root/autorun3 \ +/root/autorun4 \ +/root/srcdtips \ +/etc/init.d/pxebootsrv \ +/etc/init.d/sysresccd \ +/etc/init.d/dostartx \ +/etc/init.d/dhcpd \ +/bin/bashlogin \ +" + +tools="\ +buildrescuebru \ +fixpermissions \ +get_distributables \ +get_documentation \ +putiso \ +setsymlinks \ +customchroot \ +updatedevsystem \ +updatelocalsrc \ +" + +for x in $executables; do + echo "Setting executable bit on $x" + chmod +x /mnt/custom/customcd/files$x +done +for y in $tools; do + echo "Setting executable bit on $y" + chmod +x /mnt/custom/buildtools/$y +done + diff --git a/buildtools/get_distributables b/buildtools/get_distributables new file mode 100644 index 0000000..8043325 --- /dev/null +++ b/buildtools/get_distributables @@ -0,0 +1,40 @@ +#!/bin/bash + +echo "Getting distributables..." + +if [ ! -e buildtools.conf ]; then + cp buildtools.conf.delivered buildtools.conf +fi +source buildtools.conf + +if [ "$1" = "b" ]; then + srcpath=$BUILD_SRC_PATH +elif [ "$1" = "d" ]; then + srcpath=$DEV_SRC_PATH +else + echo "Unknown system type parameter." + echo "Must be b for build machine or d for dev system." + exit 1 +fi +rm -rf /mnt/custom/customcd/files/root/rescuebru/* +rm -rf /root/rescuebru/* +sleep 2 +if [ "$1" = "b" ]; then + ntpdate 0.pool.ntp.org +fi +rm -rf /mnt/custom/customcd/isoroot/RescueBRU_Documentation/* +rsync -rlptDvz --exclude=*.iso --exclude=*.md5 $srcpath /mnt/custom/ +find /mnt/custom/customcd/isoroot/RescueBRU_Documentation/ -type f ! -name '*.pdf' ! -name '*.xls' -delete +mkdir -p /mnt/custom/rescuebru-src +rsync -rlptDvz --del --exclude=*.iso --exclude=*.md5 $srcpath /mnt/custom/rescuebru-src/ +cp -Rv /mnt/custom/rescuebru-src /mnt/custom/customcd/isoroot +if [ ! -d "/root/rescuebru" ]; then + mkdir /root/rescuebru +fi +chmod +x /mnt/custom/buildtools/* +chmod -x /mnt/custom/buildtools/*.conf /mnt/custom/buildtools/*.conf.delivered +cp -R /mnt/custom/customcd/files/root/rescuebru/* /root/rescuebru + +rm -f /mnt/custom/customcd/files/root/.bash_history +rm -rf /mnt/custom/customcd/files/root/.config/geany + diff --git a/buildtools/get_documentation b/buildtools/get_documentation new file mode 100644 index 0000000..1fab9db --- /dev/null +++ b/buildtools/get_documentation @@ -0,0 +1,23 @@ +#!/bin/bash + +echo "Getting proprietary documentation..." + +if [ ! -e buildtools.conf ]; then + cp buildtools.conf.delivered buildtools.conf +fi +source buildtools.conf + +if [ "$1" = "b" ]; then + docpath=$BUILD_DOC_PATH + mkdir -p /mnt/custom/customcd/isoroot/RescueBRU_Documentation + rsync -rlptDvz $docpath/RescueBRU_Documentation /mnt/custom/customcd/isoroot/ + find /mnt/custom/customcd/isoroot/RescueBRU_Documentation/ -type f ! -name '*.pdf' ! -name '*.xls' -delete +elif [ "$1" = "d" ]; then + echo "This is a development machine, so leaving documentation as-is." +else + echo "Unknown system type parameter." + echo "Must be b for build machine or d for dev system." + exit 1 +fi + +rm -f /mnt/custom/customcd/files/root/.bash_history diff --git a/buildtools/putiso b/buildtools/putiso new file mode 100644 index 0000000..12a37cf --- /dev/null +++ b/buildtools/putiso @@ -0,0 +1,8 @@ +#!/bin/bash +if [ ! -e buildtools.conf ]; then + cp buildtools.conf.delivered buildtools.conf +fi +source buildtools.conf + +isopath=$ISO_DEST_PATH +rsync -avz /mnt/custom/isoxfer/ $isopath diff --git a/buildtools/setsymlinks b/buildtools/setsymlinks new file mode 100644 index 0000000..3acd6a3 --- /dev/null +++ b/buildtools/setsymlinks @@ -0,0 +1,9 @@ +#!/bin/bash +rm -f /mnt/custom/customcd/files/root/rescuebru/rescuebru \ +/mnt/custom/customcd/files/root/rescuebru/rbruserver \ +/mnt/custom/customcd/files/root/rescuebru/clone \ +/mnt/custom/customcd/files/root/rescuebru/blank +ln -s /root/rescuebru/rescuebru.sh /mnt/custom/customcd/files/root/rescuebru/rescuebru +ln -s /root/rescuebru/rbruserver.sh /mnt/custom/customcd/files/root/rescuebru/rbruserver +ln -s /root/rescuebru/clone.sh /mnt/custom/customcd/files/root/rescuebru/clone +ln -s /root/rescuebru/blank.sh /mnt/custom/customcd/files/root/rescuebru/blank diff --git a/buildtools/updatedevsystem b/buildtools/updatedevsystem new file mode 100644 index 0000000..2046046 --- /dev/null +++ b/buildtools/updatedevsystem @@ -0,0 +1,10 @@ +#!/bin/bash +# updatedevsystem - Push latest src files back to the normal development system +if [ ! -e buildtools.conf ]; then + cp buildtools.conf.delivered buildtools.conf +fi +source buildtools.conf + +devsystem=$BUILD_SRC_PATH +srcpath=$DEV_SRC_PATH +rsync -avz --exclude 'buildtools.conf' $srcpath $devsystem diff --git a/buildtools/updatelocalsrc b/buildtools/updatelocalsrc new file mode 100644 index 0000000..16aa998 --- /dev/null +++ b/buildtools/updatelocalsrc @@ -0,0 +1,10 @@ +#!/bin/bash +# updatelocalsrc - Get latest src files from normal development system +if [ ! -e buildtools.conf ]; then + cp buildtools.conf.delivered buildtools.conf +fi +source buildtools.conf + +devsystem=$BUILD_SRC_PATH +srcpath=$DEV_SRC_PATH +rsync -avz --del --exclude 'buildtools.conf' $devsystem $srcpath diff --git a/customcd/files/bin/bashlogin b/customcd/files/bin/bashlogin new file mode 100644 index 0000000..559a4c4 --- /dev/null +++ b/customcd/files/bin/bashlogin @@ -0,0 +1,55 @@ +#!/bin/sh +# ============ ENV VARS ================================ +cd /root +export LANG=en_US.utf8 +export HOME=/root +export SHELL=/bin/bash +export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/root/rescuebru +export path="/sbin /bin /usr/sbin /usr/bin /root/rescuebru" +export MAIL=/var/mail/root +export USER=root + +# ============ PRINT MESSAGE =========================== +lc1='\e[01;31m' # light red +dc1='\e[00;31m' # dark red +lc2='\e[01;37m' # white +dc2='\e[00;37m' # gray + +# fix broken console with utf8 in the alternative-kernels +echo -n -e '\033%G' +kbd_mode -u + +LINES=$(stty size|cut -d" " -f1) +fbecho() +{ + [ $LINES -ge 28 ] && echo +} + +if [ -f /root/version ] +then + VERSION=" ${lc2}$(cat /root/version)${lc1} " +else + VERSION="" +fi + +if [ -f /root/rb_version ] +then + RB_VERSION=" ${lc2}$(cat /root/rb_version)${lc1} " +else + RB_VERSION="" +fi + + +fbecho +echo -e "${lc1} ======== ${lc2}RescueBRU${lc1} -${RB_VERSION}=== ${lc2}SystemRescueCD${lc1} -${VERSION}=== ${lc2}$(basename $(tty))${dc2}/6 ${lc1}========" +echo -e " ${dc1}http://www.sysresccd.org/" +echo +echo -e "${dc1}*${dc2} Type ${lc2}rescuebru${dc2} to run the backup/restore utility." +echo -e "${dc1}*${dc2} Type ${lc2}rbruserver${dc2} to start the backup server." +echo +echo -e "${dc1}*${dc2} Type ${lc2}srcdtips${dc2} to view SystemRescueCD tips." +fbecho + +# ============ SHELL PROMPT ============================ +exec $SHELL --login + diff --git a/customcd/files/etc/conf.d/hostname b/customcd/files/etc/conf.d/hostname new file mode 100644 index 0000000..4a684aa --- /dev/null +++ b/customcd/files/etc/conf.d/hostname @@ -0,0 +1 @@ +HOSTNAME=rescuebru diff --git a/customcd/files/etc/conf.d/pxebootsrv b/customcd/files/etc/conf.d/pxebootsrv new file mode 100644 index 0000000..de55185 --- /dev/null +++ b/customcd/files/etc/conf.d/pxebootsrv @@ -0,0 +1,54 @@ +# Copyright 2003-2007 Francois Dupoux - www.sysresccd.org +# Distributed under the terms of the GNU General Public License v2 + +# Config file for /etc/init.d/pxebootsrv +# Have a look at the PXE chapter in the official manual for more details: +# http://www.sysresccd.org/Sysresccd-manual-en_PXE_network_booting + +# ------------------------- README ------------------------------------ +# The pxebootsrv service allows to provide a PXE-boot-server for +# SystemRescueCd out of the box. You just need to edit the following +# options and run "/etc/init.d/pxebootsrv restart", and you can boot +# any computer of your local network with PXE. +# +# You must configure these options if the current SystemRescueCd system +# acts as DHCP-server and TFTP-server and HTTP-server. If you keep this +# default behavior you just need to edit these options and start the +# service with "/etc/init.d/pxebootsrv restart". +# If you don't want the current system to be the DHCP server, you will have +# to configure everything by hand and it will not be possible to use +# the pxebootsrv service. + +# ------------------------ CONFIGURATION ------------------------------- +# By default the current systems acts as DHCP and TFTP and HTTP server +# If you want another machine of you network to act as one of those +# you will have to turn the appropriate option yo "no" + +# Set to "yes" if you want this machine to act as a DHCP server +PXEBOOTSRV_DODHCPD="yes" +# Set to "yes" if you want this machine to act as a TFTP server +PXEBOOTSRV_DOTFTPD="yes" +# Set to "yes" if you want this machine to act as an HTTP server +PXEBOOTSRV_DOHTTPD="yes" +# Set to "yes" if you want this machine to act as an NFS server +PXEBOOTSRV_DONFSD="no" + +# Here is a typical PXE-Boot configuration --> update with your settings +PXEBOOTSRV_SUBNET="10.111.1.0" # Used only if PXEBOOTSRV_DODHCPD="yes" +PXEBOOTSRV_NETMASK="255.255.255.0" # Used only if PXEBOOTSRV_DODHCPD="yes" +PXEBOOTSRV_DEFROUTE="10.111.1.1" # Used only if PXEBOOTSRV_DODHCPD="yes" +PXEBOOTSRV_DNS="10.111.1.1" # Used only if PXEBOOTSRV_DODHCPD="yes" +PXEBOOTSRV_DHCPRANGE="10.111.1.50 10.111.1.90" # Used only if PXEBOOTSRV_DODHCPD="yes" +PXEBOOTSRV_LOCALIP="10.111.1.1" +PXEBOOTSRV_IF="eth0" + +# Keep these values to $PXEBOOTSRV_LOCALIP if the current computer +# acts as TFTP server and HTTP server as well as DHCP server +PXEBOOTSRV_TFTPSERVER="$PXEBOOTSRV_LOCALIP" # IP address of the TFTP server if PXEBOOTSRV_DODHCPD="yes" +PXEBOOTSRV_HTTPSERVER="http://$PXEBOOTSRV_LOCALIP/sysrcd.dat" # download URL + +# Set a low value to boot faster. Default, wait 900 deciseconds (1min30sec) +PXEBOOTSRV_TIMEOUT="50" # Used only if PXEBOOTSRV_DOTFTPD="yes" +# You can append extra parameters +PXEBOOTSRV_EXTRA="" # Used only if PXEBOOTSRV_DOTFTPD="yes" + diff --git a/customcd/files/etc/dhcp/dhcpd.conf.rbruserver b/customcd/files/etc/dhcp/dhcpd.conf.rbruserver new file mode 100644 index 0000000..b6283f4 --- /dev/null +++ b/customcd/files/etc/dhcp/dhcpd.conf.rbruserver @@ -0,0 +1,101 @@ +# dhcpd.conf.rbruserver +# Rescue CD Backup & Restore Utility DHCP server configuration +# version 7.2.2 +# Rod Wright 6/20/2018 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +# see /usr/share/doc/dhcp*/dhcpd.conf.sample +# + +ddns-update-style interim; +ignore client-updates; + +class "rescuebruclients" { + match if substring(option host-name,0,9) = "rescuebru"; +} + +class "pxeclients" { + match if substring(option vendor-class-identifier, 0, 9) = "PXEClient"; + filename "/pxelinux.0"; +} + +subnet 10.111.1.0 netmask 255.255.255.0 { + option routers 10.111.1.1; + default-lease-time 21600; + max-lease-time 43200; + next-server 10.111.1.1; # IP addr of the TFTP server + allow booting; + allow bootp; + pool { + allow members of "rescuebruclients"; + range dynamic-bootp 10.111.1.100 10.111.1.199; + } +} + +subnet 10.111.2.0 netmask 255.255.255.0 { + option routers 10.111.2.1; + default-lease-time 21600; + max-lease-time 43200; + next-server 10.111.2.1; # IP addr of the TFTP server + allow booting; + allow bootp; + pool { + allow members of "rescuebruclients"; + range dynamic-bootp 10.111.2.100 10.111.2.199; + } +} + +subnet 10.111.3.0 netmask 255.255.255.0 { + option routers 10.111.3.1; + default-lease-time 21600; + max-lease-time 43200; + next-server 10.111.3.1; # IP addr of the TFTP server + allow booting; + allow bootp; + pool { + allow members of "rescuebruclients"; + range dynamic-bootp 10.111.3.100 10.111.3.199; + } +} + +subnet 10.111.4.0 netmask 255.255.255.0 { + option routers 10.111.4.1; + default-lease-time 21600; + max-lease-time 43200; + next-server 10.111.4.1; # IP addr of the TFTP server + allow booting; + allow bootp; + pool { + allow members of "rescuebruclients"; + range dynamic-bootp 10.111.4.100 10.111.4.199; + } +} + +subnet 10.111.5.0 netmask 255.255.255.0 { + option routers 10.111.5.1; + default-lease-time 21600; + max-lease-time 43200; + next-server 10.111.5.1; # IP addr of the TFTP server + allow booting; + allow bootp; + pool { + allow members of "rescuebruclients"; + range dynamic-bootp 10.111.5.100 10.111.5.199; + } +} + +subnet 10.111.6.0 netmask 255.255.255.0 { + option routers 10.111.6.1; + default-lease-time 21600; + max-lease-time 43200; + allow booting; + allow bootp; + next-server 10.111.6.1; # IP addr of the TFTP server + pool { + allow members of "rescuebruclients"; + range dynamic-bootp 10.111.6.100 10.111.6.199; + } +} + + diff --git a/customcd/files/etc/dhcp/dhcpd.conf.rbruserver.pxeboot b/customcd/files/etc/dhcp/dhcpd.conf.rbruserver.pxeboot new file mode 100644 index 0000000..13f3498 --- /dev/null +++ b/customcd/files/etc/dhcp/dhcpd.conf.rbruserver.pxeboot @@ -0,0 +1,91 @@ +# dhcpd.conf.rbruserver.pxeboot +# Rescue CD Backup & Restore Utility PXE DHCP server configuration +# version 7.2.2 +# Rod Wright 6/20/2018 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +# see /usr/share/doc/dhcp*/dhcpd.conf.sample +# + +ddns-update-style interim; +ignore client-updates; + +class "pxeclients" { + match if substring(option vendor-class-identifier, 0, 9) = "PXEClient"; + filename "/pxelinux.0"; +} + +subnet 10.111.1.0 netmask 255.255.255.0 { + option routers 10.111.1.1; + default-lease-time 21600; + max-lease-time 43200; + next-server 10.111.1.1; # IP addr of the TFTP server + allow booting; + allow bootp; + pool { + range dynamic-bootp 10.111.1.100 10.111.1.199; + } +} + +subnet 10.111.2.0 netmask 255.255.255.0 { + option routers 10.111.2.1; + default-lease-time 21600; + max-lease-time 43200; + next-server 10.111.2.1; # IP addr of the TFTP server + allow booting; + allow bootp; + pool { + range dynamic-bootp 10.111.2.100 10.111.2.199; + } +} + +subnet 10.111.3.0 netmask 255.255.255.0 { + option routers 10.111.3.1; + default-lease-time 21600; + max-lease-time 43200; + next-server 10.111.3.1; # IP addr of the TFTP server + allow booting; + allow bootp; + pool { + range dynamic-bootp 10.111.3.100 10.111.3.199; + } +} + +subnet 10.111.4.0 netmask 255.255.255.0 { + option routers 10.111.4.1; + default-lease-time 21600; + max-lease-time 43200; + next-server 10.111.4.1; # IP addr of the TFTP server + allow booting; + allow bootp; + pool { + range dynamic-bootp 10.111.4.100 10.111.4.199; + } +} + +subnet 10.111.5.0 netmask 255.255.255.0 { + option routers 10.111.5.1; + default-lease-time 21600; + max-lease-time 43200; + next-server 10.111.5.1; # IP addr of the TFTP server + allow booting; + allow bootp; + pool { + range dynamic-bootp 10.111.5.100 10.111.5.199; + } +} + +subnet 10.111.6.0 netmask 255.255.255.0 { + option routers 10.111.6.1; + default-lease-time 21600; + max-lease-time 43200; + allow booting; + allow bootp; + next-server 10.111.6.1; # IP addr of the TFTP server + pool { + range dynamic-bootp 10.111.6.100 10.111.6.199; + } +} + + diff --git a/customcd/files/etc/hal/fdi/information/media-check-disable-cdrom.fdi b/customcd/files/etc/hal/fdi/information/media-check-disable-cdrom.fdi new file mode 100644 index 0000000..e946639 --- /dev/null +++ b/customcd/files/etc/hal/fdi/information/media-check-disable-cdrom.fdi @@ -0,0 +1,10 @@ + + + + + + false + + + + diff --git a/customcd/files/etc/init.d/dhcpd b/customcd/files/etc/init.d/dhcpd new file mode 100644 index 0000000..2ef512c --- /dev/null +++ b/customcd/files/etc/init.d/dhcpd @@ -0,0 +1,120 @@ +#!/sbin/openrc-run +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +extra_commands="configtest" + +: ${DHCPD_CONF:=/etc/dhcp/${SVCNAME}.conf} + +depend() { + #need net + provide net + use logger dns +} + +get_var() { + local var="$(sed -n 's/^[[:blank:]]\?'"$1"' "*\([^#";]\+\).*/\1/p' "${chroot}${DHCPD_CONF}")" + echo ${var:-$2} +} + +setup_opts() { + DHCPD_CHROOT=${DHCPD_CHROOT%/} + + # Work out our cffile if it's in our DHCPD_OPTS + case " ${DHCPD_OPTS} " in + *" -cf "*) + DHCPD_CONF=" ${DHCPD_OPTS} " + DHCPD_CONF="${DHCPD_CONF##* -cf }" + DHCPD_CONF="${DHCPD_CONF%% *}" + ;; + *) DHCPD_OPTS="${DHCPD_OPTS} -cf ${DHCPD_CONF}" + ;; + esac +} + +checkconfig() { + set -- ${DHCPD_OPTS} -chroot "${DHCPD_CHROOT:-/}" -t + + dhcpd "$@" 1>/dev/null 2>&1 + local ret=$? + if [ ${ret} -ne 0 ] ; then + eerror "${SVCNAME} has detected a syntax error in your configuration files:" + dhcpd "$@" + fi + + return ${ret} +} + +configtest() { + setup_opts + + ebegin "Checking ${SVCNAME} configuration" + checkconfig + eend $? +} + +start() { + setup_opts + local chroot="${DHCPD_CHROOT}" + + if [ -n "${chroot}" ] ; then + # the config test want's these to exist + mkdir -p \ + "${chroot}"/var/run/dhcp \ + "${chroot}"/var/lib/dhcp \ + "${chroot}"/etc/dhcp + fi + + # see comment in get_var() above + if [ ! -f "${chroot}${DHCPD_CONF}" ] ; then + eerror "${chroot}${DHCPD_CONF} does not exist" + return 1 + fi + + checkconfig || return 1 + + checkpath -d -o dhcp:dhcp "${chroot}"/var/run/dhcp "${chroot}"/var/lib/dhcp + + local leasefile="$(get_var lease-file-name /var/lib/dhcp/${SVCNAME}.leases)" + checkpath -f -o dhcp:dhcp "${chroot}${leasefile}" + + # Setup LD_PRELOAD so name resolution works in our chroot. + if [ -n "${chroot}" ] ; then + checkpath -d -o root:root -m 755 "${chroot}"/dev "${chroot}"/etc "${chroot}"/proc + cp -pP /etc/localtime /etc/resolv.conf "${chroot}"/etc/ + export LD_PRELOAD="${LD_PRELOAD} libresolv.so libnss_dns.so" + if ! mountinfo -q "${chroot}/proc" ; then + mount --bind /proc "${chroot}/proc" + fi + fi + + local pidfile="$(get_var pid-file-name /var/run/dhcp/${SVCNAME}.pid)" + + ebegin "Starting ${chroot:+chrooted }${SVCNAME}" + start-stop-daemon --start --exec /usr/sbin/dhcpd \ + --pidfile "${chroot}/${pidfile}" \ + -- ${DHCPD_OPTS} -q -pf "${pidfile}" -lf "${leasefile}" \ + -user dhcp -group dhcp \ + -chroot "${chroot:-/}" ${DHCPD_IFACE} + eend $? \ + && save_options dhcpd_chroot "${chroot}" \ + && save_options pidfile "${pidfile}" +} + +stop() { + local chroot="$(get_options dhcpd_chroot)" + [ -z "${chroot}" ] && chroot="$(get_options chroot)" + + ebegin "Stopping ${chroot:+chrooted }${SVCNAME}" + start-stop-daemon --stop --exec /usr/sbin/dhcpd \ + --pidfile "${chroot}/$(get_options pidfile)" + res=$? + + if [ ${res} -eq 0 ] && [ -n "${chroot}" ] ; then + if mountinfo -q "${chroot}/proc" ; then + umount "${chroot}/proc" + fi + fi + + eend ${res} +} diff --git a/customcd/files/etc/init.d/dostartx b/customcd/files/etc/init.d/dostartx new file mode 100644 index 0000000..e32821c --- /dev/null +++ b/customcd/files/etc/init.d/dostartx @@ -0,0 +1,44 @@ +#!/sbin/runscript + +DAEMON="/usr/bin/xinit" +ARGS="/etc/X11/xinit/xinitrc" +PIDFILE="/var/run/dostartx.pid" +LOGFILE="/var/log/dostartx.log" +CWD="/root" + +totalmem=`free|grep Mem:|awk '{print $2}'` +if [ "$totalmem" -lt 500000 ]; then + if grep -q "autoruns=3" /proc/cmdline ; then + dotextonly=1 + fi +fi + +depend() { + after sysresccd +} + +start() { + if grep -q "dostartx" /proc/cmdline + then + if [ "$dotextonly" ] + then + ebegin "Not enough memory to start the graphical environment" + eend 0 + else + ebegin "Starting the graphical environment" + start-stop-daemon --start --quiet --user root --env SHELL="/bin/bash" --env PATH="$PATH:/root/rescuebru" \ + --pidfile $PIDFILE --exec $DAEMON --background --chdir $CWD \ + --stdout $LOGFILE --make-pidfile -- $ARGS + eend $? + fi + else + eend 0 + fi +} + +stop() { + ebegin "Stopping the graphical environment" + start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec $DAEMON + eend $? +} + diff --git a/customcd/files/etc/init.d/pxebootsrv b/customcd/files/etc/init.d/pxebootsrv new file mode 100644 index 0000000..dfc7d41 --- /dev/null +++ b/customcd/files/etc/init.d/pxebootsrv @@ -0,0 +1,187 @@ +#!/sbin/runscript +# Distributed under the terms of the GNU General Public License, v2 or later + +bootdir='/livemnt/boot' + +depend() +{ + need net +} + +start() +{ + ebegin "Starting the pxe-boot-server" + + # ---- check the cdrom files exist + if ! ls -l ${bootdir}/sysrcd.dat ${bootdir}/???linux/???linux.cfg >/dev/null 2>&1 + then + eerror "Files are missing, please check you are running a valid SystemRescueCd" + return 1 + fi + + # ---- check the config file exists + if [ ! -f /etc/conf.d/pxebootsrv ] + then + eerror "The pxebootsrv configuration file \"/etc/conf.d/pxebootsrv\" does not exists. Cannot continue." + return 1 + fi + + # ---- check the major options are set to 'yes' or 'no' + if [ $PXEBOOTSRV_DODHCPD != "yes" ] && [ $PXEBOOTSRV_DODHCPD != "no" ] + then + eerror "Invalid value for PXEBOOTSRV_DODHCPD. Must be \"yes\" or \"no\" (lowercase)." + return 1 + fi + + if [ $PXEBOOTSRV_DOTFTPD != "yes" ] && [ $PXEBOOTSRV_DOTFTPD != "no" ] + then + eerror "Invalid value for PXEBOOTSRV_DOTFTPD. Must be \"yes\" or \"no\" (lowercase)." + return 1 + fi + + if [ $PXEBOOTSRV_DOHTTPD != "yes" ] && [ $PXEBOOTSRV_DOHTTPD != "no" ] + then + eerror "Invalid value for PXEBOOTSRV_DOHTTPD. Must be \"yes\" or \"no\" (lowercase)." + return 1 + fi + + if [ $PXEBOOTSRV_DONFSD != "yes" ] && [ $PXEBOOTSRV_DONFSD != "no" ] + then + eerror "Invalid value for PXEBOOTSRV_DONFSD. Must be \"yes\" or \"no\" (lowercase)." + return 1 + fi + + if [ $PXEBOOTSRV_DODHCPD == "yes" ] + then + # ---- prepare /etc/dhcp/dhcpd.conf from /etc/conf.d/pxebootsrv + [ -f /etc/dhcp/dhcpd.conf ] && cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.bak + cp /etc/dhcp/dhcpd.orig /etc/dhcp/dhcpd.conf + + if [ -z "$PXEBOOTSRV_SUBNET" -o -z "$PXEBOOTSRV_NETMASK" ] + then + eerror "Invalid values for PXEBOOTSRV_SUBNET or PXEBOOTSRV_NETMASK" + return 1 + else + sed -i -e "s/subnet 192.168.1.0 netmask 255.255.255.0/subnet $PXEBOOTSRV_SUBNET netmask $PXEBOOTSRV_NETMASK/" /etc/dhcp/dhcpd.conf + sed -i -e "s/option subnet-mask 255.255.255.0;/option subnet-mask $PXEBOOTSRV_NETMASK;/" /etc/dhcp/dhcpd.conf + fi + + if [ -z "$PXEBOOTSRV_DEFROUTE" ] + then + eerror "The config variable PXEBOOTSRV_DEFROUTE is missing" + return 1 + else + sed -i -e "s/option routers 192.168.1.254;/option routers $PXEBOOTSRV_DEFROUTE;/" /etc/dhcp/dhcpd.conf + fi + + if [ -z "$PXEBOOTSRV_DHCPRANGE" ] + then + eerror "The config variable PXEBOOTSRV_DHCPRANGE is missing" + return 1 + else + sed -i -e "s/range dynamic-bootp 192.168.1.100 192.168.1.150;/range dynamic-bootp $PXEBOOTSRV_DHCPRANGE;/" /etc/dhcp/dhcpd.conf + fi + + if [ -z "$PXEBOOTSRV_TFTPSERVER" ] + then + eerror "The config variable PXEBOOTSRV_TFTPSERVER is missing" + return 1 + else + sed -i -e "s/next-server 192.168.1.5;/next-server $PXEBOOTSRV_TFTPSERVER;/" /etc/dhcp/dhcpd.conf + fi + + if [ -n "$PXEBOOTSRV_DNS" ] + then + sed -i -e "s/option domain-name-servers 192.168.1.254;/option domain-name-servers $PXEBOOTSRV_DNS;/" /etc/dhcp/dhcpd.conf + fi + fi + + if [ $PXEBOOTSRV_DOTFTPD == "yes" ] + then + # ---- prepare pxelinux config file + [ ! -d /tftpboot/pxelinux.cfg ] && mkdir -p /tftpboot/pxelinux.cfg + [ ! -f /tftpboot/pxelinux.0 ] && cp /usr/share/syslinux/pxelinux.0 /tftpboot/ + [ -f /tftpboot/pxelinux.cfg/default.bak ] && rm -f /tftpboot/pxelinux.cfg/default.bak + [ -f /tftpboot/pxelinux.cfg/default ] && mv /tftpboot/pxelinux.cfg/default /tftpboot/pxelinux.cfg/default.bak + cp --remove-destination ${bootdir}/???linux/{*msg,*c32,*.0,memdisk,netboot} /tftpboot/ + cp --remove-destination ${bootdir}/???linux/???linux.cfg /tftpboot/pxelinux.cfg/default + if [ -n "$PXEBOOTSRV_TIMEOUT" ] + then + sed -i -e "s!^TIMEOUT .*!TIMEOUT $PXEBOOTSRV_TIMEOUT!i" /tftpboot/pxelinux.cfg/default + fi + sed -i -e "s!scandelay=1!scandelay=5 netboot=$PXEBOOTSRV_HTTPSERVER ${PXEBOOTSRV_EXTRA}!g" /tftpboot/pxelinux.cfg/default + fi + + # ---- start the NFS server + if [ $PXEBOOTSRV_DONFSD == "yes" ] + then + # ---- nfs export /tftpboot + touch /etc/exports + sed -i -e 's!^/tftpboot!#/tftpboot!g' /etc/exports + echo "/tftpboot *(fsid=0,ro,no_subtree_check,all_squash,insecure,anonuid=1000,anongid=1000)" >> /etc/exports + fi + + # ---- stop network manager to avoid conflicts + /etc/init.d/NetworkManager stop + + # ---- bring up network interface + ifconfig $PXEBOOTSRV_IF $PXEBOOTSRV_LOCALIP/24 + + # ---- start the DHCPD service + if [ $PXEBOOTSRV_DODHCPD == "yes" ] + then + /etc/init.d/dhcpd restart + if [ "$?" != "0" ] + then + eerror "Cannot start /etc/init.d/dhcpd, check /var/log/messages" + return 1 + fi + fi + + # ---- start the THTTPD service + if [ $PXEBOOTSRV_DOHTTPD == "yes" ] + then + /etc/init.d/thttpd restart + if [ "$?" != "0" ] + then + eerror "Cannot start /etc/init.d/thttpd" + return 1 + fi + fi + + # ---- start the TFTPD service + if [ $PXEBOOTSRV_DOTFTPD == "yes" ] + then + /etc/init.d/in.tftpd restart + if [ "$?" != "0" ] + then + eerror "Cannot start /etc/init.d/in.tftpd" + return 1 + fi + fi + + # ---- start the NFS server + if [ $PXEBOOTSRV_DONFSD == "yes" ] + then + /etc/init.d/nfs restart + if [ "$?" != "0" ] + then + eerror "Cannot start /etc/init.d/nfs" + return 1 + fi + + fi + + return 0 +} + +stop() +{ + ebegin "Stopping the pxe-boot-server" + + /etc/init.d/thttpd stop + /etc/init.d/in.tftpd stop + /etc/init.d/dhcpd stop + + return 0 +} diff --git a/customcd/files/etc/init.d/sysresccd b/customcd/files/etc/init.d/sysresccd new file mode 100644 index 0000000..5a11f98 --- /dev/null +++ b/customcd/files/etc/init.d/sysresccd @@ -0,0 +1,128 @@ +#!/sbin/runscript + +source /sbin/livecd-functions.sh + +depend() +{ + before xdm autorun tigervnc + after pwgen sshd portmap hald +} + +start() +{ + ebegin "Performing the SystemRescueCd specific initializations" + + CMDLINE="$(cat /proc/cmdline)" + + # ---- create file /var/log/lastlog so that ssh does not complain in the logs ---- + touch /var/log/lastlog + + # ---- create various directories ---- + mkdir -p /var/log/samba + mkdir -p /var/cache/revdep-rebuild + mkdir -p /var/run/dhcp + chown dhcp:dhcp /var/run/dhcp + + # ---- disable screensaver in the console + setterm -blank 0 -powersave off + + # ---- auto-detect software raid ---- + [ -n "$(which mdadm)" ] && mdadm --auto-detect 2>&1 + + # ---- change the root password if requested in cmdline ---- + for curopt in ${CMDLINE} + do + if echo "${curopt}" | grep -q -E '^rootpass=[^ ]{1,32}$' + then + newpass="$(echo ${curopt} | sed -r -e 's!^rootpass=([^ ]{1,32})$!\1!g')" + ( echo root:${newpass} ) | chpasswd 1>/dev/null 2>&1 + fi + done + + # ---- options to start/stop services ---- + for curopt in ${CMDLINE} + do + if echo "${curopt}" | grep -q -E '^initscript=[a-zA-Z0-9]{1,32}:[a-z]{1,32}$' + then + touch /var/log/initscript.log + service="$(echo ${curopt} | sed -r -e 's!^initscript=([a-zA-Z0-9]{1,32}):([a-z]{1,32})$!\1!g')" + action="$(echo ${curopt} | sed -r -e 's!^initscript=([a-zA-Z0-9]{1,32}):([a-z]{1,32})$!\2!g')" + echo "initscript: found option ${curopt} (service=${service} and action=${action}" >| /var/log/initscript.log + if [ -x "/etc/init.d/${service}" ] + then + cmd="/etc/init.d/${service} ${action}" + ${cmd} > /var/log/initscript-${service}.log 2>&1 + res=$? + echo "initscript: ${cmd} --> ${res}" | tee -a /var/log/initscript.log + else + echo "initscript: /etc/init.d/${service} not found" | tee -a /var/log/initscript.log + fi + fi + done + + # ---- options to configure and start the vncserver ---- + # eg: "rescuecd vncserver=2:mYpAsWd" will create two vnc displays (display=1 on port 5900 and display=2 on port 5901) + # and the two displays will use the same password and the root user account (password=mYpAsWd) + # this option should be used only once, but in case of multiple usages the last vncserver option overwrite the previous ones + vnclog='/var/log/vncserver.log' + for curopt in ${CMDLINE} + do + case "${curopt}" in + vncserver\=*) + echo '' >| ${vnclog} + vncopt="$(echo ${curopt} | cut -d= -f2)" + echo "vncserver: found option vncserver=${vncopt}" | tee -a ${vnclog} + if echo "${vncopt}" | grep -q -E '^[1-9]:[^ ]{6,12}$' + then + [ -f /root/.vnc/passwd ] && rm -f /root/.vnc/passwd + [ ! -d /root/.vnc ] && mkdir -p /root/.vnc + sed -i -e 's!^DISPLAYS=.*!!g' /etc/conf.d/tigervnc + displaycnt="$(echo ${curopt} | sed -r -e 's!^vncserver=([1-9]):([^ ]{6,12})$!\1!g')" + password="$(echo ${curopt} | sed -r -e 's!^vncserver=([1-9]):([^ ]{6,12})$!\2!g')" + echo "vncserver: ${displaycnt} displays will be created" | tee -a ${vnclog} + echo "vncserver: creating password file in /root/.vnc/passwd:" >>${vnclog} + echo -e "${password}\n${password}\n" | vncpasswd /root/.vnc/passwd >>${vnclog} 2>&1 + + chmod 600 /root/.vnc/passwd + echo "exec /usr/bin/startxfce4 >/dev/null 2>&1" >| /root/.vnc/xstartup + chmod 700 /root/.vnc/xstartup + displayopt='' + for ((i=1; i <= displaycnt; i++)) + do + echo "vncserver: preparing display number $i" | tee -a ${vnclog} + displayopt="${displayopt} root:$i" + displayopt="$(echo ${displayopt} | sed -e 's!^ !!g' | sed -e 's! $!!g')" + done + echo "DISPLAYS=\"${displayopt}\"" >> /etc/conf.d/tigervnc + else + echo "vncserver: invalid syntax (expected \"vncserver=x:mYpAsWd\")" + echo " where x is the number of displays (1 or 2 in general)" + echo " mYpAsWd is a password (between 6 and 12 characters)" + sleep 2 + fi + ;; + esac + done + + # ---- clean /etc/mtab ---- + if grep -q -F 'tmpfs /newroot' /etc/mtab + then + rm -f /etc/mtab.bak + cp /etc/mtab /etc/mtab.bak + sed -i -e "/ \/newroot/d" /etc/mtab + fi + + # ---- create a kernel options file ---- + if [ -f /proc/config.gz ] + then + cat /proc/config.gz | gzip -d > /root/kernel-$(uname -r).conf + fi + + # ---- fix inittab for serial consoles + livecd_fix_inittab + /sbin/telinit q &>/dev/null + + # ---- mount tmpfs (important for backing store) + mount -t tmpfs tmpfs /tmp +} + diff --git a/customcd/files/etc/profile b/customcd/files/etc/profile new file mode 100644 index 0000000..4f44b5c --- /dev/null +++ b/customcd/files/etc/profile @@ -0,0 +1,69 @@ +# /etc/profile: login shell setup +# +# That this file is used by any Bourne-shell derivative to setup the +# environment for login shells. +# + +# Load environment settings from profile.env, which is created by +# env-update from the files in /etc/env.d +if [ -e /etc/profile.env ] ; then + . /etc/profile.env +fi + +# You should override these in your ~/.bashrc (or equivalent) for per-user +# settings. For system defaults, you can add a new file in /etc/profile.d/. +export EDITOR=${EDITOR:-/bin/nano} +export PAGER=${PAGER:-/usr/bin/less} + +# 077 would be more secure, but 022 is generally quite realistic +umask 022 + +# Set up PATH depending on whether we're root or a normal user. +# There's no real reason to exclude sbin paths from the normal user, +# but it can make tab-completion easier when they aren't in the +# user's PATH to pollute the executable namespace. +# +# It is intentional in the following line to use || instead of -o. +# This way the evaluation can be short-circuited and calling whoami is +# avoided. +if [ "$EUID" = "0" ] || [ "$USER" = "root" ] ; then + PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/rescuebru:${ROOTPATH}" +else + PATH="/usr/local/bin:/usr/bin:/bin:/root/rescuebru:${PATH}" +fi +export PATH +unset ROOTPATH + +if [ -n "${BASH_VERSION}" ] ; then + # Newer bash ebuilds include /etc/bash/bashrc which will setup PS1 + # including color. We leave out color here because not all + # terminals support it. + if [ -f /etc/bash/bashrc ] ; then + # Bash login shells run only /etc/profile + # Bash non-login shells run only /etc/bash/bashrc + # Since we want to run /etc/bash/bashrc regardless, we source it + # from here. It is unfortunate that there is no way to do + # this *after* the user's .bash_profile runs (without putting + # it in the user's dot-files), but it shouldn't make any + # difference. + . /etc/bash/bashrc + else + PS1='\u@\h \w \$ ' + fi +else + # Setup a bland default prompt. Since this prompt should be useable + # on color and non-color terminals, as well as shells that don't + # understand sequences such as \h, don't put anything special in it. + PS1="${USER:-$(type whoami >/dev/null && whoami)}@$(type uname >/dev/null && uname -n) \$ " +fi + +for sh in /etc/profile.d/*.sh ; do + [ -r "$sh" ] && . "$sh" +done +unset sh +alias cp='cp -i' +alias mv='mv -i' +alias rm='rm -i' +alias ls='ls --color=auto' +alias ll='ls -l' +alias grep='grep --color=auto' diff --git a/customcd/files/etc/zsh/zprofile b/customcd/files/etc/zsh/zprofile new file mode 100644 index 0000000..1750c29 --- /dev/null +++ b/customcd/files/etc/zsh/zprofile @@ -0,0 +1,44 @@ +# /etc/zsh/zprofile +# $Header: /mnt/raid/cvsroot/rescuebru/customcd/files/etc/zsh/Attic/zprofile,v 1.1.2.1.2.4 2010/12/22 19:42:04 rwright Exp $ + +# Load environment settings from profile.env, which is created by +# env-update from the files in /etc/env.d +if [ -e /etc/profile.env ] ; then + . /etc/profile.env +fi + +# You should override these in your ~/.zprofile (or equivalent) for per-user +# settings. For system defaults, you can add a new file in /etc/profile.d/. +export EDITOR=${EDITOR:-/bin/nano} +export PAGER=${PAGER:-/usr/bin/less} + +# 077 would be more secure, but 022 is generally quite realistic +umask 022 + +# Set up PATH depending on whether we're root or a normal user. +# There's no real reason to exclude sbin paths from the normal user, +# but it can make tab-completion easier when they aren't in the +# user's PATH to pollute the executable namespace. +# +# It is intentional in the following line to use || instead of -o. +# This way the evaluation can be short-circuited and calling whoami is +# avoided. +if [ "$EUID" = "0" ] || [ "$USER" = "root" ] ; then + PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${ROOTPATH}" +else + PATH="/usr/local/bin:/usr/bin:/bin:${PATH}" +fi +# Add /root/rescuebru and /root to all paths +PATH="${PATH}:/root/rescuebru" +PATH="${PATH}:/root" +export PATH +unset ROOTPATH + +shopts=$- +setopt nullglob +for sh in /etc/profile.d/*.sh ; do + [ -r "$sh" ] && . "$sh" +done +unsetopt nullglob +set -$shopts +unset sh shopts diff --git a/customcd/files/lib/udev/rules.d/60-cdrom_id.rules b/customcd/files/lib/udev/rules.d/60-cdrom_id.rules new file mode 100644 index 0000000..61ab013 --- /dev/null +++ b/customcd/files/lib/udev/rules.d/60-cdrom_id.rules @@ -0,0 +1,20 @@ +# do not edit this file, it will be overwritten on update + +ACTION=="remove", GOTO="cdrom_end" +SUBSYSTEM!="block", GOTO="cdrom_end" +KERNEL!="sr[0-9]*|xvd*", GOTO="cdrom_end" +ENV{DEVTYPE}!="disk", GOTO="cdrom_end" + +# unconditionally tag device as CDROM +KERNEL=="sr[0-9]*", ENV{ID_CDROM}="1" + +# media eject button pressed +ENV{DISK_EJECT_REQUEST}=="?*", RUN+="/usr/bin/eject $devnode", GOTO="cdrom_end" + +# import device and media properties and lock tray to +# enable the receiving of media eject button events +IMPORT{program}="cdrom_id --lock-media $devnode" + +KERNEL=="sr0", SYMLINK+="cdrom", OPTIONS+="link_priority=-100" + +LABEL="cdrom_end" diff --git a/customcd/files/lib/udev/rules.d/60-persistent-storage.rules b/customcd/files/lib/udev/rules.d/60-persistent-storage.rules new file mode 100644 index 0000000..40b4eb9 --- /dev/null +++ b/customcd/files/lib/udev/rules.d/60-persistent-storage.rules @@ -0,0 +1,91 @@ +# do not edit this file, it will be overwritten on update + +# persistent storage links: /dev/disk/{by-id,by-uuid,by-label,by-path} +# scheme based on "Linux persistent device names", 2004, Hannes Reinecke + +# forward scsi device event to corresponding block device +ACTION=="change", SUBSYSTEM=="scsi", ENV{DEVTYPE}=="scsi_device", TEST=="block", ATTR{block/*/uevent}="change" + +ACTION=="remove", GOTO="persistent_storage_end" + +# enable in-kernel media-presence polling +ACTION=="add", SUBSYSTEM=="module", KERNEL=="block", ATTR{parameters/events_dfl_poll_msecs}=="0", ATTR{parameters/events_dfl_poll_msecs}="2000" +ACTION=="add", ATTR{removable}=="1", ATTR{events_poll_msecs}=="-1", ATTR{events_poll_msecs}="2000" + +SUBSYSTEM!="block", GOTO="persistent_storage_end" + +# skip rules for inappropriate block devices +KERNEL=="fd*|mtd*|nbd*|gnbd*|btibm*|dm-*|md*|zram*", GOTO="persistent_storage_end" + +# ignore partitions that span the entire disk +TEST=="whole_disk", GOTO="persistent_storage_end" + +# for partitions import parent information +ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_*" + +# virtio-blk +KERNEL=="vd*[!0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}" +KERNEL=="vd*[0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}-part%n" + +# ATA devices using the "scsi" subsystem +KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", IMPORT{program}="ata_id --export $devnode" +# ATA/ATAPI devices (SPC-3 or later) using the "scsi" subsystem +KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{type}=="5", ATTRS{scsi_level}=="[6-9]*", IMPORT{program}="ata_id --export $devnode" + +# Run ata_id on non-removable USB Mass Storage (SATA/PATA disks in enclosures) +KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", ATTR{removable}=="0", SUBSYSTEMS=="usb", IMPORT{program}="ata_id --export $devnode" +# Otherwise, fall back to using usb_id for USB devices +KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", IMPORT{builtin}="usb_id" + +# scsi devices +KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $devnode", ENV{ID_BUS}="scsi" +KERNEL=="cciss*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $devnode", ENV{ID_BUS}="cciss" +KERNEL=="sd*|sr*|cciss*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}" +KERNEL=="sd*|cciss*", ENV{DEVTYPE}=="partition", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}-part%n" + +# firewire +KERNEL=="sd*[!0-9]|sr*", ATTRS{ieee1394_id}=="?*", SYMLINK+="disk/by-id/ieee1394-$attr{ieee1394_id}" +KERNEL=="sd*[0-9]", ATTRS{ieee1394_id}=="?*", SYMLINK+="disk/by-id/ieee1394-$attr{ieee1394_id}-part%n" + +KERNEL=="mmcblk[0-9]", SUBSYSTEMS=="mmc", ATTRS{name}=="?*", ATTRS{serial}=="?*", ENV{ID_NAME}="$attr{name}", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}" +KERNEL=="mmcblk[0-9]p[0-9]", ENV{ID_NAME}=="?*", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}-part%n" +KERNEL=="mspblk[0-9]", SUBSYSTEMS=="memstick", ATTRS{name}=="?*", ATTRS{serial}=="?*", ENV{ID_NAME}="$attr{name}", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/memstick-$env{ID_NAME}_$env{ID_SERIAL}" +KERNEL=="mspblk[0-9]p[0-9]", ENV{ID_NAME}=="?*", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/memstick-$env{ID_NAME}_$env{ID_SERIAL}-part%n" + +# by-path (parent device path) +ENV{DEVTYPE}=="disk", DEVPATH!="*/virtual/*", IMPORT{builtin}="path_id" +ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}" +ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}-part%n" + +# skip unpartitioned removable media devices from drivers which do not send "change" events +ENV{DEVTYPE}=="disk", KERNEL!="sd*|sr*", ATTR{removable}=="1", GOTO="persistent_storage_end" + +# probe filesystem metadata of optical drives which have a media inserted +KERNEL=="sr*", ENV{DISK_EJECT_REQUEST}!="?*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="?*", \ + IMPORT{builtin}="blkid --offset=$env{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}" +# single-session CDs do not have ID_CDROM_MEDIA_SESSION_LAST_OFFSET +KERNEL=="sr*", ENV{DISK_EJECT_REQUEST}!="?*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="", \ + IMPORT{builtin}="blkid --noraid" + +# probe filesystem metadata of disks +KERNEL!="sr*", IMPORT{builtin}="blkid" + +# watch metadata changes by tools closing the device after writing +KERNEL!="sr*", OPTIONS+="watch" + +# by-label/by-uuid links (filesystem metadata) +ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" +ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" + +# by-id (World Wide Name) +ENV{DEVTYPE}=="disk", ENV{ID_WWN_WITH_EXTENSION}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN_WITH_EXTENSION}" +ENV{DEVTYPE}=="partition", ENV{ID_WWN_WITH_EXTENSION}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN_WITH_EXTENSION}-part%n" + +# by-partlabel/by-partuuid links (partition metadata) +ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_ENTRY_UUID}=="?*", SYMLINK+="disk/by-partuuid/$env{ID_PART_ENTRY_UUID}" +ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_ENTRY_NAME}=="?*", SYMLINK+="disk/by-partlabel/$env{ID_PART_ENTRY_NAME}" + +# add symlink to GPT root disk +ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_GPT_AUTO_ROOT}=="1", SYMLINK+="gpt-auto-root" + +LABEL="persistent_storage_end" diff --git a/customcd/files/root/autorun1 b/customcd/files/root/autorun1 new file mode 100644 index 0000000..8735d44 --- /dev/null +++ b/customcd/files/root/autorun1 @@ -0,0 +1,16 @@ +#!/bin/bash +# autorun1 +# Rescue CD Backup & Restore Utility text client startup +# version 7.2.5 +# Rod Wright 1/16/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +/etc/init.d/NetworkManager stop +export PATH=$PATH:/root/rescuebru +rm -f /root/.zshrc +rm -f /root/.bashrc +cp /root/zshrc.rescuebru /root/.zshrc +cp /root/bashrc.rescuebru /root/.bashrc + + diff --git a/customcd/files/root/autorun2 b/customcd/files/root/autorun2 new file mode 100644 index 0000000..bc0efac --- /dev/null +++ b/customcd/files/root/autorun2 @@ -0,0 +1,16 @@ +#!/bin/bash +# autorun2 +# Rescue CD Backup & Restore Utility server startup +# version 7.2.5 +# Rod Wright 1/16/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +/etc/init.d/NetworkManager stop +export PATH=$PATH:/root/rescuebru +rm -f /root/.config/autostart/Terminal.desktop +cp /root/rbruserver.desktop /root/.config/autostart/ +rm -f /root/.config/autostart/Terminal.desktop +/usr/bin/eject >/dev/null 2>&1 + + diff --git a/customcd/files/root/autorun3 b/customcd/files/root/autorun3 new file mode 100644 index 0000000..43b78b5 --- /dev/null +++ b/customcd/files/root/autorun3 @@ -0,0 +1,25 @@ +#!/bin/bash +# autorun3 +# Rescue CD Backup & Restore Utility graphical client startup +# version 7.2.5 +# Rod Wright 1/16/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +/etc/init.d/NetworkManager stop +export PATH=$PATH:/root/rescuebru + +totalmem=`free|grep Mem:|awk '{print $2}'` + +if [ "$totalmem" -lt 1000000 ]; then + rm -f /root/.zshrc + rm -f /root/.bashrc + cp /root/zshrc.rescuebru /root/.zshrc + cp /root/bashrc.rescuebru /root/.bashrc +else + rm -f /root/.config/autostart/Terminal.desktop + cp /root/xrescuebru.desktop /root/.config/autostart/ + rm -f /root/.config/autostart/Terminal.desktop + /usr/bin/eject >/dev/null 2>&1 +fi + diff --git a/customcd/files/root/autorun4 b/customcd/files/root/autorun4 new file mode 100644 index 0000000..e6dc6ce --- /dev/null +++ b/customcd/files/root/autorun4 @@ -0,0 +1,12 @@ +#!/bin/bash +# autorun4 +# Rescue CD Backup & Restore Utility PXE boot server startup +# version 7.2.5 +# Rod Wright 1/16/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +/etc/init.d/NetworkManager stop +export PATH=$PATH:/root/rescuebru +/etc/init.d/pxebootsrv start + diff --git a/customcd/files/root/bashrc.rbruserver b/customcd/files/root/bashrc.rbruserver new file mode 100644 index 0000000..9f11a48 --- /dev/null +++ b/customcd/files/root/bashrc.rbruserver @@ -0,0 +1,25 @@ +#!/bin/bash +# bashrc.rbruserver +# Rescue CD Backup & Restore Utility server bash configuration +# version 7.2.5 +# Rod Wright 1/16/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +if [ ! "$(grep nox /proc/cmdline)" ] +then + if [ -x /usr/bin/X ] + then + if [ -e /etc/startx ] + then + rm -f /etc/startx + source /etc/profile ##STARTX##STARTX su - -c startx + [ -f /etc/motd ] && cat /etc/motd + fi + fi +fi + +# Start rbruserver +if [ `/usr/bin/tty` = "/dev/tty1" ]; then + /root/rescuebru/rbruserver +fi diff --git a/customcd/files/root/bashrc.rescuebru b/customcd/files/root/bashrc.rescuebru new file mode 100644 index 0000000..c4f8a87 --- /dev/null +++ b/customcd/files/root/bashrc.rescuebru @@ -0,0 +1,28 @@ +#!/bin/bash +# bashrc.rescuebru +# Rescue CD Backup & Restore Utility client bash configuration +# version 7.2.5 +# Rod Wright 1/16/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +if [ ! "$(grep nox /proc/cmdline)" ] +then + if [ -x /usr/bin/X ] + then + if [ -e /etc/startx ] + then + rm -f /etc/startx + source /etc/profile ##STARTX##STARTX su - -c startx + [ -f /etc/motd ] && cat /etc/motd + fi + fi +fi + +# Eject the CD +/usr/bin/eject >/dev/null 2>&1 + +# Start rescuebru +if [ `/usr/bin/tty` = "/dev/tty1" ]; then + /root/rescuebru/rescuebru +fi diff --git a/customcd/files/root/rb_version b/customcd/files/root/rb_version new file mode 100644 index 0000000..8aea167 --- /dev/null +++ b/customcd/files/root/rb_version @@ -0,0 +1 @@ +7.2.5 diff --git a/customcd/files/root/rbruserver.desktop b/customcd/files/root/rbruserver.desktop new file mode 100644 index 0000000..d7758e3 --- /dev/null +++ b/customcd/files/root/rbruserver.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=0.9.4 +Type=Application +Name=xrescuebru +Comment= +Exec=/root/rescuebru/xrbruserver.sh +OnlyShowIn=XFCE; +StartupNotify=false +Terminal=false +Hidden=false diff --git a/customcd/files/root/rescuebru/CHANGELOG b/customcd/files/root/rescuebru/CHANGELOG new file mode 100644 index 0000000..9e2c6ff --- /dev/null +++ b/customcd/files/root/rescuebru/CHANGELOG @@ -0,0 +1,438 @@ +RescueBRU System - Rescue CD Backup & Restore Utility Rod Wright +CHANGELOG +######################################################################## +General changes: +------------------------------------------------------------------------ +02/11/2016 - 7.2.1 - Changed default startup mode from text mode to +graphical (Xorg) mode. Fixed some things that were missing from the boot +menu and re-ordered options to make more sense. Created a /mnt/usb +directory so some procedures would work correctly. Updated the RescueBRU +User Guide to reflect changes. + +06/27/2018 - 7.2.2 - Updated System Rescue CD version to 5.2.2 to +provide kernel support for newer hardware. + +03/19/2021 - 7.2.3 - No changes. + +09/21/2021 - 7.2.4 - No changes. + +01/19/2024 - 7.2.5 - Changed scripts in /etc/init.d to prevent dhcpcd +from running automatically at boot. This makes RescueBRU play nice in +networks with other DHCP servers by not unnecessarily grabbing up leases +unnecessarily. We will let rescuebru.sh acquire addresses later under +its own control. + +######################################################################## +rescuebru.sh: +------------------------------------------------------------------------ +05/06/08 - 1.0 - Initial Release + +05/09/08 - 1.1 - Added prompting for MBRs and partitions. Added +Help. Added media creation. + +05/16/08 - 1.2 - Fixed bug where partition array was not being +created correctly when multiple drives were present. Added error +detection on backup and restore. Added backup media capacity +detection and warning. Added backup and restore of extended +partition information. Updated help files. + +05/24/08 - 2.0 - Added support for HP CISS controller devices. Added +NFS media support. + +06/05/08 - 2.1 - Added support for Adaptec I2O SCSI controller +devices. Improved client IP address deconfliction. Added support to +restore linux swap partitions. Fixed unreliable detection of +extended partitions. + +06/10/08 - 2.2 - Added "-M" (--no-mbr) to PI_BACKUP_ARGS for +partimage since it was causing trouble with Adaptec I2O controller, +and we back up MBRs separately anyway. + +06/12/08 - 2.3 - Added "--force" option to arguments for sfdisk +restoration to prevent failure caused by restoring existing table. + +07/01/08 - 2.4 - Added line to kill off netplugd before we start, +since we don't need it and it interferes with server detection on +some machines. Added support for backing up to a local directory. + +07/02/08 - 2.5 - Added a 5 second sleep after setting up a network +interface to give any network switches time to recognize and route +us properly. + +07/23/08 - 2.6 - Improved Local media type for general use. Added +integration with new rbruserver script. Fixed main menu to catch +garbage user input. + +08/13/08 - 3.0 - Upgraded sysresccd to version 1.0.4. Improved exit +options. Now you can exit to shell, exit and reboot, or exit and +power off. Added operation logging so it's easy to tell if something +failed. Added backup method menu. Standard is dd/sfdisk/partimage. +Verbatim is dd of whole drive, compressed and split into 2G files. + +05/13/09 - 3.1 - Fixed net_setup function to stop testing interfaces +after it finds a working one. Create /var/lib/nfs/state file so nfs +startup script won't complain. Removed Adaptec i2o specific code +since sysresccd version 1.0.4 names the devices correctly. NOTE: +BACKUPS DONE WITH VERSIONS OF RESCUEBRU PRIOR TO 3.0 THAT CONTAIN +I2O DEVICES CANNOT BE RESTORED WITH VERSIONS 3.0 OR LATER. REDO +THOSE BACKUPS! Fixed bug where a failure to find a server loops you +back through the net setup code again. Removed prompts to save log +file when rebooting or powering down since anything saved in the +ramdisk will disappear anyway. Added option to view log files on +backup media. + +10/22/09 - 4.0 - Added progress indicating for verbatim +backups/restores. Removed arbitrary limit to number of clients +(since it was easy to fool anyway). Added conv=sync,noerror to dd +arguments in vbbackup function to ignore disk errors and replace bad +blocks with nulls. Shortened timeouts in the network code to speed +things up a bit. Changed network interface scanning to start with +short timeouts and gradually increase them so we can work with slow +NICs, but not take too long on fast ones. Added a prompt for the +initial IP address so that multiple users can work on the same +network without IP collisions. Removed the backup media and backup +method submenus and replaced them with simple prompts to make them +less unwieldy. Moved the restore and backup processes out of the +main menu and into functions. Fixed bug that caused incorrect +behavior when "quit" was supplied as an image name. Removed prompt +to save temporary log file on exit to shell. Save temporary log by +default. Removed prompting to save a log with the backup. It's a +good idea to save the logs and sometimes it was accidentally not +saved. Fixed bug in logview function that caused weird behavior on +subsequent calls of the function. Don't delete existing backup +before starting new one, so if something goes wrong, we're not +screwed. When prompting for IP addresses, after the backup server +address, only prompt for the host byte to make entries easier. + +2/16/10 - 4.1 - At end of backup, copy new backup over old one +before displaying log to avoid long delays. Detect and abort on NFS +share mount failure. In function net_setup(), ping more during +"determine ip" phase to accommodate slower hardware. In function +mbrrestore(), removed untrue statement that associated partitions +couldn't be restored. At beginning of function net_setup(), unmount +any stale NFS mounts and take down any interfaces that are already +up. Put "then" and "do" on the same line as their starting +statements so auto-indent works properly in IDE. Fixed bug where +status file wasn't getting written if $remote_dir was different than +$MEDIA_MNT_DIR. In function net_setup(), improve interface scanning +to increase the number of pings in each step and decrease the number +of steps since some slower NICs were still not coming up. In +function net_setup, changed sleeps and pings wherever link is +brought up to sleep and ping longer based on the timeout required to +find the server. This should prevent NFS mounts from failing on slow +NICs. Modified function partbackup() to save UUID info to image file +for linux swap partitions. Included static binary mkswap-uuid to +enable setting UUID on swap partitions. Modified function +partrestore() to set UUID when restoring swap if UUID info is +available, otherwise let mkswap generate one. This prevents swap +mount failure on distributions (like Ubuntu) that mount swap based +on UUID instead of device name. + +2/25/10 - 5.0 - Updated System Rescue CD to version 1.3.5. Stripped +unneeded packages to get iso size down enough to run docache by +default. Added docache and lowmem as boot parameters. Edited +/bin/bashlogin and f1boot.msg to reflect new versions/dates. Added +code to mbrbackup(), partbackup(), and vbbackup() functions to save +output of fdisk -l for each drive for comparison on restore. Added +code to driveselect() and partselect() funtions to compare sizes of +original and current drives and issue warnings as required. + +6/11/10 - 5.1 - Moved CHANGELOG off to a separate file since it was +getting so huge. Found that Adaptec i2o support is a moving target. +With the current kernel, it's back to /dev/i2o/hdXX. Put the i2o +specific code that I pulled out for version 3.1 back in. IF YOU HAVE +BACKUPS OF MACHINES USING ADAPTEC I2O CONTROLLERS THAT WERE DONE +SINCE VERSION 4.0, YOU WILL NEED TO MANUALLY RENAME THE FILES IN +THOSE BACKUPS TO REFLECT THE NEW DEVICE NAMES, OR JUST DO NEW +BACKUPS! Added option to select what you want to do after a +successful backup or restore (return to menu, reboot, or shut down). +Reworked dobackup() and dorestore() to remove excessive loop +nesting. Fixed bug where new backups log files were getting dumped +into the $IMAGE_PATH directory. Added the ability to abort network +scanning after the normal scan so you don't have to wait for the +long and extra long scans to complete to get back to the menu. + +9/9/10 - 6.0 - Updated System Rescue CD to version 1.5.8. Set up +boot menu and autoruns to eliminate typing commands at shell +prompts. Fixed bug in rescuebru.sh netscan_timeout() where pressing +a didn't abort scan. Added scripts to rename backups when the +Adaptec i2o driver changes device names. If you get errors when +trying to restore like "device not found", run the appropriate +script on the server to fix things. Added PXE boot server +capability to rbruserver. + +1/6/11 - 6.1 - Updated System Rescue CD to version 1.6.4 to get +updated tg3 driver. In rescuebru.sh, updated vbbackup() and +vbrestore() to use pv for progress indication. + +11/29/11 - 6.2 - Swap partitions created with old versions of mkswap +didn't have UUIDs, so on backup, the file generated by blkid didn't +contain UUID. This caused failure on restore. Fixed the swap +creation in rescuebru.sh:partrestore() to detect this condition and +do the right thing. If aborting network scanning once, was unable to +abort it in subsequent passes. In rescuebru.sh, fixed +netscan_timeout() to unset the $nsa loop control variable at start. +Fixed some typos in isolinux.cfg. + +7/3/12 - 6.3 - Added flush_input() function to drop spurious user +input between prompts. Added y_or_n() function to standardize, +simplify, and validate yes or no prompting. Removed mkswap-uuid +since new mkswap implements UUID setting. Removed ddprog since we +don't use it any more. Renamed backup methods to reflect what they +actually do. Added inline help for media type and backup method +selections. Added fsarchiver backup method. Fixed bug where USB +backup media wasn't being excluded from drive/partition selection +prompting. Fixed bug where the initial boot menu wasn't starting the +pxeboot server when option 7 was selected. Modified the build tools +to put a copy of /root/rescuebru in the root of the ISO file system +so you could see the scripts without having to boot the CD. + +9/14/12 - 6.3.1 - Added check_route() function to work around slow +behavior of certain Cisco switches in setting up routes. + +1/16/13 - 7.0 - Added function to display selected actions before +beginning an operation and prompt for confirmation. Also check for a +backup where nothing is selected. Previously, this would succeed, +resulting in a backup of nothing potentially overwriting an existing +backup. Added clone.sh and blank.sh command line utilities. +Integrated those two utilities into the RescueBRU menu structure. +Moved functions that have a common usage among various RescueBRU +components to a separate functions.sh file. Integrated CHANGELOGs +from the multiple utilities into this file. Fixed bug where +arguments passed in from rbruserver were not being parsed correctly +resulting in the local RAID devices not being excluded. Changed name +of functions vbbackup(), vbrestore() to ddgzbackup(), ddgzrestore() +to match the new method naming scheme. Save S.M.A.R.T. data for +drives during backup so that useful drive info may be obtained. When +backing up, save drive sizes in separate files instead of trying to +extract it from the fdisk -l output. Save partition size information +as well as drive size information. When creating directory for +backup, if directory already exists, and user elects not to +overwrite, the getimagename() function is called again instead of +just aborting out and having the user start all over. Enabled +pausing of various operations. Automatically eject the CD after +booting to rescuebru or rescuebru in xorg options. Completely +revamped the menu layout of rescuebru. Moved all program settings +(media type, backup method, and action after successful operation) +to a Settings submenu. Created a Disk Utilities submenu for cloning, +blanking, badblocks testing, and media setup. Changed the constant +menu options (help, exit) to letters to prevent having to renumber +them if new options are added in the future. Reorganized funtions to +make them easier to maintain. Standardized all menu code to case +statements using regular expressions instead of unwieldy "if then +elif then" statements with cumbersome test constructs. Updated all +help documentation to reflect changes. + +1/2/2015 - 7.1.0 - Complete rewrite of rescuebru.sh. Implemented +dialog based user interface. Network configuration is now automatic +using DHCP. Changed the standard IP addressing scheme to 10.111.x.y. +Added ability to save notes and version numbers with a backup. If +overwriting a previous backup, preserve notes/logs from the existing +backup. If a notes template is present on the server, loads that +into the note edit dialog. Added image management functionality +(copy/delete/rename) that was previously only available in the +server. Backup method is now determined automatically by default for +each partition individually based on the contents. Fixed numerous +bugs. Removed scsi-i2o conversion scripts because the systems they +were written to support are no longer available to test against. If +the problem returns (can only happen with a new SystemRescueCD +version), the suggestion is just to do new backups of the affected +systems. Updated help files. + +2/19/2015 - 7.1.1 - Critical bugfix and minor feature release. Fixed +bug in do_restore() where size warning code caused abort for backups +done of HP CISS devices. Added ability to specify compression levels +of backups. Changed hotkeys for help options in menus from "H" to +"?" to avoid conflicts with other menu options. Fixed bug where +smartctl output was not being parsed correctly resulting in messages +like "Previous device was: (blank)" during restore. + +3/10/2015 - 7.2.0 - Updated SystemRescueCD to version 4.5.1 to make +use of new megaraid driver device support. Added support for GPT +partition tables. Added support for booting machines with UEFI BIOS. + +2/11/2016 - 7.2.1 - Xorg mode is now the default mode and includes a +backup media capacity monitoring window. Modified the xrescuebru.sh +script to disable screen blanking. Validate the version input text +to prevent failure to display available backups. Fixed bug where +auto_net_setup would report no carrier where it did in face exist. + +06/27/2018 - 7.2.2 - No changes. + +03/19/2021 - 7.2.3 - Added support for NVMe devices. + +9/21/2021 - 7.2.4 - Fixed bug in getimages() function where gpt +partition table images of NVMe devices were not being offered as +selections to restore, resulting in failed restores with new drives. + +01/19/2024 - 7.2.5 - Added option to the settings menu to set the backup +server type. The options are “RescueBRU Server” (the default) and +“any DHCP server”. Also changed the auto_net_setup() function to only +attempt to get a DHCP address based on the backup server type selected +in settings. This is to prevent attempts to get an IP address from any +available DHCP server in the event that getting one from a RescueBRU +server fails. This makes RescueBRU play nice on networks that have DHCP +servers by not grabbing up leases unnecessarily. If you need to use +RescueBRU with the NFS storage type, but you don’t have a dedicated +RescueBRU Server running, you’ll need to go into settings and explicitly +enable promiscuous DHCP by changing the backup server type. Added an +option to the settings menu to specify the remote NFS share name in case +we are using a non RescueBRU NFS server but still use the auto net +setup type to get our address. + +######################################################################## +rbruserver.sh: +---------------------------------------------------------------------- +07/23/08 - 1.0 - Initial Release + +08/12/08 - 1.1 - Added code to server_start to clean up stale client +mark files. + +08/27/08 - 1.2 - Incorporated improvements to mainmenu() + +04/30/09 - 1.3 - Added code to intelligently determine RAID array +members instead of hardcoding them. + +05/14/09 - 1.4 - Added code to create /var/lib/nfs/state file so nfs +startup script won't complain. Added capability to view log files. +Improved exit options so they match rescuebru and are not confusing. +Added raidtest function to show RAID status on startup and with a +menu option. + +10/21/09 - 1.5 - Changed raidtest function to use mdadm instead of +just cat'ing and parsing /proc/mdstat. Start server by default on +program start. Fixed bug in logview function that caused weird +behavior on subsequent calls of the function. Added ability to show +connected clients and their status. + +9/7/10 - 2.0 - Add ability to start PXE boot script to act as a boot +server. + +12/20/10 - 2.1 - Fixed bug in server_start that prevented network +from being brought back up after a user stop/start. + +1/17/13 - 3.0 - Fixed bug where only the RAID partitions and not the +entire drive devices were being passed to rescuebru when local +backup/restore was selected. Removed functions that are duplicated +in functions.sh. Moved change information to the commom CHANGELOG +file. Consolidated the three image manipulation functions, +image_copy(), image_rename(), and image_delete() into a single +function, image_mod(). Cleaned up code structure. Changed the main +menu exit options to letters to prevent having to renumber them if +new options are added in the future. Combined image copy, rename, +and delete options into an image management submenu. + +1/2/2015 - 7.1.0 - Advanced the version number to match that of +other scripts. Major rewrite of rbruserver.sh. Implemented dialog +based user interface. Network addressing is provided to clients +using DHCP. Server now uses all available interfaces in the machine, +and serves IP addresses and NFS on all. By default, only provides +DHCP responses to clients identifying themselves as "rescuebru". If +PXE boot server is running, provides responses to all clients by +necessity. Fixed bug where PXE boot server would send the server +version of the configuration instead of the client version. Added +capability to define a template for backup notes to guide users +about what information to be entered in a note. Increased RAID +stripe cache size to the max to improve RAID write performance. + +2/19/2015 - 7.1.1 - Advanced the version number. + +3/10/2015 - 7.2.0 - Updated SystemRescueCD to version 4.5.1 to make +use of new megaraid driver device support. Added command to kill +dhcpcd at startup since we don't need to ask somebody for an IP +address if we're a server. Added support for booting machines with +UEFI BIOS. + +2/11/2016 - 7.2.1 - Server now runs in Xorg mode. Implemented a +RAID set capacity display. Implemented a fault monitoring display +and indication using the blue UID light on the server machine to +indicate a fault. + +06/27/2018 - 7.2.2 - No changes. + +03/19/2021 - 7.2.3 - Added support for NVMe devices. + +9/21/2021 - 7.2.4 - No changes + +01/19/2024 - 7.2.5 - No changes. + +######################################################################## +clone.sh: +------------------------------------------------------------------------ +11/28/12 - 1.0 - Initial Release + +1/2/2015 - 7.1.0 - Advanced the version number to match that of +other scripts. + +2/19/2015 - 7.1.1 - Advanced the version number. + +3/10/2015 - 7.2.0 - Updated SystemRescueCD to version 4.5.1 to make +use of new megaraid driver device support. + +2/11/2016 - 7.2.1 - Changed the input and output block sizes used by +the dd command from the default (512 byte) to 4096 byte to increase +clone speed. + +06/27/2018 - 7.2.2 - No changes. + +03/19/2021 - 7.2.3 - No changes. + +09/21/2021 - 7.2.4 - No changes. + +01/19/2024 - 7.2.5 - No changes. + +######################################################################## +blank.sh: +------------------------------------------------------------------------ +11/28/12 - 1.0 - Initial Release + +1/2/2015 - 7.1.0 - Advanced the version number to match that of +other scripts. + +2/19/2015 - 7.1.1 - Advanced the version number. + +3/10/2015 - 7.2.0 - Updated SystemRescueCD to version 4.5.1 to make +use of new megaraid driver device support. + +2/11/2016 - 7.2.1 - Changed the input and output block sizes used by +the dd command from the default (512 byte) to 4096 byte to increase +clone speed. + +06/27/2018 - 7.2.2 - No changes. + +03/19/2021 - 7.2.3 - No changes. + +09/21/2021 - 7.2.4 - No changes. + +01/19/2024 - 7.2.5 - No changes. + +######################################################################## +functions.sh: +------------------------------------------------------------------------ +12/5/12 - 1.0 - Initial Release + +1/2/2015 - 7.1.0 - Advanced the version number to match that of +other scripts. Updated existing functions to use the dialog based +user interface. + +2/19/2015 - 7.1.1 - Advanced the version number. + +3/10/2015 - 7.2.0 - Updated SystemRescueCD to version 4.5.1 to make +use of new megaraid driver device support. Added --time-style +parameter to the ls command in the showimages() and buildimagelist() +functions due to a change in the default time style in the newer +version of ls. + +2/11/2016 - 7.2.1 - No changes. + +06/27/2018 - 7.2.2 - No changes. + +03/19/2021 - 7.2.3 - No changes. + +09/21/2021 - 7.2.4 - No changes. + +01/19/2024 - 7.2.5 - Modified the validate_text() function to validate +either a name (of say, a backup or version number) or a path (which +would need to include forward slashes). Fixed bug in getnewname() where +"NEW_IMAGE_NAME" or "lost+found" would incorrectly be accepted as the +backup image name. diff --git a/customcd/files/root/rescuebru/blank.sh b/customcd/files/root/rescuebru/blank.sh new file mode 100644 index 0000000..fc6694f --- /dev/null +++ b/customcd/files/root/rescuebru/blank.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# blank.sh +# Rescue CD Backup & Restore Utility device blanking utility +# version 7.2.5 +# Rod Wright 1/19/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +PROG_NAME="blank.sh" +PROG_VERSION=7.2.5 +PROG_REVISION=1 +RBRU_INSTALL_PATH="/root/rescuebru" + +source $RBRU_INSTALL_PATH/functions.sh + +# test for required arguments +if [ "$#" -ne 1 ]; then + echo "blank.sh: Invalid number of arguments." + echo "Usage: blank " + echo "target can be drive (/dev/sda) or partition" + echo "(/dev/sda1)." + echo "If target is a drive, all data including the MBR," + echo "partition table, and any RAID signatures will be lost." + echo "If target is a partition, any filesystem on it will" + echo "be lost." + exit 1 +fi + +tgt_dev=$1 +dd_bs=4096 + +# determine sizes of target +tgt_size=`blockdev --getsize64 $tgt_dev` +tgt_blocks=$(($tgt_size / $dd_bs )) + +# now do the blanking +monitor "dd if=/dev/zero bs=$dd_bs count=$tgt_blocks conv=sync,noerror status=noxfer|pv -s $tgt_size|dd of=$tgt_dev bs=$dd_bs" "pausable" +exit $? diff --git a/customcd/files/root/rescuebru/clone.sh b/customcd/files/root/rescuebru/clone.sh new file mode 100644 index 0000000..8bcdc93 --- /dev/null +++ b/customcd/files/root/rescuebru/clone.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# clone.sh +# Rescue CD Backup & Restore Utility drive/partition cloning utility +# version 7.2.5 +# Rod Wright 1/19/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +PROG_NAME="clone.sh" +PROG_VERSION=7.2.5 +PROG_REVISION=1 +RBRU_INSTALL_PATH="/root/rescuebru" + +source $RBRU_INSTALL_PATH/functions.sh + +# test for required arguments +if [ "$#" -ne 2 ]; then + echo "clone.sh: Invalid number of arguments." + echo "Usage: clone " + echo "source and destination can be drives (/dev/sda) or partitions" + echo "(/dev/sda1)." + echo "Please ensure the size of the destination is equal to or" + echo "greater than the size of the source." + exit 1 +fi + +source_dev=$1 +dest_dev=$2 +dd_bs=4096 + +# determine sizes of devices +source_size=`blockdev --getsize64 $source_dev` +dest_size=`blockdev --getsize64 $dest_dev` + +# compare sizes and warn if necessary +if [ $dest_size -lt $source_size ]; then + pv_size=$dest_size + if ! approved "WARNING: The size of the destination device seems to be smaller than the size of the source device. Continue anyway?" ; then + inform "Aborting" "3" + exit 1 + fi +else + pv_size=$source_size +fi + +# now do the clone +monitor "dd if=$source_dev bs=$dd_bs conv=sync,noerror status=noxfer|pv -s $pv_size|dd of=$dest_dev bs=$dd_bs" "pausable" +exit $? diff --git a/customcd/files/root/rescuebru/faultmonitor.sh b/customcd/files/root/rescuebru/faultmonitor.sh new file mode 100644 index 0000000..86b9649 --- /dev/null +++ b/customcd/files/root/rescuebru/faultmonitor.sh @@ -0,0 +1,130 @@ +#!/bin/bash +# faultmonitor.sh +# Rescue CD Backup & Restore Utility fault monitoring script +# version 7.2.5 +# Rod Wright 1/19/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +CAPACITY_WARN=90 +STATUS_FILE="/root/faultstatus.txt" + +function checkraid() { + # check for RAID failure + # takes one argument, a full raid device name + local device=$1 + if [ "$device" != "none" ]; then + if mdadm -D $device | grep -q degraded ; then + return 1 + else + return 0 + fi + else + return 0 + fi +} + +function checksmart() { + # check for RAID member SMART failure + # takes a list of RAID partition full device names as positional parameters + for drive in $* ; do + if echo $drive|grep -q nvme ; then + nvmesmartstat=`nvme smart-log $drive|grep critical_warning|cut -d ":" -f2|sed 's/^ *//g'` + if [ $nvmesmartstat -ne 0 ]; then return 1 ;fi + else + smartctl -q silent $drive + local smartstat=$(($? & 8)) + if [ $smartstat -ne 0 ]; then return 1 ;fi + fi + done + return 0 +} + +function checkcapacity() { + # check for RAID usage above a threshold + # takes two arguments, a RAID device and a percentage + local device=$1 + local threshold=$2 + if [ "$device" != "none" ]; then + local pctstrg=`df $device |grep $device|awk '{print $5}'` + local pct=${pctstrg//%} + if [ $pct -ge $threshold ] ; then + return 1 + else + return 0 + fi + else + return 0 + fi +} + +function flashuid() { + # turn flashing UID light on or off + # takes one argument, the word "on" or "off" + # determine if ipmi hardware is supported and return failure if not + if ! ipmitool chassis status >/dev/null 2>&1; then return 1 ; fi + if [ "$1" = "on" ]; then + local ipmiarg="force" + elif [ "$1" = "off" ]; then + local ipmiarg="0" + else + # invalid argument make no change and return failure + return 1 + fi + ipmitool chassis identify $ipmiarg +} + +function update_faultstatusfile() { + # maintain the fault status file + if [ "$raiddevname" != "none" ]; then + if [ $raidfail ]; then + local raidline="RAID Status : \033[1;31mFAIL\033[0m" + else + local raidline="RAID Status : \033[1;32mOK\033[0m" + fi + else + local raidline="RAID Status : \033[1;33mWAIT\033[0m" + fi + if [ $smartfail ]; then + local smartline="Disk Status : \033[1;31mFAIL\033[0m" + else + local smartline="Disk Status : \033[1;32mOK\033[0m" + fi + if [ "$raiddevname" != "none" ]; then + if [ $lowspace ]; then + local capline="Free Space : \033[1;31mLOW\033[0m" + else + local capline="Free Space : \033[1;32mOK\033[0m" + fi + else + local capline="Free Space : \033[1;33mWAIT\033[0m" + fi + printf "$raidline \n$smartline \n$capline \n">$STATUS_FILE +} + + +# generate a list of RAID component drives +for raiddrv in `cat /proc/mdstat|grep -o -e "sd[a-z]|nvme[0-9]n[0-9]"`; do + raidmembers=$raidmembers" /dev/$raiddrv" +done +unset raidfail +unset smartfail +unset lowspace + +# main loop +while true ; do + # determine the RAID device name and see if it's mounted + if mount | grep -q "/dev/md" ; then + raiddevname=`mount |grep "/dev/md"|awk '{print $1}'` + else + raiddevname="none" + fi + + # run the tests + if ! checkraid $raiddevname ; then raidfail=1 ; else unset raidfail ; fi + if ! checksmart $raidmembers ; then smartfail=1 ; else unset smartfail ; fi + if ! checkcapacity $raiddevname $CAPACITY_WARN ; then lowspace=1 ; else unset lowspace ; fi + if [ $raidfail -o $smartfail -o $lowspace ]; then flashuid on ; else flashuid off ; fi + update_faultstatusfile + sleep 60 +done diff --git a/customcd/files/root/rescuebru/functions.sh b/customcd/files/root/rescuebru/functions.sh new file mode 100644 index 0000000..ac4c23e --- /dev/null +++ b/customcd/files/root/rescuebru/functions.sh @@ -0,0 +1,679 @@ +# functions.sh +# Rescue CD Backup & Restore Utility common functions +# version 7.2.5 +# Rod Wright 1/19/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +function monitor() { + # Run a command while monitoring for user input + # Takes two arguments. The first is a string containing + # the complete command to be executed. The second is the word + # "pausable" if you would like to be able to pause or abort + # the operation. + unset pausekey + unset pausable + cmd_string=$1 + if [ "$2" = "pausable" ]; then + pausable=1 + dialog --sleep 4 --begin 20 5 --no-shadow \ + --infobox "You may press any letter key at any time to pause the operation." 3 70 + fi + eval "$cmd_string &" + cmd_pid=$! + let watching=1 + let alive=1 + while [[ $watching && $alive ]]; do + if ! `kill -0 $cmd_pid 2>/dev/null` ; then + unset alive + wait $cmd_pid + cmd_exit_stat=$? + fi + if [ "$pausable" = "1" ]; then read -s -n1 -t1 pausekey <&1; fi + if [ $pausekey ]; then + unset watching + kill -s STOP $cmd_pid + if approved "Operation paused. Do you want to continue?" "y"; then + dialog --sleep 4 --begin 20 5 --no-shadow \ + --infobox "You may press any letter key at any time to pause the operation." 3 70 + kill -s CONT $cmd_pid + let watching=1 + else + kill -s CONT $cmd_pid + kill -s TERM $cmd_pid + wait $cmd_pid 2>/dev/null + return 1 + fi + fi + done + return $cmd_exit_stat +} + +function progreport() { + # Creates an infobox to report cumulative progress. + # Takes one argument, the text to print in box. + # If the text supplied is "" then a new report is started. + if [ -n "$1" ]; then + echo "$1">>$progfile + dialog --infobox "`tail -20 $progfile`" 24 80 + else + echo "">$progfile + fi +} + +function flush_input() { + # Flush spurious user input. Call this before a 'read' when you + # need to get user data. Do NOT call this if you're just trying to + # detect keystrokes. + read -t .1 -n 10000 discard +} + +function approved() { + # Ask a question requiring a y or n for an answer + # takes two arguments. + # First is the text of the prompt. + # Second is the default result, "y" or "n". + # Returns 0 if answer is yes, 1 if no. + if [[ $2 = "n" ]]; then + flush_input + dialog --aspect 80 --defaultno --yesno "$1" 0 0 + elif [[ $2 = "y" ]]; then + flush_input + dialog --aspect 80 --yesno "$1" 0 0 + fi + return $? +} + +function validate_text() { + # Ensures a string contains only allowed characters. + # Takes two arguments, the first is "name" or "path", + # the second is the string to be validated + # returns 0 if valid, 1 if not + unset chars_only + tst_strg=$2 + case $1 in + "name" ) + chars_regex="^[\.0-9_a-zA-Z\-]*$" + ;; + "path" ) + chars_regex="^[\.\/0-9_a-zA-Z\-]*$" + ;; + * ) + return 1 + ;; + esac + echo $tst_strg|grep -q -e $chars_regex + return $? +} + +function operation_log() { + # Turns the operation log on or off. + # Takes one argument, the string "on" or "off". + if [ "$1" = "on" ]; then + local opfn=`echo ${operation// /_}` + OPERATION_LOG="$LOG_PATH/${opfn}_`date +%Y-%m-%d_%H%M%S`.log" + elif [ "$1" = "off" ]; then + OPERATION_LOG="/dev/null" + else + pause "You must specify \"on\" or \"off\"." + return 1 + fi +} + +function log_session() { + # Appends supplied text to the session log file. Argument is text to log + if [ "$LOGGING_ENABLED" -eq 1 ]; then + echo "[`date +%T`]: $1">>$SESSION_LOG + fi +} + +function log_operation() { + # Appends supplied text to the operation log file. Argument is text to log + if [ "$LOGGING_ENABLED" -eq 1 ]; then + echo "[`date +%T`]: $1">>$OPERATION_LOG + fi +} + +function log() { + # Logs to all three of the log types. Argument is text to log. + # The filename of the logfile is determined at the point in time + # when the variable (SESSION_LOG, etc.) is defined. So define the + # session log at program start and use the operation_log() + # function at the start and end of each operation. + log_session "$1" + log_operation "$1" +} + +function contains() { + # Determine if an array contains a key or value. + # Takes two arguments. First argument is the key or value. + # Second argument is a list of elements. + # Returns 0 if array contains key or value, 1 if not. + local element + for element in "${@:2}"; do + if [ "$element" = "$1" ]; then + return 0 + fi + done + return 1 +} + +function inform() { + # Display an informative message for a short time + # Takes two arguments, first is the text to display. + # Second is optionally the number of seconds the message stays up. + if [ $2 ]; then + secs=$2 + else + secs=3 + fi + dialog --sleep "$secs" --aspect 80 --infobox "$1" 0 0 +} + +function pause() { + # Display a message and wait for acknowledgment + # takes one optional argument, the message to display + if [ "$1" = "" ]; then + pausetxt="----- PAUSED -----" + else + pausetxt="$1" + fi + dialog --aspect 80 --msgbox "$pausetxt" 0 0 +} + +function showimages() { + if [ -d $IMAGE_PATH ]; then + radiotmp=`mktemp -q` + radiocoltmp=`mktemp -q` + echo "___NAME___ ___DATE___ ___SIZE___ ___VERSION___">$radiotmp + origifs=$IFS + IFS=$'\n' + # Build a list of existing images + for line in `ls -l --time-style=+%Y-%m-%d\ %H:%M --hide="lost+found" $IMAGE_PATH/|sed -e 1,1d|awk {'print $8" "$6'}`; do + IFS=$origifs + local name=`echo $line|cut -d " " -f1` + local size=$(echo `du -sh $IMAGE_PATH/$name`|cut -d " " -f1) + local version=`cat $IMAGE_PATH/$name/version.txt 2>/dev/null` + if [ "$version" = "" ]; then version="-"; fi + if [ -e $IMAGE_PATH/$name/latest_backup_date.txt ]; then + local date=`cat $IMAGE_PATH/$name/latest_backup_date.txt` + else + local date=`echo $line|cut -d " " -f2` + fi + echo "$name $date $size $version">>$radiotmp + IFS=$'\n' + done + IFS=$origifs + column -t $radiotmp>$radiocoltmp + flush_input + dialog --title "Images available on backup media" \ + --exit-label "Return" \ + --textbox $radiocoltmp 24 79 + rm -f $radiotmp $radiocoltmp + else + if [ "$PROG_NAME" = "rescuebru.sh" ]; then + flush_input + pause "Media does not appear to be set up as backup media.\nChoose Set up backup media from the main menu." + elif [ "$PROG_NAME" = "rbruserver.sh" ]; then + flush_input + pause "Path to backup images not found." + fi + return 1 + fi + rm -f $radiotmp $radiocoltmp + return 0 +} + +function lognoteview() { + local backupname + local logname + # Allows user to view log files saved on backup media + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and is viewing log files.">$MEDIA_MNT_DIR/$wkg_addr + fi + while true; do + # Generate a list of backups for the radiobox dialog + radiotmp=`mktemp -q` + buildimagelist + # Prompt for backup name + if ! pickimagename "view log/notes files for" "single" ; then + rm -f $radiotmp + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + return 0 + else + backupname=$imagename + fi + rm -f $radiotmp + # Generate a list of logs and notes for the radiobox dialog + radiotmp=`mktemp -q` + tagtmp=`mktemp -q` + for tag in `ls $IMAGE_PATH/$backupname/*.log|rev|cut -d / -f1|rev`; do + echo "$tag \"off\"">>$radiotmp + done + for tag in `ls $IMAGE_PATH/$backupname/*.notes|rev|cut -d / -f1|rev`; do + echo "$tag \"off\"">>$radiotmp + done + if [ ! -s "$radiotmp" ]; then + pause "No logs or notes found for this image." + rm -f $radiotmp $tagtmp + else + # Prompt for log or note file name + if [ `wc -l $radiotmp|cut -d " " -f1` -eq 1 ]; then + lognotename=`cat $radiotmp|cut -d " " -f1` + if approved "Only one log/notes file found. Select Yes to view that or No to return to the previous menu." "y"; then + # Show the log or notes file + flush_input + dialog --title $lognotename --textbox $IMAGE_PATH/$backupname/$lognotename 25 80 + else + rm -f $radiotmp $tagtmp + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + return 0 + fi + else + flush_input + while dialog --no-items --cancel-label "Return" --radiolist "Select log/notes file to view" \ + 20 60 20 `cat $radiotmp` 2>$tagtmp ; do + lognotename=`cat $tagtmp` + # Show the log or notes file + flush_input + dialog --title $lognotename --textbox $IMAGE_PATH/$backupname/$lognotename 25 80 + done + fi + rm -f $radiotmp $tagtmp + fi + done +} + +function getbackupname() { + # Get imagename for backup + radiotmp=`mktemp -q` + # Insert an option to create a new name + echo "\"NEW_IMAGE_NAME\" \"---------- ------ -----\" \"on\"">$radiotmp + buildimagelist + imgcount=`wc -l $radiotmp|cut -d " " -f1` + while [ ! $iname_confirmed ]; do + if [ $imgcount -eq 1 ]; then + # new image name is the only option + if ! getnewname ; then + log "Unable to get new image name." + rm -f $radiotmp + return 1 + else + iname_confirmed=1 + fi + else + # show the radiolist + if ! pickimagename "backup" "single"; then + log "Unable to get image name." + rm -f $radiotmp + return 1 + else + iname_confirmed=1 + fi + fi + if [ "$imagename" = "NEW_IMAGE_NAME" ]; then + # NEW_IMAGE_NAME was chosen from list + if ! getnewname ; then + log "Unable to get new image name." + rm -f $radiotmp + return 1 + else + iname_confirmed=1 + fi + fi + # test imagename for uniqueness and ask what to do + if [ -d $IMAGE_PATH/$imagename ]; then + overwrite_confirm + case $? in + 1 ) + unset iname_confirmed + ;; + 2 ) + iname_confirmed=1 + imgovr=1 + rm -f $ovrchoicetmp + rm -f $radiotmp + ;; + * ) + unset iname_confirmed + rm -f $radiotmp + return 1 + ;; + esac + fi + done + rm -f $radiotmp + return 0 +} + +function getrestorename() { + # Get imagename for restore + radiotmp=`mktemp -q` + buildimagelist + imgcount=`wc -l $radiotmp|cut -d " " -f1` + if [ $imgcount -eq 1 ]; then + # only one image found + imagename=`cat $radiotmp|cut -d " " -f1|tr -d '"'` + pause "$imagename was the only image found. Selecting that to restore." + rm -f $radiotmp + return 0 + else + if ! pickimagename "restore" "single"; then + rm -f $radiotmp + return 1 + fi + fi +} + +function getmodnames() { + # Get source and/or destination image names + # Parameter is "copy", "rename", or "delete" + # get existing image name + radiotmp=`mktemp -q` + buildimagelist + imgcount=`wc -l $radiotmp|cut -d " " -f1` + if [ $imgcount -eq 0 ]; then + # no images found + pause "No images found." + log "No images found." + rm -f $radiotmp + return 1 + elif [ $imgcount -eq 1 ]; then + # only one image found + srcimagename=`cat $radiotmp|cut -d " " -f1|tr -d '"'` + pause "$srcimagename was the only image found. Selecting that to $1." + rm -f $radiotmp + else + # more than one image found + if [ "$1" = "delete" ]; then + pickcmd="pickimagename $1 multiple" + else + pickcmd="pickimagename $1 single" + fi + if ! $pickcmd ; then + rm -f $radiotmp + return 1 + else + srcimagename=$imagename + fi + fi + if [ "$1" = "copy" -o "$1" = "rename" ]; then + # get destination image name + unset imagename + if ! getnewname ; then + pause "Unable to get new image name." + log "Unable to get new image name." + return 1 + elif [ -d $IMAGE_PATH/$imagename ]; then + # test imagename for uniqueness and ask what to do + overwrite_confirm + case $1 in + 0 ) + unset iname_confirmed + inform "Overwrite confirmation cancelled." + return 1 + ;; + 1 ) + unset iname_confirmed + ;; + 2 ) + destimagename=$imagename + iname_confirmed=1 + imgovr=1 + return 0 + ;; + esac + else + destimagename=$imagename + iname_confirmed=1 + imgovr=1 + return 0 + fi + fi +} + +function overwrite_confirm() { + # Get confirmation to overwrite an image + # Returns 1 to select a new name, 2 to overwrite existing, or something + # else to just cancel. + ovrchoicetmp=`mktemp -q` + dialog --no-tags --menu "You have selected an existing image name." 9 60 9 \ + "1" "Return to image selection and enter a new name" \ + "2" "Overwrite existing image (if operation successful)" 2>$ovrchoicetmp + local retval=`cat $ovrchoicetmp` + rm -f $ovrchoicetmp + return $retval +} + +function pickimagename() { + # Choose a new image name(s) from a radiolist or checklist dialog + # $radiotmp list file must already exist using buildimagelist() + # takes two arguments. First is operation to be performed. + # Second is "single" or "multiple". + radiocoltmp=`mktemp -q` + selectiontmp=`mktemp -q` + column -t $radiotmp>$radiocoltmp + local dialog_script=`mktemp -q` + if [ "$2" = "single" ]; then + local listtype="--radiolist" + local noun="name" + elif [ "$2" = "multiple" ]; then + local listtype="--checklist" + local noun="names" + else + pause "ERROR in pickimagename(). Must specify single or multiple." + rm -f $radiotmp $radiocoltmp $selectiontmp $dialog_script + return 1 + fi + echo "dialog --cancel-label \"Return\" $listtype \"Select image $noun to $1\" 25 80 25 `cat $radiocoltmp|tr '\n' ' '` 2>$selectiontmp">$dialog_script + if ! bash $dialog_script ; then + rm -f $radiotmp $radiocoltmp $selectiontmp $dialog_script + return 1 + fi + imagename=`cat $selectiontmp` + rm -f $radiocoltmp $selectiontmp $dialog_script + return 0 +} + +function getnewname() { + # Prompt for a new image name + local iname_invalid=1 + while [ $iname_invalid ]; do + # Prompt for new image name + nametmp=`mktemp -q` + if dialog --inputbox "Please enter new image name" \ + 8 50 "$imagename" 2>$nametmp ; then + imagename=`cat $nametmp` + if ! validate_text name $imagename; then + pause "Image name contains invalid characters. Valid characters are upper and lowercase letters, numbers, underscore, and dash. Try again." 0 0 + elif [ "$imagename" = "" ]; then + pause "Image name cannot be blank. \nTry again." + elif [ "$imagename" = "NEW_IMAGE_NAME" ]; then + pause "\"NEW_IMAGE_NAME\" is not a valid image name. \nChoose another." + elif [ "$imagename" = "lost+found" ]; then + pause "\"lost+found\" is not a valid image name. \nChoose another." + else + unset iname_invalid + rm -f $nametmp + fi + else + inform "Image name entry aborted." + rm -f $nametmp + unset imagename + return 1 + fi + done + log "New image name is $imagename" + return 0 +} + +function buildimagelist() { + # Create a file containing a list of existing images with info + if [ ! -e $radiotmp ]; then + radiotmp=`mktemp -q` + fi + origifs=$IFS + IFS=$'\n' + for line in `ls --time-style=+%Y-%m-%d\ %H:%M --hide="lost+found" -l $IMAGE_PATH/|sed -e 1,1d|awk {'print $8" "$6'}`; do + IFS=$origifs + local name=`echo $line|cut -d " " -f1` + local size=$(echo `du -sh $IMAGE_PATH/$name`|cut -d " " -f1) + local version=`cat $IMAGE_PATH/$name/version.txt 2>/dev/null` + if [ "$version" = "" ]; then version="-"; fi + if [ -e $IMAGE_PATH/$name/latest_backup_date.txt ]; then + local bdate=`cat $IMAGE_PATH/$name/latest_backup_date.txt` + else + local bdate=`echo $line|cut -d " " -f2` + fi + local tag="$name" + local item="$bdate $size $version" + local status="off" + echo "\"$tag\" \"$item\" \"$status\"">>$radiotmp + IFS=$'\n' + done + IFS=$origifs +} + +function getimagename() { + # Dispatcher function to get image name(s) for an operation + # parameter is "backup" or "restore" or "copy" or "rename" or "delete" + unset imgovr + while [ ! $iname_confirmed ]; do + case $1 in + "backup" ) + getbackupname + return $? + ;; + "restore" ) + getrestorename + return $? + ;; + "copy" | "rename" | "delete" ) + getmodnames "$1" + return $? + ;; + * ) + pause "${FUNCNAME[@]} :Invalid parameter passed to getimagename()." + return 1 + ;; + esac + done +} + +function shutdown_proc() { + # Manage shutdown or reboot + # Takes one argument, "shutdown" or "reboot" + # Returns 1 on abort or invalid option. + case "$1" in + "reboot" ) + warntxt="REBOOT" + cmdtxt="reboot" + abrttxt="Reboot" + ;; + + "shutdown" ) + warntxt="SHUTDOWN" + cmdtxt="poweroff" + abrttxt="Shutdown" + ;; + + * ) + inform "Invalid shutdown option. Aborting." "4" + return 1 + ;; + esac + flush_input + if dialog --no-cancel --pause "$warntxt IN PROGRESS. Press to abort or to confirm." \ + 10 70 30 ; then + if cleanup ; then + inform "Starting $warntxt now." "1" + reset + $cmdtxt + else + pause "$abrttxt could not be completed." + return 1 + fi + else + inform "$abrttxt aborted" + return 1 + fi +} + +function image_mod { + while true; do + # Show modification menu + imtmp=`mktemp -q` + if dialog --no-cancel \ + --title "IMAGE MANAGEMENT" \ + --menu "Please enter choice:" 11 50 6 \ + "1" "Copy an image" \ + "2" "Rename an image" \ + "3" "Delete one or more images" \ + "M" "Return to main menu" 2>$imtmp ; then + imchoice=`cat $imtmp` + rm -f $imtmp + case $imchoice in + "M" ) + return 0 + ;; + + 3 ) + mod_type="delete" + mod_cmd="rm -rf " + ;; + + 2 ) + mod_type="rename" + mod_cmd="mv " + ;; + + 1 ) + mod_type="copy" + mod_cmd="cp -R " + ;; + esac + # Get source and/or destination image names + unset srcimagename destimagename imagename + if getmodnames "$mod_type" ; then + # srcimagename, destimagename for copy or rename + # srcimagename for delete + if [ "$mod_type" = "copy" -o "$mod_type" = "rename" ]; then + inform "$mod_type in progress. Please wait..." + if $mod_cmd $IMAGE_PATH/$srcimagename $IMAGE_PATH/$destimagename ; then + inform "$mod_type succeeded." + else + pause "$mod_type failed." + fi + elif [ "$mod_type" = "delete" ]; then + unset delfail + if approved "WARNING! You are about to permanently delete the following image(s):\n$srcimagename\nAre you sure?" "n"; then + inform "$mod_type in progress. Please wait..." + for delimg in $srcimagename; do + if ! $mod_cmd $IMAGE_PATH/$delimg ; then + delfail="$delfail $delimg" + fi + done + if [ $delfail ]; then + pause "The following images could not be deleted:\n$delfail" + else + inform "$mod_type succeeded." + fi + else + inform "Image deletion aborted." + fi + else + pause "An invalid modification type was specified." + fi + else + pause "Couldn't get image name to $mod_type." + fi + else + inform "Image modification canceled." + return 1 + fi + done +} diff --git a/customcd/files/root/rescuebru/rbruserver.sh b/customcd/files/root/rescuebru/rbruserver.sh new file mode 100644 index 0000000..8c7f3fb --- /dev/null +++ b/customcd/files/root/rescuebru/rbruserver.sh @@ -0,0 +1,846 @@ +#!/bin/bash +# rbruserver.sh +# Rescue CD Backup & Restore Utility Server Script +# version 7.2.5 +# Rod Wright 1/19/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +PROG_NAME="rbruserver.sh" +PROG_VERSION=7.2.5 +RBRU_INSTALL_PATH="/root/rescuebru" + +source $RBRU_INSTALL_PATH/functions.sh + +RAID_MEMBERS="" +RAID_MNT_PT="/mnt/rescuebru" +IMAGE_PATH="$RAID_MNT_PT/rescuebru-backups" +NET_ADDR="10.111." +EXPRT_ARGS="*(rw,no_root_squash,no_subtree_check,fsid=1)" +SVR_STAT=0 +PXE_STAT=0 +NET_STAT=0 +LOGGING_ENABLED=0 +CLIENT_NET_STATUS=0 + +NOTES_TEMPLATE=$RAID_MNT_PT/notes_template.txt + +TRUE=1 +FALSE=0 + +function editnotestemplate { + # Edit the template for notes where rescuebru client expects it + templatetext=`mktemp -q` + touch $NOTES_TEMPLATE + if dialog --title "Notes Template" \ + --backtitle "Edit template then Tab to or and press enter." \ + --ok-label "Save" \ + --editbox $NOTES_TEMPLATE 20 80 2>$templatetext ; then + cp -f $templatetext $NOTES_TEMPLATE + else + pause "Couldn't edit notes template." + rm -f $templatetext + fi +} + +function clientstatus { + # show connected clients and their status + if client_files=`ls $RAID_MNT_PT/10.* 2>/dev/null` ; then + cstmp=`mktemp -q` + for cfname in $client_files; do + # see if the client still responds + client_addr=`basename $cfname` + if ! ping -q -c3 $client_addr 1>/dev/null 2>&1 ; then + echo "$client_addr is allocated but not responding. Mark file will be removed on next server stop.">>$cstmp + else + echo "$client_addr `cat $cfname`">>$cstmp + fi + done + dialog --title "Client Status" --aspect 80 --msgbox "$(cat $cstmp)" 0 0 + else + inform "No connected clients." + fi + rm -f $cstmp + return 0 +} + +function raidtest { + # Show RAID status + # Takes one argument, the string "inform" or "pause" that determines if it waits for acknowledgement + + $1 "`mdadm -D $raid_dev |awk '/\/dev\/md|Array Size|Dev Size|Devices|State|\/dev\/sd|\/dev\/nvme/ {print}'`" "6" + return 0 +} + +function mainmenu { + # Show the main menu + mmtemp=`mktemp -q` + if [ "$SVR_STAT" = 0 ]; then + svr_stat_txt="Start server" + else + svr_stat_txt="Stop Server" + fi + if [ "$PXE_STAT" = 0 ]; then + pxe_stat_txt="Start the PXE boot server" + else + pxe_stat_txt="Stop the PXE boot server" + fi + dialog --clear --no-cancel \ + --title "RescueBRU Server Main Menu"\ + --menu "Welcome to Rescue CD Backup & Restore Server + __ Version $PROG_VERSION __ + + Please enter choice:" 23 50 23 \ + "1" "$svr_stat_txt" \ + "2" "Show backups available on media" \ + "3" "Show storage capacity" \ + "4" "Show RAID status" \ + "5" "Show client status" \ + "6" "Image management" \ + "7" "$pxe_stat_txt" \ + "8" "Run RescueBru (for local backup/restore)" \ + "9" "View logs or notes" \ + "10" "Edit notes template" \ + "S" "Exit to shell" \ + "R" "Exit and reboot" \ + "P" "Exit and power down" 2> $mmtemp + mainmc=`cat $mmtemp` + rm -f $mmtemp + return 0 +} + +function server_start { + #clean up stale client mark files + for cmfile in `ls $RAID_MNT_PT|grep 10.`; do + rm -f $RAID_MNT_PT/$cmfile + done + # kill netplugd to keep it from interfering + killall netplugd >/dev/null 2>&1 + # Since sysresccd-1.0.4, we have to manually start nfs + if ! /etc/init.d/nfs start >/dev/null 2>&1 ; then + pause "NFS service failed to start." + return 1 + fi + sleep 2 + # Bring up the network + # Build array of interfaces + ifname=( ) + for nif in `cat /proc/net/dev|grep eth|cut -d : -f1`; do + ifname=( ${ifname[@]} $nif ) + done + if [ "$NET_STAT" -eq 1 ]; then + inform "Network is already up" + else + inform "Bringing up the networks..." + ifidx=1 + for nif in ${ifname[@]} ; do + inform "$nif as $NET_ADDR$ifidx.1" "1" + ifconfig $nif $NET_ADDR$ifidx.1 netmask 255.255.255.0 + let "ifidx += 1" + done + sleep 2 + inform "Starting DHCP server..." + cp /etc/dhcp/dhcpd.conf.rbruserver /etc/dhcp/dhcpd.conf + if ! /etc/init.d/dhcpd restart >/dev/null 2>&1 ; then + pause "DHCP server failed to start." + return 1 + fi + sleep 2 + NET_STAT=1 + fi + # NFS export the RAID set + inform "Exporting the RAID set to NFS clients..." + if ! exportfs -r >/dev/null 2>&1 ; then + pause "An error was encountered while exporting the RAID set." + return 1 + fi + sleep 5 + SVR_STAT=1 +} + +function server_stop { + # Check to see if all clients have exited + if ls $RAID_MNT_PT |grep -q 10. ; then + if ! approved "It appears that not all clients have exited. Stopping server now may cause client or server lockups, corrupt backups, or other problems. Do you want to stop the server anyway?" "n"; then + return 1 + fi + fi + # Un-export the RAID set + # exportfs -u \*:/mnt/rescuebru + # Turn off nfs + inform "Stopping NFS..." + if ! /etc/init.d/nfs stop >/dev/null 2>&1 ; then + inform "Could not stop NFS." + fi + # Turn off dhcpd + inform "Stopping DHCP server..." + if ! /etc/init.d/dhcpd stop >/dev/null 2>&1 ; then + inform "Could not stop DHCP server." + fi + rm -f /etc/dhcp/dhcpd.conf + # Bring down the networks + inform "Bringing down the networks..." + for nif in ${ifname[@]} ; do + inform "$nif ..." "1" + ifconfig $nif 0.0.0.0 + ifconfig $nif down + done + NET_STAT=0 + # Clean up IP mark files + rm -f $RAID_MNT_PT/10.* >/dev/null 2>&1 + SVR_STAT=0 + return 0 +} + +function show_usage { + local total=`df -h $RAID_MNT_PT|grep $RAID_MNT_PT|awk '{print $2}'` + local used=`df -h $RAID_MNT_PT|grep $RAID_MNT_PT|awk '{print $3}'` + local available=`df -h $RAID_MNT_PT|grep $RAID_MNT_PT|awk '{print $4}'` + local percentage=`df -h $RAID_MNT_PT|grep $RAID_MNT_PT|awk '{print $5}'` + pause "Total capacity: $total\nUsed: $used\nAvailable: $available\nPercent usage: $percentage" +} + +function cleanup() { + # Perform cleanup actions prior to exit + if [ "$SVR_STAT" -eq 1 ]; then + if server_stop ; then + if mount|grep -q $RAID_MNT_PT ; then + umount $RAID_MNT_PT + sleep 2 + fi + return 0 + else + return 1 + fi + else + if mount|grep -q $RAID_MNT_PT ; then + umount $RAID_MNT_PT + sleep 2 + fi + return 0 + fi +} + +function pxe_start() { + # Start the PXE boot server + if [ ! -d /tftpboot/pxelinux.cfg ]; then + mkdir -p /tftpboot/pxelinux.cfg + fi + if [ ! -f /tftpboot/pxelinux.0 ]; then + cp /usr/share/syslinux/pxelinux.0 /tftpboot/ + fi + if [ -f /tftpboot/pxelinux.cfg/default.bak ]; then + rm -f /tftpboot/pxelinux.cfg/default.bak + fi + if [ -f /tftpboot/pxelinux.cfg/default ]; then + mv /tftpboot/pxelinux.cfg/default /tftpboot/pxelinux.cfg/default.bak + fi + cp --remove-destination /livemnt/boot/???linux/{*msg,*c32,*.0,memdisk,netboot} /tftpboot/ + cp --remove-destination /livemnt/boot/???linux/???linux.cfg.pxeclient /tftpboot/pxelinux.cfg/default + touch /etc/exports + sed -i -e 's!^/tftpboot!#/tftpboot!g' /etc/exports + echo "/tftpboot *(fsid=0,ro,no_subtree_check,all_squash,insecure,anonuid=1000,anongid=1000)" >> /etc/exports + exportfs -r + rm -f /etc/dhcp/dhcpd.conf + cp /etc/dhcp/dhcpd.conf.rbruserver.pxeboot /etc/dhcp/dhcpd.conf + if ! /etc/init.d/dhcpd restart >/tmp/dhcpdrestart.log 2>&1; then + pause "Unable to restart DHCP server. Aborting." + return 1 + fi + if ! /etc/init.d/thttpd restart >/tmp/thttpdrestart.log 2>&1; then + pause "Unable to restart thttp server. Aborting." + return 1 + fi + if ! /etc/init.d/in.tftpd restart >/tmp/tftpdrestart.log 2>&1; then + pause "Unable to restart tftp server. Aborting." + return 1 + fi + return 0 +} + +function pxe_stop() { + # Stop the PXE boot server + rm -f /etc/dhcp/dhcpd.conf + cp /etc/dhcp/dhcpd.conf.rbruserver /etc/dhcp/dhcpd.conf + if ! /etc/init.d/dhcpd restart >/tmp/dhcpdrestart.log 2>&1; then + pause "Unable to restart DHCP server. Aborting." + return 1 + fi + if ! /etc/init.d/thttpd stop >/tmp/thttpdstop.log 2>&1; then + pause "Unable to stop thttp server. Aborting." + return 1 + fi + if ! /etc/init.d/in.tftpd stop >/tmp/tftpdstop.log 2>&1; then + pause "Unable to stop tftp server. Aborting." + return 1 + fi + return 0 +} + +function createraid() { + # Creates a RAID set from existing drives + + # Build an array of existing drives + declare -A drives + for rdrive in `ls /dev/sd? /dev/nvme?n?` ; do + rdrive_bytes=`fdisk -l $rdrive|grep $rdrive:|egrep -oe "[0-9]+ bytes"|egrep -oe "[0-9]+"` + drives[$rdrive]=$rdrive_bytes + done + + # Prompt for drives to use + prompttext="Select drives you would like to configure as RAID members" + # Generate an array of devices for the list dialog + local listitems=( ) + tagtmp=`mktemp -q` + for dev in `echo ${!drives[@]}|tr " " "\n"|sort|tr "\n" " "` ; do + drivegb=$(( ${drives[$dev]} / 1073741824 )) + listitems+=( "$dev" "$drivegb Gb" "off" ) + done + # Select devices + declare -A selraiddevs + unset finished + flush_input + while [ ! $finished ] ; do + if ! dialog --checklist "$prompttext" 20 60 20 "${listitems[@]}" 2>$tagtmp ; then + inform "Device selection canceled." "3" + rm -f $tagtmp + return 1 + fi + for devname in `cat $tagtmp` ; do + selraiddevs[$devname]="${drives[$devname]}" + done + local finished=1 + if [ ${#selraiddevs[@]} -eq 0 ]; then + pause "You didn't select any devices. If this was your intent, press enter to return to the selection list and select Cancel." + unset finished + fi + done + rm -f $tagtmp + + # Determine possible RAID levels + case ${#selraiddevs[@]} in + 1 ) + # single disk RAID0 is only option + raidlvlopts="0" + ;; + 2 ) + # options are RAID0 or RAID1 + raidlvlopts="0 1" + ;; + * ) + # options are RAID0, RAID1, or RAID5 + raidlvlopts="0 1 5" + ;; + esac + + # Choose configuration + local lvlitems=( ) + tagtmp=`mktemp -q` + for level in $raidlvlopts ; do + if [ "$level" = "0" ]; then + # size is capacity of smallest selected device * number of selected devices + smallestcap=$(printf "%d\n" ${selraiddevs[@]} | sort -rn | tail -n1) + numdrives=${#selraiddevs[@]} + let "totalbytes=smallestcap*numdrives" + totalgb=$(( $totalbytes / 1073741824 )) + lvlitems+=( "$level" "striped RAID no parity, $totalgb Gb, NO REDUNDANCY" "off" ) + fi + if [ "$level" = "1" ]; then + # size is capacity of smallest selected device + totalbytes=$(printf "%d\n" ${selraiddevs[@]} | sort -rn | tail -n1) + totalgb=$(( $totalbytes / 1073741824 )) + lvlitems+=( "$level" "mirrored RAID, $totalgb Gb, fault tolerant" "off" ) + fi + if [ "$level" = "5" ]; then + # size is capacity of smallest selected device * number of selected devices - capacity of smallest selected device + smallestcap=$(printf "%d\n" ${selraiddevs[@]} | sort -rn | tail -n1) + numdrives=${#selraiddevs[@]} + let "totalbytes=smallestcap*numdrives-smallestcap" + totalgb=$(( $totalbytes / 1073741824 )) + lvlitems+=( "$level" "striped RAID with parity, $totalgb Gb, fault tolerant" "off" ) + fi + done + + prompttext="Select desired RAID level" + tagtmp=`mktemp -q` + # Select level + unset finished + flush_input + while [ ! $finished ] ; do + if ! dialog --radiolist "$prompttext" 20 60 20 "${lvlitems[@]}" 2>$tagtmp ; then + inform "Level selection canceled." + rm -f $tagtmp + return 1 + fi + sellevel=`cat $tagtmp` + finished=1 + done + rm -f $tagtmp + + # Confirm data destruction + if ! approved "WARNING! All existing data on the devices you selected will be destroyed. Proceed?" "n"; then + inform "RAID creation cancelled." + return 1 + fi + + # Remove any existing partitions and RAID metadata + inform "Clearing partition tables and old RAID metadata" "1" + newraidparts=( ) + for rdevice in ${!selraiddevs[@]} ; do + sgdisk -Z $rdevice >/dev/null 2>&1 + dd if=/dev/zero of=$rdevice bs=1024k count=2000 >/dev/null 2>&1 + dd if=/dev/zero of=$rdevice bs=512 count=2048 seek=$((`blockdev --getsz $rdevice` -2048)) >/dev/null 2>&1 + if echo $rdevice | grep -q sd ; then + newraidparts+=( "$rdevice""1" ) + elif echo $rdevice | grep -q nvme ; then + newraidparts+=( "$rdevice""p1" ) + fi + done + + # Create a single GPT partition using entire drive for each selected drive + inform "Creating new partition tables" "1" + for rdevice in ${!selraiddevs[@]} ; do + parted -s $rdevice mklabel gpt + parted -s $rdevice mkpart primary ext2 0% 100% + parted -s $rdevice set 1 raid on + sleep 2 + partprobe $rdevice + done + + # Create RAID set of selected level and create filesystem. + inform "Creating RAID set" "1" + case $sellevel in + 0 ) + # Create raid 0. Use force if single drive. + if [[ ${#newraidparts[@]} == 1 ]]; then + if ! mdadm --create /dev/md0 --quiet --level=0 --force --raid-devices=1 ${newraidparts[@]} ; then + pause "RAID set creation failed." + return 1 + else + echo "32768" > /sys/block/md0/md/stripe_cache_size + fi + else + if ! mdadm --create /dev/md0 --quiet --level=0 --raid-devices=${#newraidparts[@]} ${newraidparts[@]} ; then + pause "RAID set creation failed." + return 1 + else + echo "32768" > /sys/block/md0/md/stripe_cache_size + fi + fi + sleep 3 + # Create filesystem + if ! mkfs.ext4 -b 4096 -m .1 /dev/md0 | dialog --progressbox "Creating filesystem. This make take a while..." 24 80 ; then + pause "Filesystem creation failed." + return 1 + fi + if [ ! -d "$RAID_MNT_PT" ]; then + mkdir $RAID_MNT_PT + fi + inform "Mounting RAID set and creating new image path..." + mount /dev/md0 $RAID_MNT_PT + sleep 2 + mkdir $IMAGE_PATH;; + 1 ) + # Create raid 1 + if ! mdadm --create /dev/md0 --quiet --level=1 --raid-devices=${#newraidparts[@]} ${newraidparts[@]} ; then + pause "RAID set creation failed." + return 1 + else + echo "32768" > /sys/block/md0/md/stripe_cache_size + fi + sleep 3 + # Create filesystem + if ! mkfs.ext4 -b 4096 -m .1 /dev/md0| dialog --progressbox "Creating filesystem. This make take a while..." 24 80 ; then + pause "Filesystem creation failed." + return 1 + fi + if [ ! -d "$RAID_MNT_PT" ]; then + mkdir $RAID_MNT_PT + fi + inform "Mounting RAID set and creating new image path..." + mount /dev/md0 $RAID_MNT_PT + sleep 2 + mkdir $IMAGE_PATH + ;; + 5 ) + # Create raid 5 + if ! mdadm --create /dev/md0 --quiet --level=5 --raid-devices=${#newraidparts[@]} ${newraidparts[@]} ; then + pause "RAID set creation failed." + return 1 + else + echo "32768" > /sys/block/md0/md/stripe_cache_size + fi + sleep 3 + # Create filesystem + if ! mkfs.ext4 -b 4096 -m .1 -E stride=128,stripe-width=$((128*(${#newraidparts[@]}-1))) /dev/md0 | dialog --progressbox "Creating filesystem. This make take a while..." 24 80 ; then + pause "Filesystem creation failed." + return 1 + fi + if [ ! -d "$RAID_MNT_PT" ]; then + mkdir $RAID_MNT_PT + fi + inform "Mounting RAID set and creating new image path..." + mount /dev/md0 $RAID_MNT_PT + sleep 2 + mkdir $IMAGE_PATH + ;; + * ) + # ? + pause "Invalid RAID level. RAID creation failed." + return 1 + ;; + esac + return 0 +} + +function export() { + # Export backups to other media + pause "the export() function would run now." + + # Select export media + if ! iedevselect ; then + pause "Couldn't select export media." + return 1 + fi + # we now have ie_media_type, ie_media_dev, ie_media_cap + + # Select images to export + buildimagelist + imgcount=`wc -l $radiotmp|cut -d " " -f1` + if [ $imgcount -eq 1 ]; then + # only one image found + imagename=`cat $radiotmp|cut -d " " -f1|tr -d '"'` + pause "$imagename was the only image found. Selecting that to export." + rm -f $radiotmp + return 0 + else + if ! pickimagename "export" "multiple"; then + rm -f $radiotmp + pause "Couldn't select images to export." + return 1 + fi + fi + # we now have imagename + + if [ "$ie_media_type" = "optical" ]; then + for expimage in $imagename ; do + imagesz=$(du $IMAGE_PATH/$expimage | awk '{print $1}') + done + fi + # Determine total size of images to export (for non-optical media) + tcap=0 + for expimage in $imagename ; do + imagesz=$(du $IMAGE_PATH/$expimage | awk '{print $1}') + tcap=$(echo "$tcap + $imagesz"|bc) + done + # we now have total required size in tcap + + if [ "$ie_media_type" = "optical" ]; then + numdiscs=$(echo "fd=$tcap/$ie_media_cap;scale=0;fd/1+1"|bc) + + fi +} + +function iedevselect() { + # Prompt user to select export or import media type and device. Mount + # device if it's not optical media. + # Takes one argument, "import" or "export". + # Sets variables, ie_media_type, ie_media_dev, ie_media_cap. + ie_op=$1 + iemttemp=`mktemp -q` + while true ; do + if ! dialog --menu "Select $ie_op media type" 12 40 8 \ + "O" "Optical" \ + "U" "USB" \ + "L" "Local" \ + "?" "import/export help" 2> $iemttemp ; then + rm -f $iemttemp + return 0 + else + iemt=`cat $iemttemp` + rm -f $iemttemp + fi + case $iemt in + "O" ) + ie_media_type="optical" + log "$ie_op media type set to $media_type." + unset ieoptdrive + for optdrive in `ls /dev/sr{0,1} 2>/dev/null`; do + if ! mount|grep -q $optdrive ; then ieoptdrive=$optdrive; fi + done + if [ ! $ieoptdrive ]; then + pause "No usable optical drive found." + return 1 + fi + ie_media_dev=$ieoptdrive + if [ "$ie_op" = "export" ]; then + omttemp=`mktemp -q` + if ! dialog --menu "Select optical media type" 12 40 8 \ + "1" "700MB CD-R" \ + "2" "4.3GB DVD+R" \ + "3" "7.9GB DVD+R DL" \ + "4" "22.5GB BD-R" \ + "5" "46.5GB BD-R DL" 2> $omttemp ; then + rm -f $omttemp + return 0 + else + omt=`cat $omttemp` + rm -f $omttemp + fi + case $omt in + 1 ) ie_media_cap=$(echo "700*1024"|bc) ;; + 2 ) ie_media_cap=$(echo "4.3*1024*1024"|bc) ;; + 3 ) ie_media_cap=$(echo "7.9*1024*1024"|bc) ;; + 4 ) ie_media_cap=$(echo "22.5*1024*1024"|bc) ;; + 5 ) ie_media_cap=$(echo "46.5*1024*1024"|bc) ;; + * ) ie_media_cap=0 ;; + esac + fi + return 0 + ;; + + "U" ) + ie_media_type="USB" + log "$ie_op media type set to $media_type." + local infotext="Searching for USB drive" + flush_input + searching=1 + while [ $searching ]; do + infotext="$infotext ." + dialog --begin 3 5 --infobox "Plug in USB drive now or press any key to abort. If drive is already plugged in, and is not detected, unplug it, wait a few seconds, and plug it in again." 0 0 \ + --and-widget \ + --begin 10 5 --sleep 1 --infobox "$infotext" 14 70 + if read -s -n1 -t1 kp <&1 ; then + pause "USB media mounting aborted." + log "USB media mounting aborted." + unset searching + return 1 + fi + if [ -e /tmp/usbdriveinfo ] ; then + unset searching + fi + done + ie_media_dev=$(grep DEVNAME /tmp/usbdriveinfo|cut -d"=" -f2) + if [ ! -e "$ie_media_dev""1" ]; then + if approved "The USB drive you inserted doesn't appear to be partitioned. Would you like to partition and create a filesystem on it now (all existing data will be lost)?" "n" ; then + parted -s $ie_media_dev mklabel gpt + parted -s $ie_media_dev mkpart primary ext2 0% 100% + sleep 2 + partprobe $rdevice + mkfs.ext4 -b 4096 -m .1 $ie_media_dev"1" | dialog --progressbox "Creating filesystem. Please wait..." 24 80 + else + pause "USB device $ie_media_dev is not usable." + return 1 + fi + fi + ie_media_dev=$ie_media_dev"1" + if ! mount $ie_media_dev /mnt/usb ; then + pause "Could not mount USB device for $ie_op. Aborting." + return 1 + fi + ie_media_cap=$(df --output=avail /mnt/usb|tail -1|tr -d " ") + return 0 + ;; + + "L" ) + ie_media_type="Local" + log "$ie_op media type set to $media_type." + # Determine correct local directory + localdirtmp=`mktemp -q` + path_invalid=true + unset local_dir + while [ $path_invalid ]; do + flush_input + if dialog --inputbox "Enter full path of $ie_op directory" 8 78 "$LOCAL_DIR" 2>$localdirtmp ; then + local_dir=`cat $localdirtmp` + if [ "$local_dir" = "" ]; then + inform "You must enter a valid path or select Cancel to abort." "5" + fi + if [ -d "$local_dir" ]; then + unset path_invalid + elif [ "$local_dir" = "" ]; then + : + else + pause "Specified directory does not exist. Perhaps you made a typo.\nTry again." + fi + else + pause "Local directory setup cancelled." + log "Local directory setup cancelled." + rm -f $localdirtemp + return 1 + fi + done + log "Local $ie_op directory is $local_dir" + rm -f $localdirtemp + ie_media_cap=$(df --output=avail $local_dir|tail -1|tr -d " ") + return 0 + ;; + + "?" ) + if [ -r "$HELP_PATH/importexport.txt" ]; then + dialog --title "RescueBRU Help - Import/export" \ + --no-shadow --textbox $HELP_PATH/importexport.txt 25 80 + else + pause "Help file $HELP_PATH/importexport.txt could not be found. Check your installation." + fi + ;; + esac + done +} + + + +##### Execution begins here ##### + +# Fix the font so dialog boxes aren't corrupt +/usr/bin/setfont + +# Check for presence of RAID set +if ! cat /proc/mdstat|grep -q md ; then + pause "Server RAID set was not found." + # Check for presence of unconfigured drives + if ls /dev/sd* || ls /dev/nvme?n? >/dev/null 2>&1; then + if approved "One or more drives were found that are not configured as part of a RAID set. Would you like to configure a new RAID set?" "n" ; then + if ! createraid ; then + pause "Cannot start server without backup storage." + exit 1 + fi + fi + else + pause "Cannot start server without backup storage." + exit 1 + fi +fi + +# Increase RAID cache size to improve performance +for mddir in `ls /sys/block |egrep -e "md[0-9]+"` ; do + echo "32768" > /sys/block/$mddir/md/stripe_cache_size 2>/dev/null +done + +# Kill off any running DHCP client daemon +dhcpcd -q -k + +# configure /etc/exports +echo "$RAID_MNT_PT $EXPRT_ARGS" > /etc/exports + +# Determine RAID array members +for raiddrv in `cat /proc/mdstat|grep -o -e "sd[a-z]|nvme[0-9]n[0-9]"`; do + RAID_MEMBERS=$RAID_MEMBERS" /dev/$raiddrv" +done +for raidpart in `cat /proc/mdstat|grep -o -e "sd[a-z][1-9]|nvme[0-9]n[0-9]p[0-9]"`; do + RAID_MEMBERS=$RAID_MEMBERS" /dev/$raidpart" +done + +# Mount the RAID set +if [ ! -d "$RAID_MNT_PT" ]; then + mkdir $RAID_MNT_PT +fi +if ! mount|grep -q $RAID_MNT_PT ; then + inform "Mounting RAID set..." + for possible_raid in `ls /dev|egrep -e "md[0-9]+"` ; do + possible_raid_path="/dev/$possible_raid" + if mount $possible_raid_path $RAID_MNT_PT 1>/dev/null 2>&1 ; then + raid_dev=$possible_raid_path + break + fi + done + sleep 2 +else + raid_dev=`mount|grep $RAID_MNT_PT|egrep -o -e "/dev/md[0-9]+"` + inform "RAID set appears to be mounted." +fi + +# Show RAID status +raidtest "inform" +sleep 5 +# Start server by default +server_start + +echo "0000" > /var/lib/nfs/state + +while true; do + mainmenu + case $mainmc in + "P" | "p" ) + shutdown_proc "shutdown" + ;; + + "R" | "r" ) + shutdown_proc "reboot" + ;; + + "S" | "s" ) + if cleanup ; then + inform "Exiting to shell" "2" + reset + exit 0 + else + pause "Could not perform cleanup options. Not exiting." + return 1 + fi + ;; + + 10 ) + editnotestemplate + ;; + + 9 ) + lognoteview + ;; + + 8 ) + inform "Starting RescueBRU" + rescuebru -localserver $IMAGE_PATH $raid_dev $RAID_MEMBERS + ;; + + 7 ) + if [ "$PXE_STAT" = 0 ]; then + inform "Starting PXE boot server" + if ! pxe_start ; then + pause "Errors were encountered while starting PXE boot server." + else + PXE_STAT=1 + fi + else + inform "Stopping PXE boot server" + if ! pxe_stop ; then + pause "Errors were encountered while stopping PXE boot server." + else + PXE_STAT=0 + fi + fi + ;; + + 6 ) + image_mod + ;; + + 5 ) + clientstatus + ;; + + 4 ) + raidtest "pause" + ;; + + 3 ) + show_usage + ;; + + 2 ) + showimages + ;; + + 1 ) + echo + if [ "$SVR_STAT" = 0 ]; then + server_start + else + server_stop + fi + ;; + esac +done + +echo "End of script! If you see this, something is wrong!" +exit 1 diff --git a/customcd/files/root/rescuebru/rescuebru-help/backup.txt b/customcd/files/root/rescuebru/rescuebru-help/backup.txt new file mode 100644 index 0000000..72f80e7 --- /dev/null +++ b/customcd/files/root/rescuebru/rescuebru-help/backup.txt @@ -0,0 +1,35 @@ + +Option 2 of the RescueBRU main menu (Do a backup) allows backups to +be performed. It first attempts to mount the particular backup media +you selected, and then asks you to choose an image name from a list +or supply a new name for the backup. This name will become the name +of the directory on the NFS server or USB drive where the backup +images are stored. It should be short, but descriptive. It cannot +contain spaces or special characters. For example, "SJ#4 Display PC +3 (Pilot/ WSO UFCs)" would not be accepted. A better alternative +would be "sj4disppc3". After you supply a name for the backup, a +directory is created on the backup media to store the images. + +RescueBRU then probes the hard drives and generates a list of drives +and their partitions. Because you may not always want to back up all +partitions of all drives, RescueBRU prompts you whether or not to +back up each MBR and each partition. Select what you want with the +spacebar. After choosing MBRs and partitions, you will be prompted +to confirm the options. Once you have selected Ok and confirmed, the +master boot records and the partitions you chose are backed up. + +An important note about the dd method: +When selecting drives and partitions to be backed up using this +method, be aware that dd backs up the entire drive (/dev/sda +for example) not just the MBR like the other methods. This means +that if you select a drive (/dev/sda) you should probably not select +any of the drive's partitions, since the data contained on them is +already in the backup of the drive itself. Selecting the drive and +its partitions will make the backup take a long, long time and be +ludicrously huge. However, RescueBRU never assumes it knows more +than you and will happily oblige if you tell it to. + +When the backup is complete, the backup media is unmounted and you +are returned to the main menu. From here you can perform other +operations or exit RescueBRU. + diff --git a/customcd/files/root/rescuebru/rescuebru-help/bucomp.txt b/customcd/files/root/rescuebru/rescuebru-help/bucomp.txt new file mode 100644 index 0000000..dd1407e --- /dev/null +++ b/customcd/files/root/rescuebru/rescuebru-help/bucomp.txt @@ -0,0 +1,34 @@ + +This determines the level of compression used when doing a backup. The +following options are available: + +low + +Uses either no compression (for partimage and dd) or the lzo +compression algorithm (for fsarchiver). The advantage is that it's +very fast on the client side. The disadvantage is that the size of +the backup will be large; in most cases as large as the original +data. Using this setting really only makes sense if you have vast +amounts of storage space for your backups and a very fast network, +or if you know that your data is pretty much uncompressible, such as +a compressed database. Note that even though low compression is fast +on the client side, you may still run into speed limitations of the +storage subsystem on the server side, or of the network. + +normal + +Uses the gzip compression algorithm to give the best compromise +between speed and backup size. This is the default compression level. + +high + +Uses the bzip2 compression algorithm (for partimage and dd) or the +lzma compression algorithm (for fsarchiver). This results in a very +good compression ratio requiring less space to store the backup. +However, this comes at the price of high CPU and memory usage on the +client side. A backup done with high compression will probably take +a long, long time to accomplish. Additionally, if there is +insufficient memory available on the client, the compression may +fail altogether, resulting in the backup being stored uncompressed. +If you want to use high compression, testing is advised before +deciding to use it for real. diff --git a/customcd/files/root/rescuebru/rescuebru-help/diskutil.txt b/customcd/files/root/rescuebru/rescuebru-help/diskutil.txt new file mode 100644 index 0000000..92078b7 --- /dev/null +++ b/customcd/files/root/rescuebru/rescuebru-help/diskutil.txt @@ -0,0 +1,59 @@ + +Option 4 of the RescueBRU main menu (Disk Utilities) allows you to +perform various drive maintenance actions. These actions are +described below. + +Clone disk +RescueBRU generates a list of hard drives. You are then prompted to +select the source and destination drives from menus. You will then +be asked to confirm your actions and an exact block by block copy of +all data on the source drive will be created on the destination +drive. The operation may take a long time for large drives. A +progress indicator will be shown. When the clone is finished, you +will be returned to the Disk Utilities menu. + +Blank disk +RescueBRU generates a list of hard drives. You are then prompted to +select the target drive for blanking from a menu. You will then be +asked to confirm your actions and all data on the target drive will +be overwritten with zeros. This will destroy the MBR, the partition +table, and any RAID signatures that may exist on the drive. Any data +that exists on the drive will not be recoverable. NOTE: This will +not satisfy the US DoD 5220.22-M standard and will not serve to +"declassify" a drive. If the drive contained classified data, it +will still need to be stored and controlled in accordance with the +highest classification it contained. When the blanking operation is +finished, you will be returned to the Disk Utilities menu. + +Test disk for bad blocks +RescueBRU generates a list of hard drives. You are then prompted to +select the target drive for testing from a menu. You will also be +prompted whether you want to do a read-only test or a write/read +test. You will then be asked to confirm your actions and the test +will begin. If you have selected a read-only test, no alteration +will be made to any data on the drive.If you have selected a +write/read test, all data on the target drive will be overwritten by +various bit patterns, and finally with zeros. This will destroy the +MBR, the partition table, and any RAID signatures that may exist on +the drive. Any data that exists on the drive will not be +recoverable. NOTE: This will not satisfy the US DoD 5220.22-M +standard and will not serve to "declassify" a drive. If the drive +contained classified data, it will still need to be stored and +controlled in accordance with the highest classification it +contained. When the blanking operation is finished, you will be +returned to the Disk Utilities menu. + +Setup backup media +If using the "Local" media type, media setup is not required. For +the RescueBRU utility to work,the backup images must be stored on +the backup media in a place where RescueBRU can find them. This +option creates the directory on the backup media where the images +will be stored. After selecting this option, RescueBRU mounts the +media, and then checks to see if the backup location already exists. +If it does, RescueBRU warns you that if you continue the setup, you +may lose old backups. You have the option of continuing anyway or +aborting media setup. When a backup is started, the media is checked +to see if it is set up and this function is automatically invoked if +it isn't. Consequently, you should never have to use this option. +This option is really only useful if you want to purge all existing +backups from the media. diff --git a/customcd/files/root/rescuebru/rescuebru-help/general.txt b/customcd/files/root/rescuebru/rescuebru-help/general.txt new file mode 100644 index 0000000..2e39749 --- /dev/null +++ b/customcd/files/root/rescuebru/rescuebru-help/general.txt @@ -0,0 +1,66 @@ + +RescueBRU is the Rescue CD Backup & Restore Utility. It is a user +friendly interface to various programs on the System Rescue CD. + +RescueBRU allows you to create backup images of nearly any PC, even +those on which the filesystems or partitioning schemes are +unsupported. In the event of data corruption or drive hardware +failure, you can restore the backup images to the original drive or +to a new drive of equal or greater capacity. After the restoration, +you just reboot and use the restored drive immediately. No flaky +Norton Ghost boot floppies. No Windows device configuration. No +device driver installation. No IP address or software configuration. +Less downtime. + +Backup files are stored on an NFS server, a portable USB drive, or a +local directory. The general procedure is to run a backup to the +backup media using this custom System Rescue CD. When a drive needs +to be rebuilt, you can boot this CD on the bad machine and restore +directly from the NFS server or the USB drive. For details of how +this works, see the more specific help topics in the help menu. + +When booting the RescueBRU CD, the RescueBRU boot page will appear. +If you are backing up or restoring a single machine, you can just +hit enter to continue booting. You can also backup or restore +multiple machines at once if you are using an NFS server as your +media type. + + +The Main Menu + +The main menu gives you access to all functions of RescueBRU. + +Option 1: Settings menu. Allows you to select which type of media to +use for backup or restore, the method used for backups, and the +action for the program to take after a successful operation. + +Option 2: Do a backup. See the help for Doing a backup. + +Option 3: Do a restore. See the help for Restoring from a backup. + +Option 4: Disk Utilities. See the help for Disk Utilities. + +Option 5: Image Management. Allows you to copy, rename or delete +images stored on the backup media. + +Option 6: View logs or notes. Log files and notes are generated +during most operations of RescueBRU and may be saved with an image +when backups or restores are done. These files may be viewed using +this option. + +Option 7: Show backups available on media. + +Option H: Help. You know what this does, or you wouldn't be here. + +Option S: Exit to shell or Exit and return to rbruserver. This will +exit the RescueBRU program and return you to the System Rescue CD +shell if you ran rescuebru directly from a shell prompt. If +rescuebru was called from the rbruserver program, you will be +returned to rbruserver. + +Option R: Exit and reboot. Reboots the system. + +Option P: Exit and power down. Powers down the system on systems +that support it. For systems that do not support APM or ACPI +poweroff, it halts the system. + diff --git a/customcd/files/root/rescuebru/rescuebru-help/media.txt b/customcd/files/root/rescuebru/rescuebru-help/media.txt new file mode 100644 index 0000000..55b88d2 --- /dev/null +++ b/customcd/files/root/rescuebru/rescuebru-help/media.txt @@ -0,0 +1,22 @@ + +RescueBRU uses an NFS server, portable USB drive, or a local +directory to store backup images. + +Showing backups available on media + +Option 7 of the RescueBRU main menu (Show backups available on +media) does what the name implies. The available backups are listed +by name showing the date and time. + +An important note about using the Local media type for backup/restore: + +If you use the local media type, be aware that the drive designation +(sda, sdb, etc.) will very likely be different than what it is in +the machine the drive is to be used in. For example, if you back up +the drive using the NFS media type, the drive designation may be +sda. If you remove this drive and install it in a RescueBRU server +machine, it may get designated sdc. Attempting to restore it like +this may result in overwriting the server's image storage drive! The +rule of thumb is that the same media type must be used for both the +backup and the restore. If you back it up with NFS, restore it with +NFS. If you back it up with Local, restore it with Local. diff --git a/customcd/files/root/rescuebru/rescuebru-help/mediatype.txt b/customcd/files/root/rescuebru/rescuebru-help/mediatype.txt new file mode 100644 index 0000000..b0a411e --- /dev/null +++ b/customcd/files/root/rescuebru/rescuebru-help/mediatype.txt @@ -0,0 +1,17 @@ + +This determines what type of backup media will be used. The +following options are available: + +NFS +Uses a server on the network to store backups, usually a RescueBRU +server, but it can be any NFS server. The most convenient type. +Multiple PCs can use this simultaneously. Space for backups is +limited only by the amount of storage on the server. This is the +default type. + +USB +Uses a portable USB disk drive or thumb drive. No server required. +This is usually the slowest method. + +Local +Uses a pre-mounted partition on the local machine. For expert use only. diff --git a/customcd/files/root/rescuebru/rescuebru-help/method.txt b/customcd/files/root/rescuebru/rescuebru-help/method.txt new file mode 100644 index 0000000..2fded96 --- /dev/null +++ b/customcd/files/root/rescuebru/rescuebru-help/method.txt @@ -0,0 +1,41 @@ + +This determines how the backup is done. The following options are +available: + +auto + +Analyzes the partitions on the drive to determine the best of the +three methods described below. If the drive contains ext4, reiser4, +or btrfs partitions, fsarchiver will be used. If the drive contains +ext2, ext3, reiserfs, vfat, hpfs, jfs, xfs, ufs, hfs, or ntfs +partitions, partimage will be used. For any other partition type, or +if a drive doesn't contain any partitions, dd will be used. +This is the default. + +partimage + +Uses the partimage utility to make images of individual partitions. +Supports ext2, ext3, reiserfs, FAT16/32, HPFS, JFS, XFS, UFS, HFS, +and NTFS. Saves and restores the MBR(s) and partition table(s). +Recreates Linux swap partitions. Works for most configurations. + +fsarchiver + +Uses the fsarchiver utility to archive the files of a filesystem. +Supports ext2, ext3, reiserfs, XFS, JFS, ext4, reiser4, btrfs, and +NTFS. Saves and restores the MBR(s) and partition table(s). +Recreates Linux swap partitions. More tolerant of drive hardware +failures during backup. After restoring this type of backup, you may +have to reinstall your bootloader, since the restored system files +may not be in the same physical location on the disk. This method is +the fastest method during both backup and restore due to the +multithreaded compression/decompression. + +dd + +Uses the dd utility to create bit-by-bit images of entire hard +drives or partitions. Works for any disk drive with any filesystem +or no filesystem at all. The most reliable method. Also the slowest +method, and uses the most space for backups. Use for drives with LVM +partitions. If none of the other methods work, use this method. + diff --git a/customcd/files/root/rescuebru/rescuebru-help/restore.txt b/customcd/files/root/rescuebru/rescuebru-help/restore.txt new file mode 100644 index 0000000..e1ef882 --- /dev/null +++ b/customcd/files/root/rescuebru/rescuebru-help/restore.txt @@ -0,0 +1,18 @@ + +Option 3 of the RescueBRU main menu allows you to restore previously +backed up images. Make sure the drive you want to restore to is +installed in the PC before booting the System Rescue CD. After +selecting option 3, it first attempts to mount the backup media. +After detecting and mounting the backup media, a list of backups on +the media is shown. You are then prompted to enter the name of the +backup you wish to restore. After specifying the backup to restore, +RescueBRU determines what method was used to back up the PC. + +You are asked which MBRs/drives and partitions you would like to +restore. After you have made your selections, a confirmation message +appears so that you can verify the choices and options. After +selecting Ok to confirm, the MBRs and partitions you have selected +will be restored. + +When the restoration is complete, you are returned to the main menu, +where you can perform other operations or exit RescueBRU. diff --git a/customcd/files/root/rescuebru/rescuebru.sh b/customcd/files/root/rescuebru/rescuebru.sh new file mode 100644 index 0000000..445946f --- /dev/null +++ b/customcd/files/root/rescuebru/rescuebru.sh @@ -0,0 +1,3444 @@ +#!/bin/bash +# rescuebru.sh +# Rescue CD Backup & Restore Utility client script +# version 7.2.5 +# Rod Wright 1/19/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +PROG_NAME="rescuebru.sh" +PROG_VERSION=7.2.5 + +# Paths +RBRU_INSTALL_PATH="/root/rescuebru" +MEDIA_MNT_DIR="/mnt/rescuebru" +BACKUP_DIR="rescuebru-backups" +IMAGE_PATH="$MEDIA_MNT_DIR/$BACKUP_DIR" +HELP_PATH="$RBRU_INSTALL_PATH/rescuebru-help" +NFS_REMOTE_DIR_DEF="/mnt/rescuebru" +LOCAL_DIR="/mnt/rescuebru/rescuebru-backups" +LOG_PATH="/root/rescuebru_logs" + +# Arguments for external programs +PI_BACKUP_ARGS="-cod --debug=1 -M -B\"a=b\" save" +PI_RESTORE_ARGS="-B\"a=b\" --debug=1 restore" +FA_BACKUP_ARGS="savefs -s 2000 -v -d -j4" +FA_RESTORE_ARGS="restfs -v -d -j4" +SFD_RESTORE_ARGS="-q --force --no-reread" +for subnet in `seq 10`; do wlist="$wlist -W 10.111.$subnet.1";done +DHCPCD_RBRUSERVER_ARGS="-d -L -t120 -h rescuebru `echo $wlist`" +DHCPCD_GLOBAL_ARGS="-d -L -t120 -h rescuebru" +MAX_CARRIER_ATTEMPTS=10 + +# Defaults +MEDIA_TYPE_DEF="NFS" +BU_METHOD_DEF="auto" +NFS_SUBNET_DEF="10.111.1" +NFS_REMOTE_ADDR_DEF="$NFS_SUBNET_DEF.1" +NFS_LOCAL_DEF="99" +NFS_CLIENT_START_DEF="20" +NETSETUP_TYPE="auto" +BACKUP_SERVER_TYPE="RescueBRU Server" +POSTACTION_DEF="Return to menu" +BU_COMP_DEF="normal" + +# Initial status +CLIENT_NET_STATUS=0 +LOCAL_STATUS=0 + +# Values +ROUTE_TIMEOUT=30 +MIN_MEDIA_FREE=2048 +NOTES_TEMPLATE="$MEDIA_MNT_DIR/notes_template.txt" + +TEMP_NOTES="/root/${operation}_`date +%Y-%m-%d_%H%M%S`.notes" + +# Logging +LOGGING_ENABLED=1 +SESSION_LOG="$LOG_PATH/session_`date +%Y-%m-%d_%H%M%S`.log" +OPERATION_LOG="/dev/null" # There is no operation yet, but the text + # needs to have somewhere to go. This + # will get redefined as a real file at the + # beginning of a real operation. Set it back + # to /dev/null at the end of a real + # operation so it won't continue to + # accumulate data from subsequent operations. + +# Import functions +source $RBRU_INSTALL_PATH/functions.sh + +# Declare global associative arrays +declare -A blockdevs +declare -A seldevs +declare -A devbm +declare -A images +declare -A selimages +declare -A imgid + +# ----------- BACKUP/RESTORE FUNCTIONS ------------- +function do_backup() { + # Handles backup process + operation="backup" + operation_log "on" + unset imagename srcimagename destimagename iname_confirmed iname_invalid + unset FAIL prabrt + for key in ${!blockdevs[@]}; do unset blockdevs[$key]; done + for key in ${!seldevs[@]}; do unset seldevs[$key]; done + for key in ${!devbm[@]}; do unset devbm[$key]; done + + progreport "" + log "Starting $operation process." + + # Attempt to mount media + media_reqd=1 + if ! media "mount" ; then + pause "Unable to mount backup media." + log "Unable to mount backup media." + operation_log "off" + rm -f $LOG_PATH/backup*.log + return 1 + fi + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and is performing a backup.">$MEDIA_MNT_DIR/$wkg_addr + fi + + # Check that media is set up + if [ ! -d $IMAGE_PATH ]; then + inform "Backup media is not set up." + if ! mediasetup ; then + pause "Backup media could not be set up. Aborting." + log "Backup media could not be set up. Aborting." + operation_log "off" + rm -f $LOG_PATH/backup*.log + return 1 + fi + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and is performing a backup.">$MEDIA_MNT_DIR/$wkg_addr + fi + fi + + # Get image name + if ! getimagename "backup" ; then + pause "User aborted while getting image name." + log "User aborted while getting image name." + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + operation_log "off" + rm -f $LOG_PATH/backup*.log + return 0 + fi + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and is performing a backup of $imagename.">$MEDIA_MNT_DIR/$wkg_addr + fi + + # Get info on all disks + log "Getting disk information..." + inform "Getting disk information..." "2" + if getblkdevs ; then + log "Got disk information." + else + pause "Couldn't get disk information." + log "Couldn't get disk information." + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + operation_log "off" + rm -f $LOG_PATH/backup*.log + return 1 + fi + + # Select devices to be backed up + log "Selecting device(s) to back up..." + inform "Selecting device(s) to back up..." "2" + if deviceselect "multiple" "Select devices to back up"; then + log "Selected device(s) to back up." + else + pause "Couldn't select device(s) to back up." + log "Couldn't select device(s) to back up." + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + operation_log "off" + rm -f $LOG_PATH/backup*.log + return 0 + fi + + # Analyze and determine backup method if set to auto + if [[ $bu_method = "auto" ]]; then + inform "Determining backup method." + log "Determining backup method." + method_analyze + fi + + # Get notes for backup + log "Getting notes for $operation." + if [ -e $NOTES_TEMPLATE ]; then + cat $NOTES_TEMPLATE>$TEMP_NOTES + else + touch $TEMP_NOTES + fi + get_notes "$operation of $imagename" + + # Get backup version + log "Getting backup version..." + get_version "$operation of $imagename" + log "Backup version is $bu_version" + + # Set compression level arguments + setcomplevel + + # Confirm actions + log "Confirming actions..." + if confirm_actions ; then + inform "Backup actions confirmed." "2" + log "Backup actions confirmed." + + # Write the status file + + + # Create the directory + if createdir ; then + log "Backup directory created." + else + pause "Backup directory could not be created." + log "Backup directory could not be created." + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + operation_log "off" + rm -f $LOG_PATH/backup*.log + return 1 + fi + + # Write version number file + if echo "$bu_version">$IMAGE_PATH/$imagename/version.txt ; then + inform "Wrote version number file." "2" + log "Wrote version number file." + else + inform "WARNING: Couldn't write version number file." + log "WARNING: Couldn't write version number file." + fi + + # Write backup date file + if date +%Y-%m-%d >$IMAGE_PATH/$imagename/latest_backup_date.txt ; then + inform "Wrote backup date file." "2" + log "Wrote backup date file." + else + inform "WARNING: Couldn't write backup date file." + log "WARNING: Couldn't write backup date file." + fi + + # Run backups of selected devices + for budev in `echo ${!seldevs[@]}|tr " " "\n"|sort|tr "\n" " "` ; do + # Determine device type + if echo $budev|egrep -q -o -e "sd[a-z]$|c[0-9]d[0-9]$|hd[a-z]$|nvme[0-9]n[0-9]$" ; then + # device is a drive + backup="drivebackup" + elif echo $budev|egrep -q -o -e "sd[a-z][1-9]$|c[0-9]d[0-9]p[0-9]$|hd[a-z][1-9]$|nvme[0-9]n[0-9]p[0-9]$" ; then + # device is a partition + backup="partbackup" + else + pause "$FUNCNAME : $LINENO :Internal program error! Unable to determine devtype!" + FAIL=1 + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + operation_log "off" + rm -f $LOG_PATH/backup*.log + return 1 + fi + id="${seldevs[$budev]}" + log "Starting backup of $budev." + inform "Starting backup of $budev." "2" + if $backup $budev "$id"; then + log "Backup of $budev succeeded." + inform "Backup of $budev succeeded." "2" + else + inform "Errors were encountered while backing up $budev." + log "Errors were encountered while backing up $budev." + FAIL=1 + break + fi + done + else + pause "$operation aborted by user." + log "$operation aborted." + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + if [ $media_reqd ]; then media "unmount"; fi + operation_log "off" + rm -f $LOG_PATH/backup*.log + return 0 + fi + if [ ! "$FAIL" ]; then + inform "Backup finished." + log "Backup finished." + if [ $media_reqd ]; then + if [ $imgovr ]; then + log "Replacing $finalimgname with $imagename." + inform "Replacing $finalimgname with $imagename. Please wait..." + rm -rf $IMAGE_PATH/$finalimgname + mv $IMAGE_PATH/$imagename $IMAGE_PATH/$finalimgname + inform "Replacing $finalimgname with $imagename. Please wait... Done" + else + finalimgname=$imagename + fi + fi + if [ "$postaction" = "Reboot" ]; then + log "Backup finished. Starting automatic reboot..." + inform "Backup finished. Starting automatic reboot..." + if [ $media_reqd ]; then + cp $LOG_PATH/*.log $IMAGE_PATH/$finalimgname/ + cp $TEMP_NOTES $IMAGE_PATH/$finalimgname/backup_`date +%Y-%m-%d_%H%M%S`.notes + rm -f $TEMP_NOTES + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + fi + if ! shutdown_proc "reboot" ; then + if [ $media_reqd ]; then media "mount"; fi + pause "Reboot aborted." + log "Reboot aborted." + let prabrt=1 + fi + fi + if [ "$postaction" = "Shut Down" ]; then + log "Backup finished. Starting automatic shutdown..." + inform "Backup finished. Starting automatic shutdown..." + if [ $media_reqd ]; then + cp $LOG_PATH/*.log $IMAGE_PATH/$finalimgname/ + cp $TEMP_NOTES $IMAGE_PATH/$finalimgname/backup_`date +%Y-%m-%d_%H%M%S`.notes + rm -f $TEMP_NOTES + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + fi + if ! shutdown_proc "shutdown" ; then + if [ $media_reqd ]; then media "mount";fi + pause "Powerdown aborted." + log "Powerdown aborted." + let prabrt=1 + fi + fi + dialog --textbox $OPERATION_LOG 24 80 + if [ ! $prabrt ]; then + if [ $media_reqd ]; then + cp $LOG_PATH/*.log $IMAGE_PATH/$finalimgname/ + cp $TEMP_NOTES $IMAGE_PATH/$finalimgname/backup_`date +%Y-%m-%d_%H%M%S`.notes + rm -f $TEMP_NOTES + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + fi + fi + else + inform "Backup FAILED!" + log "Backup FAILED!" + if [ $imgovr ]; then + inform "NOT replacing original backup." + log "NOT replacing original backup." + fi + if [ -s "$OPERATION_LOG" ]; then dialog --title "Backup Log" --textbox $OPERATION_LOG 24 80 ;fi + if [ $media_reqd ]; then + cp $LOG_PATH/*.log $IMAGE_PATH/$imagename/ + cp $TEMP_NOTES $IMAGE_PATH/$imagename/`date +%Y-%m-%d_%H%M%S`backup.notes + if approved "Would you like to keep the failed backup?" "y"; then + inform "Saving failed backup as $imagename.fail. Please wait..." + mv $IMAGE_PATH/$imagename $IMAGE_PATH/$imagename.fail + inform "Saving failed backup as $imagename.fail. Please wait... done." + else + inform "Removing $imagename. Please wait..." + rm -rf $IMAGE_PATH/$imagename + inform "Removing $imagename. Please wait... done." + fi + + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + fi + fi + operation_log "off" + rm -f $LOG_PATH/backup*.log + return 0 +} + +function do_restore() { + # Handles restoration process + operation="restore" + operation_log "on" + unset imagename srcimagename destimagename iname_confirmed iname_invalid + unset FAIL prabrt + for key in ${!images[@]}; do unset images[$key]; done + for key in ${!selimages[@]}; do unset selimages[$key]; done + for key in ${!imgid[@]}; do unset imgid[$key]; done + + log "Starting $operation process." + + # Attempt to mount media + media_reqd=1 + if ! media "mount" ; then + pause "Unable to mount backup media." + log "Unable to mount backup media." + operation_log "off" + rm -f $LOG_PATH/restore*.log + return 1 + fi + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and is performing a restore.">$MEDIA_MNT_DIR/$wkg_addr + fi + + # Get image name + if ! getimagename "restore" ; then + pause "User aborted while getting image name." + log "User aborted while getting image name." + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + operation_log "off" + rm -f $LOG_PATH/restore*.log + return 1 + fi + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and is performing a restore of $imagename.">$MEDIA_MNT_DIR/$wkg_addr + fi + + # Get info on all disks + log "Getting disk information..." + inform "Getting disk information..." "2" + if getblkdevs ; then + log "Got disk information on block devices" + else + pause "Couldn't get disk information." + log "Couldn't get disk information." + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + operation_log "off" + rm -f $LOG_PATH/restore*.log + return 1 + fi + + # Build an array of images + log "Getting saved images..." + if getimages ; then + log "Got saved images." + else + pause "Couldn't get saved images." + log "Couldn't get saved images." + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + operation_log "off" + rm -f $LOG_PATH/restore*.log + return 1 + fi + + # Select images to be restored + log "Selecting image(s) to be restored..." + sleep 2 + if imageselect ; then + sleep 3 + log "Selected image(s) to restore." + else + pause "Couldn't select image(s) to restore." + log "Couldn't select image(s) to restore." + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + operation_log "off" + rm -f $LOG_PATH/restore*.log + return 1 + fi + + # Analyze and warn about images too big for drive + for aimg in ${!selimages[@]} ; do + # get the size of the device that was backed up + if busize=$(cat $IMAGE_PATH/$imagename/`echo "$aimg"|rev|cut -d"/" -f1|rev`.sz) ; then + # if the backup is a partition, get drive name + if echo "$aimg"|egrep -q -o -e "sd[a-z][1-9]$|c[0-9]d[0-9]p[0-9]$|hd[a-z][1-9]$|nvme[0-9]n[0-9]p[0-9]$" ; then + if echo "$aimg"|egrep -q -o -e "c[0-9]+d[0-9]+p[0-9]+|nvme[0-9]+n[0-9]+p[0-9]+" ; then + local drive=`echo $aimg|rev|cut -c3-|rev` + else + local drive=`echo $aimg|rev|cut -c2-|rev` + fi + else + local drive="$aimg" + fi + if contains "$drive" ${!blockdevs[@]} ; then + devsize=`blockdev --getsize64 $drive 2>/dev/null` + if [ $busize -gt $devsize ]; then + if ! approved "The device this image was made for was larger than the + current disk. It probably will fail to restore correctly. Proceed anyway?" "n"; then + inform "Restore aborted." + log "Restore aborted." + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + operation_log "off" + rm -f $LOG_PATH/restore*.log + return 1 + fi + fi + else + pause "The disk this backup was created from no longer exists. Restore aborted." + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + operation_log "off" + rm -f $LOG_PATH/restore*.log + return 1 + fi + else + log "Unable to determine size of the original drive." + inform "Unable to determine size of the original drive." + fi + done + + # Get notes for restore + log "Getting notes for $operation." + get_notes "$operation of $imagename" + + # Confirm actions + log "Confirming actions..." + if confirm_actions ; then + inform "Restore actions confirmed." "2" + log "Restore actions confirmed." + log "Backup method was $bu_method" + + # Restore selected images + for devimg in `echo ${!selimages[@]}|tr " " "\n"|sort|tr "\n" " "` ; do + # Determine device type + if echo $devimg|egrep -q -o -e "sd[a-z]$|c[0-9]d[0-9]$|hd[a-z]$|nvme[0-9]n[0-9]$" ; then + # device is a drive + restore="driverestore" + elif echo $devimg|egrep -q -o -e "sd[a-z][1-9]$|c[0-9]d[0-9]p[0-9]$|hd[a-z][1-9]$|nvme[0-9]n[0-9]p[0-9]$" ; then + # device is a partition + restore="partrestore" + else + pause "$FUNCNAME : $LINENO :Internal program error! Unable to determine devtype!" + FAIL=1 + operation_log "off" + rm -f $LOG_PATH/restore*.log + return 1 + fi + method="${selimages[$devimg]}" + log "Starting restore of $devimg ." + inform "Starting restore of $devimg." "2" + if $restore $devimg $method; then + inform "Restore of $devimg succeeded." "2" + log "Restore of $devimg succeeded." + else + inform "Errors were encountered while restoring $devimg ." + log "Errors were encountered while restoring $devimg." + FAIL=1 + break + fi + done + else + pause "$operation aborted by user." + log "$operation aborted." + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + if [ $media_reqd ]; then media "unmount"; fi + operation_log "off" + rm -f $LOG_PATH/restore*.log + return 0 + fi + if [ ! "$FAIL" ]; then + if [ "$postaction" = "Reboot" ]; then + log "Restore finished. Starting automatic reboot..." + inform "Restore finished. Starting automatic reboot..." + if [ $media_reqd ]; then + cp $LOG_PATH/*.log $IMAGE_PATH/$imagename/ + cp $TEMP_NOTES $IMAGE_PATH/$imagename/restore_`date +%Y-%m-%d_%H%M%S`.notes + rm -f $TEMP_NOTES + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + fi + if ! shutdown_proc "reboot" ; then + if [ $media_reqd ]; then media "mount"; fi + pause "Reboot aborted." + log "Reboot aborted." + let prabrt=1 + fi + fi + if [ "$postaction" = "Shut Down" ]; then + log "Restore finished. Starting automatic shutdown..." + inform "Restore finished. Starting automatic shutdown..." + if [ $media_reqd ]; then + cp $LOG_PATH/*.log $IMAGE_PATH/$imagename/ + cp $TEMP_NOTES $IMAGE_PATH/$imagename/restore_`date +%Y-%m-%d_%H%M%S`.notes + rm -f $TEMP_NOTES + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + fi + if ! shutdown_proc "shutdown" ; then + if [ $media_reqd ]; then media "mount";fi + pause "Powerdown aborted." + log "Powerdown aborted." + let prabrt=1 + fi + fi + if [ -s "$OPERATION_LOG" ]; then dialog --title "Restore Log" --textbox $OPERATION_LOG 24 80 ;fi + if [ ! $prabrt ]; then + if [ $media_reqd ]; then + cp $LOG_PATH/*.log $IMAGE_PATH/$imagename/ + cp $TEMP_NOTES $IMAGE_PATH/$imagename/restore_`date +%Y-%m-%d_%H%M%S`.notes + rm -f $TEMP_NOTES + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + fi + fi + else + inform "Restore FAILED!" + log "Restore FAILED!" + if [ -s "$OPERATION_LOG" ]; then dialog --title "Restore Log" --textbox $OPERATION_LOG 24 80 ;fi + if [ $media_reqd ]; then + cp $LOG_PATH/*.log $IMAGE_PATH/$imagename/ + cp $TEMP_NOTES $IMAGE_PATH/$imagename/restore_`date +%Y-%m-%d_%H%M%S`.notes + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + fi + fi + operation_log "off" + rm -f $LOG_PATH/restore*.log + return 0 +} + +function do_image_mod() { + # Sets up for image management processes + unset imagename srcimagename destimagename iname_confirmed iname_invalid + # Attempt to mount media + media_reqd=1 + if ! media "mount" ; then + pause "Unable to mount backup media." + log "Unable to mount backup media." + return 1 + fi + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and is modifying images.">$MEDIA_MNT_DIR/$wkg_addr + fi + image_mod + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + return 0 +} + +function get_notes() { + # Prompt user to enter notes to be saved with a backup or restore. + # Takes one argument, the title text of the dialog box + notetexttmp=`mktemp -q` + if [ $imgovr ]; then + if lastbkupnotes=`ls $IMAGE_PATH/$imagename/backup*notes|sort|tail -1 2>/dev/null` ; then + inform "Importing previous backup notes" + cp -f $lastbkupnotes $TEMP_NOTES + fi + fi + touch $TEMP_NOTES + if dialog --title "$1" \ + --backtitle "Enter notes or leave blank then Tab to or and press enter." \ + --ok-label "Submit" --cancel-label "No notes" \ + --editbox $TEMP_NOTES 20 80 2>$notetexttmp ; then + cp -f $notetexttmp $TEMP_NOTES + else + rm -f $TEMP_NOTES + fi + rm -f $notetexttmp +} + +function get_version() { + # Prompt user to enter version number to be saved with a backup. + # Takes one argument, the title text of the dialog box. + # Creates a string variable, bu_version, containing version text + local verstext_invalid=1 + while [ $verstext_invalid ]; do + verstmp=`mktemp -q` + if dialog --title "$1" \ + --backtitle "Enter a version string for this backup or leave blank and press enter." \ + --ok-label "Submit" --no-cancel \ + --inputbox "Backup Version:" 0 0 2>$verstmp ; then + bu_version=`cat $verstmp|sed 's/ /_/g'` + if ! validate_text name $bu_version; then + pause "Version string contains invalid characters. Valid characters are upper and lowercase letters, numbers, underscores, dashes, and periods. Try again." 0 0 + else + unset verstext_invalid + rm -f $verstmp + fi + fi + rm -f $verstmp + done +} + +function drivebackup() { + # Back up a partition table or a drive + # Takes two arguments. First is the full path device name. Second + # is the id (value in seldevs) + local retval=0 + local devname=$1 + local id=$2 + + # Determine effective backup method + if [[ $bu_method = "auto" ]]; then + eff_bu_method="${devbm[$devname]}" + else + eff_bu_method="$bu_method" + fi + + # Determine filename + local basefn=`echo $devname|rev|cut -d/ -f1|rev` + + # Save S.M.A.R.T. info for device + if smartctl -a $devname >/dev/null 2>&1 ; then + smartctl -a $devname > $IMAGE_PATH/$imagename/$basefn.sm + inform "S.M.A.R.T. info for $devname saved." "2" + log "S.M.A.R.T. info for $devname saved." + log "`cat $IMAGE_PATH/$imagename/$basefn.sm|egrep -A3 -e \"Device:|Device Model:\"`" + else + inform "S.M.A.R.T. info not available for $devname." "2" + log "S.M.A.R.T. info not available for $devname." + fi + + # Save drive size info + drivesize=`blockdev --getsize64 $devname` + if echo $drivesize > $IMAGE_PATH/$imagename/$basefn.sz ; then + inform "drive size info for $devname saved." "2" + log "drive size info for $devname saved." + else + inform "ERROR: drive size info for $devname could not be saved." + log "ERROR: drive size info for $devname could not be saved." + FAIL=1 + local retval=1 + fi + + # Save id of device + if echo $id > $IMAGE_PATH/$imagename/$basefn.id ; then + inform "disk ID of $devname saved." "2" + log "disk ID of $devname saved." + else + inform "ERROR: disk ID of $devname could not be saved." + log "ERROR: disk ID of $devname could not be saved." + FAIL=1 + local retval=1 + fi + + if [[ $eff_bu_method = "dd" ]]; then + # If this is a dd backup, dd the drive + inform "$eff_bu_method backup of $devname started..." "2" + if monitor "dd if=$devname conv=sync,noerror|pv -s $drivesize|$ddb_comp|split --bytes=2000m --suffix-length=3 --numeric-suffixes - $IMAGE_PATH/$imagename/$basefn.dd." "pausable" ; then + inform "$eff_bu_method backup of $devname succeeded." "2" + log "$eff_bu_method backup of $devname succeeded." + else + inform "ERROR: $eff_bu_method $operation of $devname failed." + log "ERROR: $eff_bu_method $operation of $devname failed." + FAIL=1 + local retval=1 + fi + elif [[ $eff_bu_method = "partimage" || $eff_bu_method = "fsarchiver" ]]; then + # Determine if we have an MBR or GPT partition scheme + local ptable_type=`fdisk -l $devname|grep "Disklabel type:"|cut -d: -f2|tr -d ' '` + if [[ $ptable_type = "dos" ]]; then + # Save fdisk output for device + if fdisk -l $devname > $IMAGE_PATH/$imagename/$basefn.fd ; then + inform "fdisk info for $devname saved." "2" + log "fdisk info for $devname saved." + else + inform "ERROR: fdisk info for $devname could not be saved." + log "ERROR: fdisk info for $devname could not be saved." + FAIL=1 + local retval=1 + fi + + # Save MBR + if dd if=$devname of=$IMAGE_PATH/$imagename/$basefn.mbr bs=512 count=1 ; then + inform "MBR of $devname saved." "2" + log "MBR of $devname saved." + else + inform "ERROR: MBR of $devname could not be saved." + log "ERROR: MBR of $devname could not be saved." + FAIL=1 + local retval=1 + fi + + # Save extended partition info + if sfdisk -d $devname > $IMAGE_PATH/$imagename/$basefn.sf ; then + inform "extended partition info of $devname saved." "2" + log "extended partition info of $devname saved." + else + inform "ERROR: extended partition info of $devname could not be saved." + log "ERROR: extended partition info of $devname could not be saved." + FAIL=1 + local retval=1 + fi + elif [[ $ptable_type = "gpt" ]]; then + # Save gpt data for device + if sgdisk -b $IMAGE_PATH/$imagename/$basefn.gpt $devname ; then + inform "GPT partition info of $devname saved." "2" + log "GPT partition info of $devname saved." + else + inform "ERROR: GPT partition info of $devname could not be saved." + log "ERROR: GPT partition info of $devname could not be saved." + FAIL=1 + local retval=1 + fi + else + inform "ERROR: Could not determine partition table type of $devname." + log "ERROR: Could not determine partition table type of $devname." + FAIL=1 + local retval=1 + fi + fi + sync + return $retval +} + +function driverestore() { + # Restores MBRs and extended partition info or dd images to a drive + # Takes two arguments. First is the full path image name. + # Second is the backup method used + local retval=0 + local devname=$1 + local eff_bu_method=$2 + local basefn=`echo $devname|rev|cut -d/ -f1|rev` + + # Display S.M.A.R.T. info of original device + log "Original drive was: `cat $IMAGE_PATH/$imagename/$basefn.sm|head -8|tail -4`" + inform "Original drive was: `cat $IMAGE_PATH/$imagename/$basefn.sm|head -8|tail -4`" "4" + + # Display S.M.A.R.T. info of current device + if smartctl -a $devname >/dev/null 2>&1 ; then + log "Current drive is: `smartctl -a $devname|head -8|tail -4`" + inform "Current drive is: `smartctl -a $devname|head -8|tail -4`" "4" + else + log "S.M.A.R.T. info not available for $devname." + inform "S.M.A.R.T. info not available for $devname." "4" + fi + + if [ "$eff_bu_method" = "dd" ]; then + # If this was a dd backup, determine the compression level used + if file $IMAGE_PATH/$imagename/$basefn.dd.000|grep -q bzip2; then + bu_comp="high" + elif file $IMAGE_PATH/$imagename/$basefn.dd.000|grep -q gzip; then + bu_comp="normal" + else + bu_comp="low" + fi + setcomplevel + # dd the image + inform "$eff_bu_method restore of $devname started..." "2" + if imgsize=`cat $IMAGE_PATH/$imagename/$basefn.sz` ; then + progress_cmd="pv -s $imgsize" + else + progress_cmd="pv -prb" + fi + if monitor "cat $IMAGE_PATH/$imagename/$basefn.dd.*|$ddr_comp|$progress_cmd|dd of=$devname" "nopause" ; then + inform "$eff_bu_method restore of $devname succeeded." "2" + log "$eff_bu_method restore of $devname succeeded." + else + inform "ERROR: $eff_bu_method $operation of $devname failed." + log "ERROR: $eff_bu_method $operation of $devname failed." + FAIL=1 + local retval=1 + fi + inform "Re-reading partition table of $devname." "2" + log "Re-reading partition table of $devname." + partprobe $devname + elif [[ $eff_bu_method = "partimage" || $eff_bu_method = "fsarchiver" ]]; then + # Determine the partition table type of the backup + if [ -e $IMAGE_PATH/$imagename/$basefn.mbr ]; then + # Restore MBR and extended partition info + dd if=$IMAGE_PATH/$imagename/$basefn.mbr of=$devname >/dev/null 2>&1 + if sfdisk $SFD_RESTORE_ARGS $devname < $IMAGE_PATH/$imagename/$basefn.sf >/dev/null 2>&1; then + inform "$operation of MBR and extended partition info of $devname successful." "2" + log "$operation of MBR and extended partition info of $devname successful." + else + partprobe $devname + if ! sfdisk $SFD_RESTORE_ARGS $devname < $IMAGE_PATH/$imagename/$basefn.sf >/dev/null 2>&1; then + inform "ERROR: $operation of MBR and extended partition info of $devname failed." + log "ERROR: $operation of MBR and extended partition info of $devname failed." + FAIL=1 + local retval=1 + else + inform "$operation of MBR and extended partition info of $devname successful." "2" + log "$operation of MBR and extended partition info of $devname successful." + fi + fi + inform "Re-reading partition table of $devname." "2" + log "Re-reading partition table of $devname." + partprobe $devname + elif [ -e $IMAGE_PATH/$imagename/$basefn.gpt ]; then + if sgdisk -Z $devname >/dev/null 2>&1 ; then + inform "Partition table of $devname cleared." "2" + log "Partition table of $devname cleared." + else + inform "ERROR: Partition table of $devname could not be cleared." + log "ERROR: Partition table of $devname could not be cleared." + FAIL=1 + local retval=1 + fi + if sgdisk -gl $IMAGE_PATH/$imagename/$basefn.gpt $devname ; then + inform "$operation of GPT partition table of $devname successful." "2" + log "$operation of GPT partition table of $devname successful." + else + partprobe $devname + if ! sgdisk -gl $IMAGE_PATH/$imagename/$basefn.gpt $devname ; then + inform "ERROR: $operation of GPT partition table of $devname failed." + log "ERROR: $operation of GPT partition table of $devname failed." + FAIL=1 + local retval=1 + else + inform "$operation of GPT partition table of $devname successful." "2" + log "$operation of GPT partition table of $devname successful." + fi + fi + inform "Re-reading partition table of $devname." "2" + log "Re-reading partition table of $devname." + partprobe $devname + else + inform "ERROR: Could not determine partition table type of the backup." + log "ERROR: Could not determine partition table type of the backup." + FAIL=1 + local retval=1 + fi + fi + sync + return $retval +} + +function partbackup() { + # Back up a partition + # Takes two arguments. First is the full path device name. Second + # is the id (value in seldevs) + local retval=0 + local devname=$1 + local id=$2 + + # Determine effective backup method + if [[ $bu_method = "auto" ]]; then + eff_bu_method="${devbm[$devname]}" + else + eff_bu_method="$bu_method" + fi + + # Determine filename + local basefn=`echo $devname|rev|cut -d/ -f1|rev` + + # Save partition size info + partsize=`blockdev --getsize64 $devname` + if echo $partsize > $IMAGE_PATH/$imagename/$basefn.sz ; then + inform "partition size info for $devname saved." "2" + log "partition size info for $devname saved." + else + inform "ERROR: partition size info for $devname could not be saved." "2" + log "ERROR: partition size info for $devname could not be saved." + FAIL=1 + local retval=1 + fi + + # Save id of device + if echo $id > $IMAGE_PATH/$imagename/$basefn.id ; then + inform "filesystem/partition type of $devname saved." "2" + log "filesystem/partition type of $devname saved." + else + inform "ERROR: filesystem/partition type of $devname could not be saved." + log "ERROR: filesystem/partition type of $devname could not be saved." + FAIL=1 + local retval=1 + fi + + if [[ $eff_bu_method = "dd" ]]; then + # If this is a dd backup, dd the drive + inform "$eff_bu_method backup of $devname started..." "2" + if monitor "dd if=$devname conv=sync,noerror|pv -s $partsize|$ddb_comp|split --bytes=2000m --suffix-length=3 --numeric-suffixes - $IMAGE_PATH/$imagename/$basefn.dd." "pausable" ; then + inform "$eff_bu_method backup of $devname succeeded." "2" + log "$eff_bu_method backup of $devname succeeded." + else + inform "ERROR: $eff_bu_method backup of $devname failed." + log "ERROR: $eff_bu_method backup of $devname failed." + FAIL=1 + local retval=1 + fi + elif [[ $eff_bu_method = "partimage" || $eff_bu_method = "fsarchiver" ]]; then + if echo "$devname"|grep -q -o -e "c[0-9]+d[0-9]+p[0-9]+|nvme[0-9]+n[0-9]+p[0-9]+" ; then + local drive=`echo $devname|rev|cut -c3-|rev` + else + local drive=`echo $devname|rev|cut -c2-|rev` + fi + if fdisk -l $drive|grep $devname|grep -q "Linux swap"; then + # partition is a swap partition + if `file -s $devname |grep -q swap` ; then + inform "Recognized $devname as Linux swap partition." + log "Recognized $devname as Linux swap partition." + swptxt=`blkid $devname` + else + inform "Warning: $devname has a partition type of Linux swap, but is not" + inform "formatted as swap." + log "Warning: $devname has a partition type of Linux swap, but is not" + log "formatted as swap." + swptxt="swap" + fi + if [[ $eff_bu_method = "partimage" ]]; then suffix="img.000";fi + if [[ $eff_bu_method = "fsarchiver" ]]; then suffix="fsa";fi + if echo $swptxt >$IMAGE_PATH/$imagename/$basefn.$suffix ; then + if echo $swptxt|grep -q UUID ; then + inform "swap partition UUID for $devname saved." "2" + log "swap partition UUID for $devname saved." + else + inform "unformatted swap partition $devname saved." "2" + log "unformatted swap partition $devname saved." + fi + else + inform "ERROR: swap partition $devname could not be saved." + log "ERROR: swap partition $devname could not be saved." + FAIL=1 + local retval=1 + fi + else + if [[ $eff_bu_method = "partimage" ]]; then + inform "$eff_bu_method backup of $devname started..." "2" + if monitor "partimage $pi_comp $PI_BACKUP_ARGS $devname $IMAGE_PATH/$imagename/$basefn.img" "pausable" ; then + inform "$eff_bu_method backup of $devname succeeded." "2" + log "$eff_bu_method backup of $devname succeeded." + else + inform "ERROR: partimage backup of $devname failed." + log "ERROR: partimage backup of $devname failed." + FAIL=1 + local retval=1 + fi + fi + if [[ $eff_bu_method = "fsarchiver" ]]; then + inform "$eff_bu_method backup of $devname started..." "2" + if monitor "fsarchiver $FA_BACKUP_ARGS $fa_comp $IMAGE_PATH/$imagename/$basefn.fsa $devname" "pausable" ; then + inform "$eff_bu_method backup of $devname succeeded." "2" + log "$eff_bu_method backup of $devname succeeded." + else + inform "ERROR: fsarchiver backup of $devname failed." + log "ERROR: fsarchiver backup of $devname failed." + FAIL=1 + local retval=1 + fi + fi + fi + fi + sync + return $retval +} + +function partrestore() { + # Restore a partition + # Takes two arguments. First is the full path image name. + # Second is the backup method used + local retval=0 + local devname=$1 + local eff_bu_method=$2 + local basefn=`echo $devname|rev|cut -d/ -f1|rev` + if [[ $eff_bu_method = "dd" ]]; then + # If this was a dd backup, determine the compression level used + if file $IMAGE_PATH/$imagename/$basefn.dd.000|grep -q bzip2; then + bu_comp="high" + elif file $IMAGE_PATH/$imagename/$basefn.dd.000|grep -q gzip; then + bu_comp="normal" + else + bu_comp="low" + fi + setcomplevel + # dd the image + log "$eff_bu_method restore of $devname started..." + inform "$eff_bu_method restore of $devname started..." "2" + if imgsize=`cat $IMAGE_PATH/$imagename/$basefn.sz` ; then + progress_cmd="pv -s $imgsize" + else + progress_cmd="pv -prb" + fi + if monitor "cat $IMAGE_PATH/$imagename/$basefn.dd.*|$ddr_comp|$progress_cmd|dd of=$devname" "nopause" ; then + inform "$eff_bu_method restore of $devname succeeded." "2" + log "$eff_bu_method restore of $devname succeeded." + else + inform "ERROR: $eff_bu_method $operation of $devname failed." + log "ERROR: $eff_bu_method $operation of $devname failed." + FAIL=1 + local retval=1 + fi + elif [[ $eff_bu_method = "partimage" || $eff_bu_method = "fsarchiver" ]]; then + log "$eff_bu_method restore of $devname started..." + inform "$eff_bu_method restore of $devname started..." "2" + if [[ $eff_bu_method = "partimage" ]]; then + suffix="img.000" + fi + if [[ $eff_bu_method = "fsarchiver" ]]; then + suffix="fsa" + fi + + # Detect swap partition and create appropriately + if file $IMAGE_PATH/$imagename/$basefn.$suffix|grep -q "ASCII text"&&grep -q swap $IMAGE_PATH/$imagename/$basefn.$suffix; then + if grep -q UUID $IMAGE_PATH/$imagename/$basefn.$suffix; then + log "$devname is a Linux swap partition with saved UUID. Running mkswap and setting UUID." + inform "$devname is a Linux swap partition with saved UUID. Running mkswap and setting UUID." "2" + if mkswap -U "$(cat $IMAGE_PATH/$imagename/$basefn.$suffix|grep -o -E ' UUID="[^ ]+"'|cut -d'"' -f2)" $devname ; then + log "Created Linux swap partition with saved UUID on $devname" + inform "Created Linux swap partition with saved UUID on $devname" "2" + else + log "ERROR: Could not create Linux swap partition with saved UUID on $devname" + inform "ERROR: Could not create Linux swap partition with saved UUID on $devname" + FAIL=1 + local retval=1 + fi + else + log "$devname is a Linux swap partition without saved UUID. Running mkswap." + inform "$devname is a Linux swap partition without saved UUID. Running mkswap." "2" + if mkswap $devname ; then + log "Created Linux swap partition with new UUID on $devname" + inform "Created Linux swap partition with new UUID on $devname" "2" + else + log "ERROR: Could not create Linux swap partition on $devname" + inform "ERROR: Could not create Linux swap partition on $devname" + FAIL=1 + local retval=1 + fi + fi + else + # For non-swap partitions, run the appropriate restore command + case "$eff_bu_method" in + "partimage" ) + if monitor "partimage $PI_RESTORE_ARGS $devname $IMAGE_PATH/$imagename/$basefn.img.000" "nopause" ; then + inform "$eff_bu_method restore of $devname succeeded." "2" + log "$eff_bu_method restore of $devname succeeded." + else + inform "ERROR: $eff_bu_method $operation of $devname failed." + log "ERROR: $eff_bu_method $operation of $devname failed." + FAIL=1 + local retval=1 + fi + ;; + "fsarchiver" ) + if monitor "fsarchiver $FA_RESTORE_ARGS $IMAGE_PATH/$imagename/$basefn.fsa id=0,dest=$devname" "nopause" ; then + inform "$eff_bu_method restore of $devname succeeded." "2" + log "$eff_bu_method restore of $devname succeeded." + else + inform "ERROR: $eff_bu_method $operation of $devname failed." + log "ERROR: $eff_bu_method $operation of $devname failed." + FAIL=1 + local retval=1 + fi + ;; + esac + fi + fi + sync + return $retval +} + +function method_analyze() { + # Analyzes devices in seldevs array to determine best backup method + # Populates the devbm associative array. Keys are device pathnames. + # Values are the backup methods. + # Examine selected devices + for adev in ${!seldevs[@]} ; do + if echo $adev|egrep -q -o -e "/dev/sd[a-z]$|/dev/cciss/c[0-9]d[0-9]$|/dev/i2o/hd[a-z]$|/dev/nvme[0-9]n[0-9]$" ; then + # device is a drive + if fdisk -l $adev |grep -q "Disklabel type:" ; then + # not really partimage, but will get the MBR or the GPT info, which will work. + devbm[$adev]="partimage" + else + # no partition table that we can see. Have to dd it. + devbm[$adev]="dd" + fi + fi + if echo $adev|egrep -q -o -e "sd[a-z][1-9]$|c[0-9]d[0-9]p[0-9]$|hd[a-z][1-9]$|nvme[0-9]n[0-9]p[0-9]" ; then + # device is a partition + case ${seldevs[$adev]} in + "ext4 filesystem" | \ + "reiser4 filesystem" | \ + "btrfs filesystem" \ + ) + devbm[$adev]="fsarchiver" + ;; + + "vfat filesystem" | \ + "hpfs filesystem" | \ + "ufs filesystem" | \ + "hfs filesystem" \ + ) + devbm[$adev]="partimage" + ;; + + "ext2 filesystem" | \ + "ext3 filesystem" | \ + "reiserfs filesystem" | \ + "jfs filesystem" | \ + "xfs filesystem" | \ + "swap partition" | \ + "ntfs filesystem" \ + ) + devbm[$adev]="partimage" + ;; + + * ) + devbm[$adev]="dd" + ;; + esac + fi + done + return 0 +} + +# -------------- DISK UTILITY FUNCTIONS --------------- +function diskutil() { + dutemp=`mktemp -q` + while true; do + flush_input + dialog --no-cancel \ + --title "DISK UTILITIES" \ + --menu "Please enter choice:" 13 50 6 \ + "1" "Clone disk" \ + "2" "Blank disk" \ + "3" "Test disk for bad blocks" \ + "4" "Set up backup media" \ + "?" "Disk utility help" \ + "M" "Return to main menu" 2> $dutemp + utilchoice=`cat $dutemp` + rm -f $dutemp + case $utilchoice in + "M" ) + return 0 + ;; + + "?" ) + if [ -r "$HELP_PATH/diskutil.txt" ]; then + dialog --title "RescueBRU Help - Disk utilities" --no-shadow --textbox $HELP_PATH/diskutil.txt 25 80 + else + pause "Help file $HELP_PATH/diskutil.txt could not be found. Check your installation." + fi + ;; + + 4 ) + media_reqd=1 + if media "mount" ; then + mediasetup + media "unmount" + else + pause "Could not mount backup media. Unable to perform media setup." + fi + ;; + + 3 ) + unset media_reqd + do_badblocks + ;; + + 2 ) + unset media_reqd + do_blank + ;; + + 1 ) + unset media_reqd + do_clone + ;; + esac + done +} + +function do_clone() { + operation="clone" + operation_log "on" + for key in ${!blockdevs[@]}; do unset blockdevs[$key]; done + for key in ${!seldevs[@]}; do unset seldevs[$key]; done + + # Select source/destination drives + if ! clone_select ; then + pause "Unable to select source and destination drives for clone." + log "Unable to select source and destination drives for clone." + operation_log "off" + return 1 + fi + # Warn if target is smaller than source + if [ $(blockdev --getsize64 $targetdev) -lt $(blockdev --getsize64 $sourcedev) ]; then + if ! approved "The target device is smaller than the source device. All data will not fit. Continue?" "n" ; then + return 1 + fi + fi + if confirm_actions ; then + # Clone the drive + if ! clone.sh $sourcedev $targetdev ; then + pause "Clone failed." + log "Clone failed." + operation_log "off" + return 1 + else + inform "clone completed." "2" + log "clone completed." + # reread target device partition table + if echo "$targetdev"|egrep -q -o -e "sd[a-z][1-9]$|c[0-9]d[0-9]p[0-9]$|hd[a-z][1-9]$|nvme[0-9]n[0-9]p[0-9]$" ; then + if echo "$targetdev"|grep -q -o -e "c[0-9]+d[0-9]+p[0-9]+|nvme[0-9]+n[0-9]+p[0-9]+" ; then + local drive=`echo $targetdev|rev|cut -c3-|rev` + else + local drive=`echo $targetdev|rev|cut -c2-|rev` + fi + else + local drive="$targetdev" + fi + inform "Re-reading partition table of $drive..." + log "Re-reading partition table of $drive" + partprobe $drivebackup + inform "Re-reading partition table of $drive...done." + case $postaction in + "Return to menu" ) + operation_log "off" + return 0 + ;; + + "Reboot" ) + log "Clone completed. Starting automatic reboot..." + if ! shutdown_proc "reboot" ; then + inform "Reboot aborted." "2" + log "Reboot aborted." + operation_log "off" + return 0 + fi + ;; + + "Shut down" ) + log "Clone completed. Starting automatic shutdown..." + if ! shutdown_proc "shutdown" ; then + inform "Shutdown aborted." "2" + log "Shutdown aborted." + operation_log "off" + return 0 + fi + ;; + esac + fi + else + inform "Operation aborted." "2" + log "Operation aborted." + operation_log "off" + flush_input + pause "Press any key to return to the disk utilities menu." + return 0 + fi +} + +function do_blank() { + operation="blank" + operation_log "on" + for key in ${!blockdevs[@]}; do unset blockdevs[$key]; done + for key in ${!seldevs[@]}; do unset seldevs[$key]; done + + # Select target drive + if ! blank_select ; then + inform "Unable to select target drive for blanking." "2" + log "Unable to select target drive for blanking." + flush_input + pause "Press any key to return to the disk utilities menu." + operation_log "off" + return 1 + fi + + if confirm_actions ; then + # Blank the drive + blank.sh $targetdev + inform "blanking completed." + log "blanking completed." + # reread target device partition table + if echo "$targetdev"|egrep -q -o -e "sd[a-z][1-9]$|c[0-9]d[0-9]p[0-9]$|hd[a-z][1-9]$|nvme[0-9]n[0-9]p[0-9]$" ; then + if echo "$targetdev"|grep -q -o -e "c[0-9]+d[0-9]+p[0-9]+|nvme[0-9]+n[0-9]+p[0-9]+" ; then + local drive=`echo $targetdev|rev|cut -c3-|rev` + else + local drive=`echo $targetdev|rev|cut -c2-|rev` + fi + else + local drive="$targetdev" + fi + inform "Re-reading partition table of $drive..." + log "Re-reading partition table of $drive" + partprobe $drivebackup + inform "Re-reading partition table of $drive...done." + case $postaction in + "Return to menu" ) + operation_log "off" + return 0 + ;; + + "Reboot" ) + log "Blanking completed. Starting automatic reboot..." + if ! shutdown_proc "reboot" ; then + inform "Reboot aborted." + log "Reboot aborted." + operation_log "off" + return 0 + fi + ;; + + "Shut down" ) + log "Blanking completed. Starting automatic shutdown..." + if ! shutdown_proc "shutdown" ; then + inform "Shutdown aborted." + log "Shutdown aborted." + operation_log "off" + return 0 + fi + ;; + esac + else + inform "Operation aborted." + log "Operation aborted." + operation_log "off" + flush_input + pause "Press any key to return to the disk utilities menu." + return 0 + fi +} + +function do_badblocks() { + operation="badblocks test" + operation_log "on" + for key in ${!blockdevs[@]}; do unset blockdevs[$key]; done + for key in ${!seldevs[@]}; do unset seldevs[$key]; done + + # Select target drive + if ! badblocks_select ; then + inform "Unable to select target drive for badblocks testing." "2" + log "Unable to select target drive for badblocks testing." + flush_input + pause "Press any key to return to the disk utilities menu." + operation_log "off" + return 1 + fi + + # Select read-write option + if ! rwoptselect ; then + inform "Unable to select read-write option for badblocks testing." "2" + log "Unable to select read-write option for badblocks testing." + flush_input + pause "Press any key to return to the disk utilities menu." + operation_log "off" + return 1 + fi + + if confirm_actions ; then + # test the drive + if ! monitor "badblocks $badblocks_args $targetdev" "pausable" ; then + pause "badblocks test failed." + log "badblocks test failed." + operation_log "off" + return 1 + else + inform "badblocks test passed." + log "badblocks test passed." + case $postaction in + "Return to menu" ) + operation_log "off" + return 0 + ;; + + "Reboot" ) + log "Badblocks test finished. Starting automatic reboot..." + if ! shutdown_proc "reboot" ; then + inform "Reboot aborted." + log "Reboot aborted." + operation_log "off" + return 0 + fi + ;; + + "Shut down" ) + log "Badblocks test finished. Starting automatic shutdown..." + if ! shutdown_proc "shutdown" ; then + inform "Shutdown aborted." + log "Shutdown aborted." + operation_log "off" + return 0 + fi + ;; + esac + fi + else + inform "Operation aborted." + log "Operation aborted." + operation_log "off" + flush_input + pause "Press any key to return to the disk utilities menu." + return 0 + fi + return 0 +} + +function clone_select() { + # Select source and destination devices for clone + unset sourcedev + unset targetdev + for key in ${!blockdevs[@]}; do unset blockdevs[$key]; done + + if ! getblkdevs ; then + pause "Couldn't get disk information." + log "Couldn't get disk information." + return 1 + fi + + # Display a menu of devices for source + for key in ${!seldevs[@]}; do unset seldevs[$key]; done + if deviceselect "single" "Select SOURCE device for clone" ; then + sourcedev="${!seldevs[@]}" + else + pause "Couldn't determine source device." + log "Couldn't determine source device." + return 1 + fi + + # Exclude the source device from the target device list + if ! exclude_dev "$sourcedev" ; then + pause "Unable to exclude source device from target device list." + return 1 + fi + + # Display menu of devices for target + for key in ${!seldevs[@]}; do unset seldevs[$key]; done + if deviceselect "single" "Select TARGET device for clone" ; then + targetdev="${!seldevs[@]}" + else + pause "Couldn't determine target device." + log "Couldn't determine target device." + return 1 + fi + + # Warn if target drive is smaller than source device + # if the target is a partition, get drive name + if echo "$targetdev"|egrep -q -o -e "sd[a-z][1-9]$|c[0-9]d[0-9]p[0-9]$|hd[a-z][1-9]$|nvme[0-9]n[0-9]p[0-9]$" ; then + if echo "$targetdev"|grep -q -o -e "c[0-9]+d[0-9]+p[0-9]+|nvme[0-9]+n[0-9]+p[0-9]+" ; then + local targetdrive=`echo $targetdev|rev|cut -c3-|rev` + else + local targetdrive=`echo $targetdev|rev|cut -c2-|rev` + fi + else + local targetdrive="$targetdev" + fi + sourcesize=`blockdev --getsize64 $sourcedev 2>/dev/null` + targetsize=`blockdev --getsize64 $targetdrive 2>/dev/null` + if [ $targetsize -lt $sourcesize ]; then + if ! approved "The source device appears to be larger than the target drive. + The data will probably not fit and the clone process will report failure. + Proceed anyway?" "n"; then + inform "Clone device selection aborted." + log "Clone device selection aborted." + unset sourcedev + unset targetdev + rm -f $LOG_PATH/clone*.log + return 1 + fi + fi + return 0 +} + +function blank_select() { + # Select target device for blanking + unset targetdev + for key in ${!blockdevs[@]}; do unset blockdevs[$key]; done + + if ! getblkdevs ; then + pause "Couldn't get disk information." + log "Couldn't get disk information." + return 1 + fi + + # Display menu of devices for target + for key in ${!seldevs[@]}; do unset seldevs[$key]; done + if deviceselect "single" "Select device to blank" ; then + targetdev="${!seldevs[@]}" + else + pause "Couldn't determine target device." + log "Couldn't determine target device." + return 1 + fi + return 0 +} + +function badblocks_select() { + # Select target drive for testing + unset targetdev + for key in ${!blockdevs[@]}; do unset blockdevs[$key]; done + if ! getblkdevs ; then + pause "Couldn't get disk information." + log "Couldn't get disk information." + return 1 + fi + + # Display menu of devices for target + for key in ${!seldevs[@]}; do unset seldevs[$key]; done + if deviceselect "single" "Select device to test" ; then + targetdev="${!seldevs[@]}" + else + pause "Couldn't determine target device." + log "Couldn't determine target device." + return 1 + fi + return 0 +} + +function rwoptselect() { + # For badblocks test, select a read-only or write test + rwtmp=`mktemp -q` + if dialog --no-items --radiolist "Select type of badblocks test" 12 40 12 \ + "read-only" "on" "write" "off" 2>$rwtmp ; then + rwopt=`cat $rwtmp` + case $rwopt in + "read-only" ) badblocks_args="-vs" ;; + "write" ) badblocks_args="-vws" ;; + esac + else + pause "badblocks test type selection cancelled." + log "badblocks test type selection cancelled." + rm -f $rwtmp + return 1 + fi + rm -f $rwtmp + return 0 +} + + +# ------------ DEVICE FUNCTIONS ------------------ + +function getblkdevs() { + # Populate associative array, blockdevs, of block devices. + # Array keys will be absolute paths of devices. + # Array values will be smartctl reported Device model or "disk" + # for drive, "extpart" for an extended partition, + # " filesystem" for a primary or logical partition + # containing a filesystem, "swap partition" + # for swap, or "unknown partition" if it couldn't be determined. + for blkdev in `ls /dev/sd* /dev/cciss/c*d* /dev/i2o/hd* /dev/nvme*n* 2>/dev/null` ; do + if echo $blkdev|egrep -q -o -e "/dev/sd[a-z]$|/dev/cciss/c[0-9]d[0-9]$|/dev/i2o/hd[a-z]$|/dev/nvme[0-9]n[0-9]$" ; then + # it's a drive + id=`smartctl -i $blkdev|egrep -e "Device:|Device Model:"|head -1|cut -d: -f2|xargs` + if [[ $id = "" ]]; then id="disk"; fi + blockdevs[$blkdev]="$id" + else + # it's a partition. determine its filesystem + pdrive=`echo $blkdev|egrep -o -e "/dev/sd[a-z]|/dev/cciss/c[0-9]d[0-9]|/dev/i2o/hd[a-z]|/dev/nvme[0-9]n[0-9]"` + if fdisk -l $pdrive|grep $blkdev|egrep -q -e "Extended|W95 Ext|Linux extended" ; then + blockdevs[$blkdev]="extpart" + else + local fstype=`blkid $blkdev |egrep -o -e ' TYPE="[a-zA-Z0-9]*"'|cut -d"\"" -f2` + if [[ $fstype = "swap" ]]; then + blockdevs[$blkdev]="swap partition" + elif [[ $fstype = "" ]]; then + blockdevs[$blkdev]="unknown partition" + else + blockdevs[$blkdev]="$fstype filesystem" + fi + fi + fi + done + if [ $(echo ${#blockdevs[@]}) -eq 0 ]; then + pause "No block devices found!" + return 1 + else + return 0 + fi +} + +function deviceselect() { + # Prompt for block devices on which to perform an operation + # Parses the blockdevs array, removes excluded devices, + # presents a checklist of drives on which to operate. + # Takes two arguments. First, the string "single" or "multiple" that + # controls whether a radiolist or checklist is displayed. Second, + # the prompt string to be displayed. + # Populates an associative array, seldevs. The keys are the absolute + # paths of block devices, and the values are the partition types taken + # from the blockdevs array + + for key in ${!seldevs[@]}; do unset seldevs[$key]; done + for key in ${!devbm[@]}; do unset devbm[$key]; done + if [ $# -ne 2 ]; then + pause "$FUNCNAME : $LINENO :Not enough arguments." + return 1 + fi + if [ "$1" = "single" ]; then + listtype="--radiolist" + elif [ "$1" = "multiple" ]; then + listtype="--checklist" + else + pause "$FUNCNAME : $LINENO :Must specify \"single\" or \"multiple\"." + return 1 + fi + prompttext=$2 + # Generate a list of devices for the list dialog + local listitems=( ) + tagtmp=`mktemp -q` + for dev in `echo ${!blockdevs[@]}|tr " " "\n"|sort|tr "\n" " "` ; do + if [[ ${blockdevs[$dev]} = "extpart" ]]; then + exclude_dev $dev;log "excluded $dev (extended partition)" + fi + if not_excluded $dev ; then listitems+=( "$dev" "${blockdevs[$dev]}" "off" ) ; fi + done + # Select devices + flush_input + while [ ! $finished ] ; do + if ! dialog $listtype "$prompttext" 20 60 20 "${listitems[@]}" 2>$tagtmp ; then + dialog --sleep 3 --aspect 80 --infobox "Device selection canceled." 0 0 + rm -f $tagtmp + return 1 + fi + for devname in `cat $tagtmp` ; do + seldevs[$devname]="${blockdevs[$devname]}" + done + local finished=1 + if [ ${#seldevs[@]} -eq 0 ]; then + pause "You didn't select any devices. If this was your intent, press enter to return to the selection list and select Cancel." + unset finished + fi + done + rm -f $tagtmp + return 0 +} + +function getimages() { + # Populate an associative array, images, with backup images. + # Array keys will be absolute path block device names. + # Values will be backup method. + # Populate an associative array, imgid, with with + # disk id/filesystem type. + # Array keys will be absolute path block device names. + # Values will be disk id/filesystem type. + # standard /dev/sdx images + for img in `ls $IMAGE_PATH/$imagename/sd* 2>/dev/null` ; do + if `echo $img|egrep -q -o -e "sd[a-z].mbr|sd[a-z].gpt"` ; then + # MBR or GPT treated as partimage + baseimgname=`echo $img|egrep -o -e 'sd[a-z].mbr|sd[a-z].gpt'|cut -d "." -f1` + imgkey="/dev/$baseimgname" + images[$imgkey]="partimage" + if [ -e $IMAGE_PATH/$imagename/$baseimgname.id ]; then + imgid[$imgkey]=`cat $IMAGE_PATH/$imagename/$baseimgname.id` + else + imgid[$imgkey]="MBR" + fi + elif `echo $img|egrep -q -o -e "sd[a-z][0-9]+.img.000"` ; then + # partimage partition + baseimgname=`echo $img|egrep -o -e 'sd[a-z][0-9]+.img.000'|cut -d "." -f1` + imgkey="/dev/$baseimgname" + images[$imgkey]="partimage" + if [ -e "$IMAGE_PATH/$imagename/$baseimgname.id" ]; then + imgid[$imgkey]=`cat $IMAGE_PATH/$imagename/$baseimgname.id` + else + imgid[$imgkey]="partition" + fi + elif `echo $img|egrep -q -o -e "sd[a-z][0-9]+.fsa"` ; then + # fsarchiver partition + baseimgname=`echo $img|egrep -o -e 'sd[a-z][0-9]+.fsa'|cut -d "." -f1` + imgkey="/dev/$baseimgname" + images[$imgkey]="fsarchiver" + if [ -e "$IMAGE_PATH/$imagename/$baseimgname.id" ]; then + imgid[$imgkey]=`cat $IMAGE_PATH/$imagename/$baseimgname.id` + else + imgid[$imgkey]="partition" + fi + elif `echo $img|egrep -q -o -e "sd[a-z][0-9]+.dd.000"` ; then + # dd partition + baseimgname=`echo $img|egrep -o -e 'sd[a-z][0-9]+.dd.000'|cut -d "." -f1` + imgkey="/dev/$baseimgname" + images[$imgkey]="dd" + if [ -e "$IMAGE_PATH/$imagename/$baseimgname.id" ]; then + imgid[$imgkey]=`cat $IMAGE_PATH/$imagename/$baseimgname.id` + else + imgid[$imgkey]="partition image" + fi + elif `echo $img|egrep -q -o -e "sd[a-z].dd.000"` ; then + # dd disk + baseimgname=`echo $img|egrep -o -e 'sd[a-z].dd.000'|cut -d "." -f1` + imgkey="/dev/$baseimgname" + images[$imgkey]="dd" + if [ -e "$IMAGE_PATH/$imagename/$baseimgname.id" ]; then + imgid[$imgkey]=`cat $IMAGE_PATH/$imagename/$baseimgname.id` + else + imgid[$imgkey]="disk image" + fi + fi + done + # HP CISS images + for img in `ls $IMAGE_PATH/$imagename/c*d* 2>/dev/null` ; do + if `echo $img|egrep -q -o -e "c[0-9]+d[0-9]+.mbr"` ; then + # MBR treated as partimage + baseimgname=`echo $img|egrep -o -e 'c[0-9]+d[0-9]+.mbr'|cut -d "." -f1` + imgkey="/dev/cciss/$baseimgname" + images[$imgkey]="partimage" + if [ -e "$IMAGE_PATH/$imagename/$baseimgname.id" ]; then + imgid[$imgkey]=`cat $IMAGE_PATH/$imagename/$baseimgname.id` + else + imgid[$imgkey]="MBR" + fi + elif `echo $img|egrep -q -o -e "c[0-9]+d[0-9]+p[0-9]+.img.000"` ; then + # partimage partition + baseimgname=`echo $img|egrep -o -e 'c[0-9]+d[0-9]+p[0-9]+.img.000'|cut -d "." -f1` + imgkey="/dev/cciss/$baseimgname" + images[$imgkey]="partimage" + if [ -e "$IMAGE_PATH/$imagename/$baseimgname.id" ]; then + imgid[$imgkey]=`cat $IMAGE_PATH/$imagename/$baseimgname.id` + else + imgid[$imgkey]="partition" + fi + elif `echo $img|egrep -q -o -e "c[0-9]+d[0-9]+p[0-9]+.fsa"` ; then + # fsarchiver partition + baseimgname=`echo $img|egrep -o -e 'c[0-9]+d[0-9]+p[0-9]+.fsa'|cut -d "." -f1` + imgkey="/dev/cciss/$baseimgname" + images[$imgkey]="fsarchiver" + if [ -e "$IMAGE_PATH/$imagename/$baseimgname.id" ]; then + imgid[$imgkey]=`cat $IMAGE_PATH/$imagename/$baseimgname.id` + else + imgid[$imgkey]="partition" + fi + elif `echo $img|egrep -q -o -e "c[0-9]+d[0-9]+p[0-9]+.dd.000"` ; then + # dd partition + baseimgname=`echo $img|egrep -o -e 'c[0-9]+d[0-9]+p[0-9]+.dd.000'|cut -d "." -f1` + imgkey="/dev/cciss/$baseimgname" + images[$imgkey]="dd" + if [ -e "$IMAGE_PATH/$imagename/$baseimgname.id" ]; then + imgid[$imgkey]=`cat $IMAGE_PATH/$imagename/$baseimgname.id` + else + imgid[$imgkey]="partition image" + fi + elif `echo $img|egrep -q -o -e "c[0-9]+d[0-9]+.dd.000"` ; then + # dd disk + baseimgname=`echo $img|egrep -o -e 'c[0-9]+d[0-9]+.dd.000'|cut -d "." -f1` + imgkey="/dev/cciss/$baseimgname" + images[$imgkey]="dd" + if [ -e "$IMAGE_PATH/$imagename/$baseimgname.id" ]; then + imgid[$imgkey]=`cat $IMAGE_PATH/$imagename/$baseimgname.id` + else + imgid[$imgkey]="disk image" + fi + fi + done + # Adaptec i2o images + for img in `ls $IMAGE_PATH/$imagename/hd* 2>/dev/null` ; do + if `echo $img|egrep -q -o -e "hd[a-z].mbr"` ; then + # MBR treated as partimage + baseimgname=`echo $img|egrep -o -e 'hd[a-z].mbr'|cut -d "." -f1` + imgkey="/dev/i2o/$baseimgname" + images[$imgkey]="partimage" + if [ -e "$IMAGE_PATH/$imagename/$baseimgname.id" ]; then + imgid[$imgkey]=`cat $IMAGE_PATH/$imagename/$baseimgname.id` + else + imgid[$imgkey]="MBR" + fi + elif `echo $img|egrep -q -o -e "hd[a-z][0-9]+.img.000"` ; then + # partimage partition + baseimgname=`echo $img|egrep -o -e 'hd[a-z][0-9]+.img.000'|cut -d "." -f1` + imgkey="/dev/i2o/$baseimgname" + images[$imgkey]="partimage" + if [ -e "$IMAGE_PATH/$imagename/$baseimgname.id" ]; then + imgid[$imgkey]=`cat $IMAGE_PATH/$imagename/$baseimgname.id` + else + imgid[$imgkey]="partition" + fi + elif `echo $img|egrep -q -o -e "hd[a-z][0-9]+.fsa"` ; then + # fsarchiver partition + baseimgname=`echo $img|egrep -o -e 'hd[a-z][0-9]+.fsa'|cut -d "." -f1` + imgkey="/dev/i2o/$baseimgname" + images[$imgkey]="fsarchiver" + if [ -e "$IMAGE_PATH/$imagename/$baseimgname.id" ]; then + imgid[$imgkey]=`cat $IMAGE_PATH/$imagename/$baseimgname.id` + else + imgid[$imgkey]="partition" + fi + elif `echo $img|egrep -q -o -e "hd[a-z][0-9]+.dd.000"` ; then + # dd partition + baseimgname=`echo $img|egrep -o -e 'hd[a-z][0-9]+.dd.000'|cut -d "." -f1` + imgkey="/dev/i2o/$baseimgname" + images[$imgkey]="dd" + if [ -e "$IMAGE_PATH/$imagename/$baseimgname.id" ]; then + imgid[$imgkey]=`cat $IMAGE_PATH/$imagename/$baseimgname.id` + else + imgid[$imgkey]="partition image" + fi + elif `echo $img|egrep -q -o -e "hd[a-z].dd.000"` ; then + # dd disk + baseimgname=`echo $img|egrep -o -e 'hd[a-z].dd.000'|cut -d "." -f1` + imgkey="/dev/i2o/$baseimgname" + images[$imgkey]="dd" + if [ -e "$IMAGE_PATH/$imagename/$baseimgname.id" ]; then + imgid[$imgkey]=`cat $IMAGE_PATH/$imagename/$baseimgname.id` + else + imgid[$imgkey]="disk image" + fi + fi + done + # NVMe images + for img in `ls $IMAGE_PATH/$imagename/nvme*n* 2>/dev/null` ; do + if `echo $img|egrep -q -o -e "nvme[0-9]+n[0-9]+.mbr|nvme[0-9]+n[0-9]+.gpt"` ; then + # MBR or GPT treated as partimage + baseimgname=`echo $img|egrep -o -e 'nvme[0-9]+n[0-9]+.mbr|nvme[0-9]+n[0-9]+.gpt'|cut -d "." -f1` + imgkey="/dev/$baseimgname" + images[$imgkey]="partimage" + if [ -e "$IMAGE_PATH/$imagename/$baseimgname.id" ]; then + imgid[$imgkey]=`cat $IMAGE_PATH/$imagename/$baseimgname.id` + else + imgid[$imgkey]="MBR" + fi + elif `echo $img|egrep -q -o -e "nvme[0-9]+n[0-9]+p[0-9]+.img.000"` ; then + # partimage partition + baseimgname=`echo $img|egrep -o -e 'nvme[0-9]+n[0-9]+p[0-9]+.img.000'|cut -d "." -f1` + imgkey="/dev/$baseimgname" + images[$imgkey]="partimage" + if [ -e "$IMAGE_PATH/$imagename/$baseimgname.id" ]; then + imgid[$imgkey]=`cat $IMAGE_PATH/$imagename/$baseimgname.id` + else + imgid[$imgkey]="partition" + fi + elif `echo $img|egrep -q -o -e "nvme[0-9]+n[0-9]+p[0-9]+.fsa"` ; then + # fsarchiver partition + baseimgname=`echo $img|egrep -o -e 'nvme[0-9]+n[0-9]+p[0-9]+.fsa'|cut -d "." -f1` + imgkey="/dev/$baseimgname" + images[$imgkey]="fsarchiver" + if [ -e "$IMAGE_PATH/$imagename/$baseimgname.id" ]; then + imgid[$imgkey]=`cat $IMAGE_PATH/$imagename/$baseimgname.id` + else + imgid[$imgkey]="partition" + fi + elif `echo $img|egrep -q -o -e "nvme[0-9]+n[0-9]+p[0-9]+.dd.000"` ; then + # dd partition + baseimgname=`echo $img|egrep -o -e 'nvme[0-9]+n[0-9]+p[0-9]+.dd.000'|cut -d "." -f1` + imgkey="/dev/$baseimgname" + images[$imgkey]="dd" + if [ -e "$IMAGE_PATH/$imagename/$baseimgname.id" ]; then + imgid[$imgkey]=`cat $IMAGE_PATH/$imagename/$baseimgname.id` + else + imgid[$imgkey]="partition image" + fi + elif `echo $img|egrep -q -o -e "nvme[0-9]+n[0-9]+.dd.000"` ; then + # dd disk + baseimgname=`echo $img|egrep -o -e 'nvme[0-9]+n[0-9]+.dd.000'|cut -d "." -f1` + imgkey="/dev/$baseimgname" + images[$imgkey]="dd" + if [ -e "$IMAGE_PATH/$imagename/$baseimgname.id" ]; then + imgid[$imgkey]=`cat $IMAGE_PATH/$imagename/$baseimgname.id` + else + imgid[$imgkey]="disk image" + fi + fi + done + if [[ ${#images[@]} -eq 0 ]]; then + return 1 + else + return 0 + fi +} + +function imageselect() { + # Select device images to be restored + # Parses the images array, presents a checklist of + # images to restore. Returns an associative array, selimages. + # Array keys are absolute path device names to restore. + # Values are the backup methods used + + for key in ${!selimages[@]}; do unset selimages[$key]; done + for key in ${!imgid[@]}; do unset imgid[$key]; done + # Generate a list of images for the checklist dialog + local listitems=( ) + tagtmp=`mktemp -q` + for img in `echo ${!images[@]}|tr " " "\n"|sort|tr "\n" " "` ; do + listitems+=( "$img" "${imgid[$img]}" "off" ) + done + # Select images + flush_input + while [ ! $finished ] ; do + if ! dialog --checklist "Select images to restore" 20 60 20 "${listitems[@]}" 2>$tagtmp ; then + dialog --sleep 3 --aspect 80 --infobox "Image selection canceled." 0 0 + rm -f $tagtmp + return 1 + fi + for imgname in `cat $tagtmp` ; do + selimages[$imgname]="${images[$imgname]}" + done + local finished=1 + if [ ${#selimages[@]} -eq 0 ]; then + pause "You didn't select any images. If this was your intent, press enter to return to the selection list and select Cancel." + unset finished + fi + done + rm -f $tagtmp + return 0 +} + +function exclude_dev() { + # add a device to the exclude array + # takes 1 parameter, a device pathname + exclude_list=( ${exclude_list[@]} $1 ) + return 0 +} + +function not_excluded() { + # Tests to see if a device is in the device exclude list. + # Takes one parameter, a device path + # Returns 0 if device is not in list or 1 if it is. + pathnm=$1 + for lst_mem in ${exclude_list[@]}; do + if [ "$pathnm" = "$lst_mem" ]; then + return 1 + fi + done + return 0 +} + + +# ------------- PROGRAM SETTING FUNCTIONS ------------ +function defaultsettings() { + + # Restore program settings to defaults + media_type=$MEDIA_TYPE_DEF + bu_method=$BU_METHOD_DEF + postaction=$POSTACTION_DEF + netsetup_type=$NETSETUP_TYPE + backup_server_type=$BACKUP_SERVER_TYPE + bu_comp=$BU_COMP_DEF + remote_dir=$NFS_REMOTE_DIR_DEF + +} + +function settings() { + + smtemp=`mktemp -q` + while true; do + flush_input + dialog --no-cancel \ + --title "RescueBRU Settings" \ + --menu "" 14 79 9 \ + "1" "Select backup media type (currently $media_type)" \ + "2" "Select backup method (currently $bu_method)" \ + "3" "Select backup compression level (currently $bu_comp)" \ + "4" "Set action after successful operation (currently $postaction)" \ + "5" "Select backup server type (currently $backup_server_type)" \ + "6" "Select network setup type (currently $netsetup_type)" \ + "7" "Set remote NFS share (currently $remote_dir)" \ + "R" "Reset all to defaults" \ + "M" "Return to main menu" 2> $smtemp + setch=`cat $smtemp` + rm -f $smtemp + case $setch in + "M" ) + + return 0 + ;; + + "R" ) + defaultsettings + ;; + + 7 ) + setremotedir + ;; + + 6 ) + netsetupselect + ;; + + 5 ) + servertypeselect + ;; + + 4 ) + setpostaction + ;; + + 3 ) + complvlselect + ;; + + 2 ) + methodselect + ;; + + 1 ) + mediaselect + ;; + esac + done +} + +function setremotedir() { + orig_remote_dir=$remote_dir + local rdir_invalid=1 + while [ $rdir_invalid ]; do + # Prompt for new remote directory name + rdnametmp=`mktemp -q` + if dialog --inputbox "Please enter remote NFS share name" \ + 8 50 "$remote_dir" 2>$rdnametmp ; then + remote_dir=`cat $rdnametmp` + if ! validate_text path $remote_dir; then + pause "Share name contains invalid characters. Valid characters are forward slash, upper and lowercase letters, numbers, underscore, and dash. Try again." 0 0 + elif [ "$remote_dir" = "" ]; then + pause "Share name cannot be blank. \nTry again." + elif [ "$imagename" = "lost+found" ]; then + pause "\"lost+found\" is not a valid share name. \nChoose another." + else + unset rdir_invalid + rm -f $rdnametmp + fi + else + inform "Share name entry aborted." + rm -f $rdnametmp + remote_dir=$orig_remote_dir + return 1 + fi + done + log "New NFS share name is $remote_dir" +} + +function complvlselect() { + # Set compression level for backups + clstemp=`mktemp -q` + while true ; do + if ! dialog --default-item "$bu_comp" --menu "Select compression level for backups (currently $bu_comp)" 12 40 8 \ + "L" "low" \ + "N" "normal" \ + "H" "high" \ + "?" "Compression level help" 2> $clstemp ; then + rm -f $clstemp + return 0 + else + buc=`cat $clstemp` + rm -f $clstemp + fi + case $buc in + "L" ) + bu_comp="low" + log "Backup compression level set to $bu_comp." + setcomplevel + return 0 + ;; + + "N" ) + bu_comp="normal" + log "Backup compression level set to $bu_comp." + setcomplevel + return 0 + ;; + + "H" ) + bu_comp="high" + log "Backup compression level set to $bu_comp." + setcomplevel + return 0 + ;; + + "?" ) + if [ -r "$HELP_PATH/bucomp.txt" ]; then + dialog --title "RescueBRU Help - Backup Compression" \ + --no-shadow --textbox $HELP_PATH/bucomp.txt 25 80 + else + pause "Help file $HELP_PATH/bucomp.txt could not be found. Check your installation." + fi + ;; + esac + done +} + +function setcomplevel() { + # Sets the compression level arguments appropriately for the + # different backup methods + case $bu_comp in + "low" ) + ddb_comp="cat" + ddr_comp="cat" + pi_comp="-z0" + fa_comp="-z1" + return 0 + ;; + + "normal" ) + ddb_comp="gzip -cq" + ddr_comp="gzip -dq" + pi_comp="-z1" + fa_comp="-z3" + return 0 + ;; + + "high" ) + ddb_comp="bzip2 -cq" + ddr_comp="bzip2 -dq" + pi_comp="-z2" + fa_comp="-z7" + return 0 + ;; + + * ) + ddb_comp="gzip -cq" + ddr_comp="gzip -dq" + pi_comp="-z1" + fa_comp="-z3" + return 0 + ;; + esac +} + +function netsetupselect() { + # Select the type of network setup + nsstemp=`mktemp -q` + if ! dialog --menu "Select network setup type (currently $netsetup_type)" 10 50 8 \ + "A" "auto" \ + "M" "manual" 2> $nsstemp ; then + rm -f $nsstemp + return 0 + else + nst=`cat $nsstemp` + rm -f $nsstemp + fi + case $nst in + "M" ) netsetup_type="manual" ;; + "A" ) netsetup_type="auto" ;; + esac + log "Net setup type set to $netsetup_type." +} + +function servertypeselect() { + # Select the type of backup server + bsttemp=`mktemp -q` + if ! dialog --menu "Select backup server type (currently $backup_server_type)" 10 50 8 \ + "R" "RescueBRU Server" \ + "A" "any DHCP server" 2> $bsttemp ; then + rm -f $bsttemp + return 0 + else + bst=`cat $bsttemp` + rm -f $bsttemp + fi + case $bst in + "R" ) backup_server_type="RescueBRU Server" ;; + "A" ) backup_server_type="any DHCP server" ;; + esac + log "Backup server type set to $backup_server_type." +} + +function setpostaction() { + # Set the action taken after successful operation + patemp=`mktemp -q` + if ! dialog --menu "Select action after successful operation (currently $postaction)" 11 73 8 \ + "M" "Return to menu" \ + "R" "Reboot" \ + "S" "Shutdown" 2> $patemp ; then + rm -f $patemp + return 0 + else + pa=`cat $patemp` + rm -f $patemp + fi + case $pa in + "M" ) postaction="Return to menu" ;; + "R" ) postaction="Reboot" ;; + "S" ) postaction="Shut Down" ;; + esac + log "Action after successful operation set to $postaction." +} + +function methodselect() { + # Prompt user to select backup method type + bmtemp=`mktemp -q` + while true ; do + if ! dialog --default-item "$bu_method" --menu "Select backup method (currently $bu_method)" 13 50 8 \ + "A" "auto" \ + "P" "partimage" \ + "F" "fsarchiver" \ + "D" "dd" \ + "?" "Backup method help" 2> $bmtemp ; then + rm -f $bmtemp + return 0 + else + bm=`cat $bmtemp` + rm -f $bmtemp + fi + case $bm in + "A" ) + bu_method="auto" + log "Backup method set to $bu_method." + return 0 + ;; + + "P" ) + bu_method="partimage" + log "Backup method set to $bu_method." + return 0 + ;; + + "F" ) + bu_method="fsarchiver" + log "Backup method set to $bu_method." + return 0 + ;; + + "D" ) + bu_method="dd" + log "Backup method set to $bu_method." + return 0 + ;; + + "?" ) + if [ -r "$HELP_PATH/method.txt" ]; then + dialog --title "RescueBRU Help - Backup method" \ + --no-shadow --textbox $HELP_PATH/method.txt 25 80 + else + pause "Help file $HELP_PATH/method.txt could not be found. Check your installation." + fi + ;; + esac + done +} + +function mediaselect() { + # Prompt user to select media type. + mttemp=`mktemp -q` + while true ; do + if ! dialog --default-item "$media_type" --menu "Select media type (currently $media_type)" 12 40 8 \ + "N" "NFS" \ + "U" "USB" \ + "L" "Local" \ + "?" "Media type help" 2> $mttemp ; then + rm -f $mttemp + return 0 + else + mt=`cat $mttemp` + rm -f $mttemp + fi + case $mt in + "N" ) + media_type="NFS" + log "Media type set to $media_type." + return 0 + ;; + + "U" ) + media_type="USB" + log "Media type set to $media_type." + return 0 + ;; + + "L" ) + media_type="Local" + log "Media type set to $media_type." + return 0 + ;; + + "?" ) + if [ -r "$HELP_PATH/mediatype.txt" ]; then + dialog --title "RescueBRU Help - Media type" \ + --no-shadow --textbox $HELP_PATH/mediatype.txt 25 80 + else + pause "Help file $HELP_PATH/mediatype.txt could not be found. Check your installation." + fi + ;; + esac + done +} + + +# ------------------ MENUS -------------------------- +function mainmenu() { + mmtemp=`mktemp -q` + if [ $LOCAL_SERVER_RUNNING ]; then + flush_input + dialog --clear --no-cancel \ + --title "RescueBRU Main Menu"\ + --menu "Welcome to Rescue CD Backup & Restore Utility + __ Version $PROG_VERSION __ + + Please enter choice:" 22 50 22 \ + "1" "Settings Menu" \ + "2" "Do a backup" \ + "3" "Do a restore" \ + "4" "Disk utilities" \ + "5" "Image management" \ + "6" "View logs or notes" \ + "7" "Show backups available on media" \ + "?" "Help" \ + "S" "Exit and return to rbruserver" 2> $mmtemp + else + flush_input + dialog --clear --no-cancel \ + --title "RescueBRU Main Menu"\ + --menu "Welcome to Rescue CD Backup & Restore Utility + __ Version $PROG_VERSION __ + + Please enter choice:" 22 50 22 \ + "1" "Settings Menu" \ + "2" "Do a backup" \ + "3" "Do a restore" \ + "4" "Disk utilities" \ + "5" "Image management" \ + "6" "View logs or notes" \ + "7" "Show backups available on media" \ + "?" "Help" \ + "S" "Exit to shell" \ + "R" "Exit and reboot" \ + "P" "Exit and power down" 2> $mmtemp + fi + mmchoice=`cat $mmtemp` + log "Option $mmchoice chosen from main menu." + rm -f $mmtemp + return 0 +} + +function showhelp() { + hmtemp=`mktemp -q` + while true; do + flush_input + dialog --clear --no-cancel \ + --title "HELP MENU"\ + --menu "Please enter choice:" 15 40 8 \ + "1" "General" \ + "2" "Doing a backup" \ + "3" "Restoring from a backup" \ + "4" "Backup media" \ + "5" "Backup method" \ + "6" "Media type" \ + "7" "Disk utilities" \ + "M" "Exit help menu" 2> $hmtemp + hmchoice=`cat $hmtemp` + rm -f $hmtemp + case $hmchoice in + "M" ) + return 0 + ;; + + 7 ) + if [ -r "$HELP_PATH/diskutil.txt" ]; then + dialog --title "RescueBRU Help - Disk utilities" \ + --no-shadow --textbox $HELP_PATH/diskutil.txt 25 80 + else + pause "Help file $HELP_PATH/diskutil.txt could not be found. Check your installation." + fi + ;; + + 6 ) + echo + if [ -r "$HELP_PATH/mediatype.txt" ]; then + dialog --title "RescueBRU Help - Media type" \ + --no-shadow --textbox $HELP_PATH/mediatype.txt 25 80 + else + pause "Help file $HELP_PATH/mediatype.txt could not be found. Check your installation." + fi + ;; + + 5 ) + echo + if [ -r "$HELP_PATH/method.txt" ]; then + dialog --title "RescueBRU Help - Backup method" \ + --no-shadow --textbox $HELP_PATH/method.txt 25 80 + else + pause "Help file $HELP_PATH/method.txt could not be found. Check your installation." + fi + ;; + + 4 ) + echo + if [ -r "$HELP_PATH/media.txt" ]; then + dialog --title "RescueBRU Help - Backup media" \ + --no-shadow --textbox $HELP_PATH/media.txt 25 80 + else + pause "Help file $HELP_PATH/media.txt could not be found. Check your installation." + fi + ;; + + 3 ) + echo + if [ -r "$HELP_PATH/restore.txt" ]; then + dialog --title "RescueBRU Help - Restoring from a backup" \ + --no-shadow --textbox $HELP_PATH/restore.txt 25 80 + else + pause "Help file $HELP_PATH/restore.txt could not be found. Check your installation." + fi + ;; + + 2 ) + echo + if [ -r "$HELP_PATH/backup.txt" ]; then + dialog --title "RescueBRU Help - Doing a backup" \ + --no-shadow --textbox $HELP_PATH/backup.txt 25 80 + else + pause "Help file $HELP_PATH/backup.txt could not be found. Check your installation." + fi + ;; + + 1 ) + echo + if [ -r "$HELP_PATH/general.txt" ]; then + dialog --title "RescueBRU Help - General" \ + --no-shadow --textbox $HELP_PATH/general.txt 25 80 + else + pause "Help file $HELP_PATH/general.txt could not be found. Check your installation." + fi + ;; + esac + done + return 0 +} + + +# ------------------ PROCESS FUNCTIONS --------------- + +function cleanup() { + # Perform cleanup functions prior to exit + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + mount $remote_addr:$remote_dir $MEDIA_MNT_DIR + rm -f $MEDIA_MNT_DIR/$wkg_addr + umount $MEDIA_MNT_DIR + /etc/init.d/nfsmount stop >/dev/null 2>&1 + ifconfig $interface 0.0.0.0 down + fi + return 0 +} + +function confirm_actions() { + # Display and confirm actions before an operation + unset devarray + declare -A devarray + while true ; do + local opsumtmp=`mktemp -q` + local conflisttmp=`mktemp -q` + local chgtmp=`mktemp -q` + local devtmp=`mktemp -q` + local notestmp=`mktemp -q` + + # Indexes for options: + # 0 - Operation + # 1 - Media type + # 2 - Backup method + # 3 - Compression level + # 4 - Image name + # 5 - Version + # 6 - Devices + # 7 - Source device + # 8 - Target device + # 9 - Type of test + # 10 - Action on success + # 11 - Notes + + # Define operation settings array + opsettings=( "Operation" "Media type" "Backup method" "Compression level" "Image name" "Version" "Devices" "Source device" "Target device" "Type of test" "Action on success" "Notes") + # Generate displayable list of devices from seldevs array + for key in ${!devarray[@]}; do unset devarray[$key]; done + echo "">$devtmp + if [ "$operation" = "backup" ]; then + for dev in ${!seldevs[@]} ; do + devarray[$dev]="${seldevs[$dev]}" + done + elif [ "$operation" = "restore" ]; then + for img in ${!selimages[@]} ; do + devarray[$img]="${imgid[$img]}" + done + fi + for dev in ${!devarray[@]} ; do + if echo $dev|egrep -q -o -e "/dev/sd[a-z]$|/dev/cciss/c[0-9]d[0-9]$|/dev/i2o/hd[a-z]$|nvme[0-9]n[0-9]$"; then + # it's a drive + echo " $dev ${devarray[$dev]}">>$devtmp + elif echo $dev|egrep -q -o -e "sd[a-z][1-9]$|c[0-9]d[0-9]p[0-9]$|hd[a-z][1-9]$|nvme[0-9]n[0-9]p[0-9]" ; then + # it's a partition + echo " $dev ${devarray[$dev]}">>$devtmp + fi + sort -k 1,1 $devtmp -o $devtmp + dispdevs=`cat $devtmp` + done + # Generate displayable notes from $TEMP_NOTES + if [ -s $TEMP_NOTES ]; then + echo "">$notestmp + cat $TEMP_NOTES>>$notestmp + opnotes=`cat $notestmp 2>/dev/null` + rm -f $notestmp + else + unset opnotes + fi + # Define variables that correspond to operation settings + opvars=( "$operation" "$media_type" "$bu_method" "$bu_comp" "$imagename" "$bu_version" "$dispdevs" "$sourcedev" "$targetdev" "$rwopt" "$postaction" "$opnotes") + # Define the appropriate settings for the operation + case $operation in + "backup" ) osindexes=( 0 1 2 3 4 5 6 10 11 );; + "restore" ) osindexes=( 0 1 4 6 10 11 );; + "blank" ) osindexes=( 0 8 10 );; + "clone" ) osindexes=( 0 7 8 10 );; + "badblocks test" ) osindexes=( 0 8 9 10 );; + esac + # Generate text for settings display and confirmation widgets + for index in ${osindexes[@]} ; do + log "${opsettings[$index]} : ${opvars[$index]}" + echo "${opsettings[$index]} : ${opvars[$index]}">>$opsumtmp + echo -n "\"$index\" \"${opsettings[$index]}\" \"off\" ">>$conflisttmp + done + # Only show the first 21 lines of the operations summary + sed -i -e '22,$d' $opsumtmp + # Display the widgets + local dialog_script=`mktemp -q` + echo "dialog --begin 0 0 --title \"Summary of Operations\" --no-collapse --no-ok --tailboxbg $opsumtmp 25 49 --and-widget --begin 0 50 --title \"Confirm Operations\" --no-collapse --defaultno --no-tags --checklist \"To proceed as shown, select OK.\nTo abort the operation, select CANCEL.\nTo make changes, check item(s) to change and select OK.\" 25 30 25 `cat $conflisttmp` 2>$chgtmp">$dialog_script + if ! bash $dialog_script ; then + # User selected CANCEL + if approved "Are you sure you want to cancel the $operation?" "n"; then + rm -f $opsumtmp $conflisttmp $chgtmp $devtmp $dialog_script $notestmp + return 1 + fi + elif [ ! -s $chgtmp ]; then + # User selected OK without requesting change + rm -f $opsumtmp $conflisttmp $chgtmp $devtmp $dialog_script $notestmp + return 0 + else + # User checked something to change and selected OK. + # Re-run the appropriate function(s) and reconfirm. + for index in `cat $chgtmp` ; do + case ${opsettings[$index]} in + "Operation" ) + if dialog --defaultno --yesno "Changing the operation will return you to the main menu. Proceed?" 6 50 ; then + return 1 + fi + ;; + "Media type" ) + media "unmount" + mediaselect + media "mount" + unset iname_confirmed + getimagename $operation + ;; + "Backup method" ) + methodselect + if [[ $bu_method = "auto" ]]; then + log "Determining backup method." + method_analyze + fi + ;; + "Compression level" ) + complvlselect + ;; + "Image name" ) + unset iname_confirmed + getimagename $operation + ;; + "Version" ) + get_version + ;; + "Devices" ) + case $operation in + "backup" ) deviceselect "multiple" "Select devices to back up" ;; + "restore" ) imageselect ;; + esac + if [[ $bu_method = "auto" ]]; then + log "Determining backup method." + method_analyze + fi + ;; + "Source device" ) + clone_select + ;; + "Target device" ) + case $operation in + "clone" ) clone_select ;; + "blank" ) blank_select ;; + "badblocks test" ) badblocks_select ;; + esac + ;; + "Type of test" ) + rwoptselect + ;; + "Action on success" ) + setpostaction + ;; + "Notes" ) + get_notes + ;; + esac + done + rm -f $opsumtmp $conflisttmp $chgtmp $devtmp $dialog_script $notestmp + fi + done +} + + +# ------------------ NETWORK FUNCTIONS ---------------- +function check_route() { + # Wait until a route is established. + # Takes two arguments, the remote ip address, and the number of attempts + iptocheck=$1 + rc_timeout=$2 + no_route=1 + unset rc_timesup + rc_tries=0 + while [ $no_route -a ! $rc_timesup ]; do + sleep 1 + if ping -q -c1 $iptocheck >/dev/null 2>&1 ; then + unset no_route + else + let "rc_tries +=1" + fi + if [ "$rc_tries" -eq "$rc_timeout" ]; then + rc_timesup=1 + fi + done + if [ $no_route ]; then return 1 ;else return 0 ; fi +} + +function ip_test() { + # tests a string to see if it's in a valid IP address format + # Argument is an IP address string. Returns 0 if valid, 1 if not + ip_regex="[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}" + if echo $1|grep -q -e $ip_regex ; then return 0; else return 1; fi +} + +function auto_net_setup() { + # Use DHCP to get an IP address + local dhcpcdtmp=`mktemp -q` + + # Check for and unmount any stale mounts + if mount|grep -q $MEDIA_MNT_DIR ; then + umount -f $MEDIA_MNT_DIR + fi + + # Build array of interfaces + ethifs=( ) + for nif in `cat /proc/net/dev|grep eth|cut -d : -f1`; do + ethifs=( ${ethifs[@]} $nif ) + done + if [ ${#ethifs[@]} -eq 0 ]; then + pause "Couldn't find any usable interfaces. You may need to use USB media." + return 1 + fi + + # Check to see if the network is already up (maybe from a previous run + # that terminated abnormally) and bring it down. + dhcpcd -q -k >/dev/null 2>&1 + for ethif in ${ethifs[@]} ; do + ifconfig $ethif 0.0.0.0 down >/dev/null 2>&1 + done + + progreport "Setting up the network." + log "Setting up the network." + # create a /var/lib/nfs/state file if it doesn't exist + echo "0000" > /var/lib/nfs/state + # kill netplugd to keep it from interfering + killall netplugd >/dev/null 2>&1 + # Since sysresccd-1.0.4, we have to manually start nfs + /etc/init.d/nfsmount start >/dev/null 2>&1 + # Since sysresccd-1.5.8, we have to manually start rpc.statd + /etc/init.d/rpc.statd start >/dev/null 2>&1 + + # Get a DHCP address + + case $backup_server_type in + "RescueBRU Server" ) + dhcpcd_args=$DHCPCD_RBRUSERVER_ARGS + ;; + + "any DHCP server" ) + dhcpcd_args=$DHCPCD_GLOBAL_ARGS + ;; + + * ) + pause "There was a problem determining the backup server type. Aborting." + return 1 + ;; + esac + + unset carrier_present + carrier_attempts=0 + while [ ! $carrier_present ] && [ $carrier_attempts -lt $MAX_CARRIER_ATTEMPTS ]; do + progreport "Requesting an IP address from $backup_server_type ..." + dhcpcd -q -k >/dev/null 2>&1 + echo ""> $dhcpcdtmp + dhcpcd $dhcpcd_args 2>$dhcpcdtmp + if cat $dhcpcdtmp|grep -q "no interfaces have a carrier" ; then + dhcpcd -q -k >/dev/null 2>&1 + sleep 3 + else + carrier_present=1 + fi + let "carrier_attempts +=1" + done + if [ ! $carrier_present ]; then + pause "No ethernet interfaces have a carrier. This probably means the cables are disconnected. Aborting." + rm -f $dhcpcdtmp + return 1 + fi + if ! cat $dhcpcdtmp|grep -q acknowledged ; then + inform "Couldn't get a DHCP offer from $backup_server_type" "5" + log "Couldn't get a DHCP offer from $backup_server_type" + dhcpcd -q -k >/dev/null 2>&1 + rm -f $dhcpcdtmp + return 1 + fi + + progreport "...ok." + remote_addr=`cat $dhcpcdtmp|grep acknowledged|tail -1|rev|cut -d " " -f1|rev` + wkg_addr=`cat $dhcpcdtmp|grep acknowledged|tail -1|rev|cut -d " " -f3|rev` + interface=`cat $dhcpcdtmp|grep acknowledged|tail -1|rev|cut -d " " -f5|cut -c2-|rev` + progreport "Got the address $wkg_addr from the server at $remote_addr" + sleep 3 + log "Got the address $wkg_addr from the server at $remote_addr" + if ! mount $remote_addr:$remote_dir $MEDIA_MNT_DIR >/dev/null 2>&1 ; then + pause "Couldn't mount $remote_addr:$remote_dir. Aborting." + log "Couldn't mount $remote_addr:$remote_dir. Aborting." + dhcpcd -q -k >/dev/null 2>&1 + ifconfig $interface 0.0.0.0 down + rm -f $formtmp $dhcpcdtmp + return 1 + fi + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + umount $MEDIA_MNT_DIR >/dev/null 2>&1 + CLIENT_NET_STATUS=1 + rm -f $formtmp $dhcpcdtmp + return 0 +} + +function manual_net_setup() { + # Set up network manually + formtmp=`mktemp -q` + progreport "" + # Check for and unmount any stale mounts + if mount|grep -q $MEDIA_MNT_DIR ; then + umount -f $MEDIA_MNT_DIR + fi + + # Build array of interfaces + ethifs=( ) + for nif in `cat /proc/net/dev|grep eth|cut -d : -f1`; do + ethifs=( ${ethifs[@]} $nif ) + done + if [ ${#ethifs[@]} -eq 0 ]; then + pause "Couldn't find any usable interfaces. You may need to USB media." + rm -f $formtmp + return 1 + fi + + # Check to see if the network is already up (maybe from a previous run + # that terminated abnormally) and bring it down. + dhcpcd -q -k >/dev/null 2>&1 + for ethif in ${ethifs[@]} ; do + ifconfig $ethif down >/dev/null 2>&1 + done + + progreport "Setting up the network." + log "Setting up the network." + # create a /var/lib/nfs/state file if it doesn't exist + echo "0000" > /var/lib/nfs/state + # kill netplugd to keep it from interfering + killall netplugd >/dev/null 2>&1 + # Since sysresccd-1.0.4, we have to manually start nfs + /etc/init.d/nfsmount start >/dev/null 2>&1 + # Since sysresccd-1.5.8, we have to manually start rpc.statd + /etc/init.d/rpc.statd start >/dev/null 2>&1 + + # prompt for IP info + addr_invalid=1 + remote_dir_invalid=1 + while [ "$addr_invalid" -o "$remote_dir_invalid" ]; do + dialog --form "Backup Server Network Parameters:" 10 77 4 \ + "Backup server IP address:" 1 1 "$NFS_REMOTE_ADDR_DEF" 1 32 32 15 \ + "Client initial IP address:" 2 1 "$NFS_SUBNET_DEF.$NFS_LOCAL_DEF" 2 32 32 15 \ + "Start of client address block:" 3 1 "$NFS_SUBNET_DEF.$NFS_CLIENT_START_DEF" 3 32 32 15 \ + "Remote directory:" 4 1 "$NFS_REMOTE_DIR_DEF" 4 32 32 255 \ + 2>$formtmp + formdata=( `cat $formtmp` ) + if [ ${#formdata[@]} -eq 0 ]; then + pause "Manual net setup cancelled." + log "Manual net setup cancelled." + rm -f $formtmp + return 1 + fi + remote_addr=${formdata[0]} + initial_addr=${formdata[1]} + local_blk_start=${formdata[2]} + remote_dir=${formdata[3]} + if ip_test "$remote_addr" ; then + unset addr_invalid + else + pause "Backup server IP address is not a valid IP address. Try again." + fi + if ip_test "$initial_addr" ; then + unset addr_invalid + else + pause "Client initial IP address is not a valid IP address. Try again." + fi + if ip_test "$local_blk_start" ; then + nset addr_invalid + else + pause "Start of client address block is not a valid IP address. Try again." + fi + if [ "$remote_dir" != "" ]; then + unset remote_dir_invalid + else + pause "Remote directory cannot be blank. Try again." + fi + done + + # Scan interfaces for server + interface="unknown" + progreport "Scanning network interfaces for connection to backup server..." + qs_text="Performing quick scan..." + ns_text="Performing normal scan..." + ls_text="Performing long scan..." + xs_text="Performing extra-long scan..." + scanpass=0 + while [ "$interface" = "unknown" -a "$scanpass" -lt 4 ]; do + let "scanpass +=1" + case $scanpass in + 1 ) + scanpings=1 + scan_info_text="$scan_info_text \n $qs_text" + ;; + 2 ) + scanpings=5 + scan_info_text="$scan_info_text \n $ns_text" + ;; + 3 ) + if ! dialog --no-label "Abort" --no-ok --defaultno \ + --pause "No server found yet. Will keep trying. Press enter to abort." 0 0 10 ; then + scanpass=9 + break + else + scanpings=10 + scan_info_text="$scan_info_text \n $ls_text" + fi + ;; + 4 ) + scanpings=20 + scan_info_text="$scan_info_text \n $xs_text" + ;; + esac + for ifname in ${ethifs[@]} ; do + progreport "$scan_info_text $ifname ..." + ifconfig $ifname $initial_addr netmask 255.255.255.0 + sleep $scanpings + if ping -q -c $scanpings -I $ifname $remote_addr >/dev/null 2>&1 ; then + interface=$ifname + break + ifconfig $ifname down + sleep 1 + fi + done + done + + if [ "$interface" = "unknown" ]; then + pause "Couldn't find a server on any interface. Make sure server is running and all cables are connected." + log "Couldn't find a server on any interface." + rm -f $formtmp + ifconfig $ifname down + return 1 + else + inform "Found a server on the $interface interface." + log "Found a server on the $interface interface." + fi + + # Determine what my real address will be + case $scanpings in + 1 ) + inform "Using quick setup based on interface speed." + ;; + 5 ) + inform "Using normal setup based on interface speed." + ;; + 10 ) + inform "Using slow setup based on interface speed." + ;; + 20 ) + inform "Using extra-slow setup based on interface speed." + ;; + esac + initial_ha=`echo $initial_addr|cut -d "." -f4` + backup_subnet=`echo $remote_addr|cut -d "." -f1-3` + ha=`echo $local_blk_start|cut -d "." -f4` + while ping -q -c $scanpings -I $interface $backup_subnet.$ha >/dev/null 2>&1 && [ $ha -lt $initial_ha ]; do + let "ha += 1" + progreport "Trying $backup_subnet.$ha..." + done + if [ $ha -eq $initial_ha ]; then + pause "Unable to get a working IP address. Too many clients may be connected." + log "Unable to get a working IP address." + rm -f $formtmp + ifconfig $ifname down + return 1 + else + inform "$backup_subnet.$ha is available." + wkg_addr=$backup_subnet.$ha + fi + ifconfig $interface down + sleep 1 + ifconfig $interface $wkg_addr netmask 255.255.255.0 + sleep $scanpings + if ! check_route "$remote_addr" $ROUTE_TIMEOUT; then + pause "Couldn't establish a route to $remote_addr after $ROUTE_TIMEOUT attempts. Aborting." + log "Couldn't establish a route to $remote_addr after $ROUTE_TIMEOUT attempts. Aborting." + ifconfig $interface down + rm -f $formtmp + return 1 + fi + if ! mount $remote_addr:$remote_dir $MEDIA_MNT_DIR >/dev/null 2>&1 ; then + pause "Couldn't mount $remote_addr:$remote_dir. Aborting." + log "Couldn't mount $remote_addr:$remote_dir. Aborting." + ifconfig $interface down + rm -f $formtmp + return 1 + fi + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + umount $MEDIA_MNT_DIR >/dev/null 2>&1 + CLIENT_NET_STATUS=1 + log "Backup server IP address is $remote_addr" + log "Local IP address is $wkg_addr" + log "Remote directory is $remote_dir" + rm -f $formtmp + progreport "" + return 0 +} + + +# ------------------ MEDIA FUNCTIONS ------------------ +function media() { + # Dispatcher for media mounting/unmounting. Chooses correct media type function + # parameter is "mount" or "unmount" + if [ ! -d $MEDIA_MNT_DIR ]; then + mkdir $MEDIA_MNT_DIR + fi + case $media_type in + "NFS" ) NFS "$1" ; return $? ;; + "USB" ) USB "$1" ; return $? ;; + "Local" ) Local "$1" ; return $? ;; + * ) + pause "Must specify mount or unmount." + return 1 + ;; + esac +} + +function NFS() { + # Mount or unmount NFS. + # parameter is "mount" or "unmount" + if [ "$CLIENT_NET_STATUS" -eq 0 ]; then + if [ "$netsetup_type" = "auto" ]; then + if ! auto_net_setup; then return 1;fi + elif [ "$netsetup_type" = "manual" ]; then + if ! manual_net_setup; then return 1;fi + fi + fi + if [ "$1" = "mount" ]; then + progreport "Please wait while route is established..." + if check_route $remote_addr $ROUTE_TIMEOUT ; then + progreport "...ok" + log "established route to $remote_addr" + else + flush_input + pause "Couldn't establish a route to $remote_addr after $ROUTE_TIMEOUT attempts." + log "Couldn't establish a route to $remote_addr after $ROUTE_TIMEOUT attempts. Aborting." + return 1 + fi + if grep -q $MEDIA_MNT_DIR /etc/mtab ; then + progreport "Remote directory appears to be already mounted. Continuing." + log "Remote directory appears to be already mounted. Continuing." + else + progreport "Mounting remote directory..." + if mount $remote_addr:$remote_dir $MEDIA_MNT_DIR -onolock ; then + progreport "...ok" + log "Remote directory mounted." + else + progreport "... FAILED" + sleep 4 + flush_input + pause "Couldn't mount remote NFS directory. Ensure NFS server is running on $remote_addr." + return 1 + fi + fi + nfs_media_free_txt=`df -h $MEDIA_MNT_DIR|grep "$MEDIA_MNT_DIR"|awk '{print $4}'` + nfs_media_free=`df -B 1024k $MEDIA_MNT_DIR|grep "$MEDIA_MNT_DIR"|awk '{print $4}'` + if [ $nfs_media_free -lt $MIN_MEDIA_FREE ]; then + if ! approved "There is less than 2G available on the backup media. If you are running a backup, you may run out of space. If you know what you're doing, you can continue anyway, or abort the operation. Continue?" "n"; then + inform "Aborting. Unmounting remote directory..." + log "Aborting. Unmounting remote directory." + sync + umount $MEDIA_MNT_DIR + sync + return 1 + fi + fi + progreport "Remote directory $remote_dir/$BACKUP_DIR mounted with $nfs_media_free_txt free space." + sleep 3 + log "Remote directory $remote_dir/$BACKUP_DIR mounted with $nfs_media_free_txt free space." + return 0 + elif [ "$1" = "unmount" ]; then + progreport "Unmounting remote directory..." + log "Unmounting remote directory." + sync + umount $MEDIA_MNT_DIR + sync + progreport "... done" + return 0 + else + pause "Must specify mount or unmount." + return 1 + fi +} + +function USB() { + # Prompt user to plug in USB drive and mount it + # parameter is "mount" or "unmount" + trying=1 + local infotext="Searching for USB drive" + flush_input + if [ "$1" = "mount" ]; then + while [ $trying ]; do + infotext="$infotext ." + dialog --begin 3 5 --infobox "Plug in USB drive now or press any key to abort. If drive is already plugged in, and is not detected, unplug it, wait a few seconds, and plug it in again." 0 0 \ + --and-widget \ + --begin 10 5 --sleep 1 --infobox "$infotext" 14 70 + if read -s -n1 -t1 kp <&1 ; then + pause "USB media mounting aborted." + log "USB media mounting aborted." + return 1 + fi + if tail -2 /var/log/messages|grep -q SCSI ; then + unset trying + fi + done + usbdvc=`tail -2 /var/log/messages|grep SCSI|grep -o -e "sd[a-z]"` + usbparts=`ls /dev/$usbdvc?` + # Add USB device to the exclude list + exclude_dev "/dev/$usbdvc" + # add USB partitions to exclude list + for uprt in $usbparts; do exclude_dev $uprt; done + inform "Found USB drive as /dev/$usbdvc" + log "Found USB drive as /dev/$usbdvc" + mount /dev/$usbdvc"1" $MEDIA_MNT_DIR + usb_media_free=`df -B 1024k $MEDIA_MNT_DIR|grep "$MEDIA_MNT_DIR"|awk '{print $4}'` + if [ $usb_media_free -lt $MIN_MEDIA_FREE ]; then + if ! approved "There is less than 2G available on the backup media. If you are running a backup, you may run out of space. If you know what you're doing, you can continue anyway, or abort the operation. Continue?" "n"; then + inform "Aborting. Unmounting USB media..." + log "Aborting. Unmounting USB media." + sync + umount $MEDIA_MNT_DIR + sync + inform "Aborting. Unmounting remote directory... done" + inform "It is now safe to unplug the USB drive." + return 1 + fi + fi + log "USB mounted with $usb_media_free M free space." + return 0 + elif [ "$1" = "unmount" ]; then + inform "Unmounting USB drive..." + sync + umount $MEDIA_MNT_DIR + sync + inform "Unmounting USB drive...done." "1" + inform "It is now safe to unplug the USB drive." + return 0 + else + pause "Must specify mount or unmount." + return 1 + fi +} + +function Local() { + # Prompt user for local pathname + # parameter is "mount" or "unmount" + if [ "$LOCAL_STATUS" -eq 0 ]; then + if ! localdir_setup ; then return 1;fi + fi + if [ "$1" = "mount" ]; then + IMAGE_PATH=$local_dir + return 0 + elif [ "$1" = "unmount" ]; then + sync + return 0 + else + pause "Must specify mount or unmount." + return 1 + fi +} + +function localdir_setup() { + # Determine correct local directory + localdirtmp=`mktemp -q` + path_invalid=true + while [ $path_invalid ]; do + flush_input + if dialog --inputbox "Enter full path of backup directory" 8 78 "$LOCAL_DIR" 2>$localdirtmp ; then + local_dir=`cat $localdirtmp` + if [ "$local_dir" = "" ]; then + local_dir=$LOCAL_DIR + fi + if [ -d "$local_dir" ]; then + unset path_invalid + else + pause "Specified directory does not exist. Perhaps you made a typo.\nTry again." + fi + else + pause "Local directory setup cancelled." + log "Local directory setup cancelled." + rm -f $localdirtemp + return 1 + fi + done + LOCAL_STATUS=1 + log "Local backup directory is $local_dir" + rm -f $localdirtemp + return 0 +} + +function createdir() { + # Create backup directory while avoiding accidental overwrites + unset finalimgname + if [ ! -d "$IMAGE_PATH" ]; then + mediasetup + fi + if [ $imgovr -eq 1 ]; then + finalimgname=$imagename + if [ -d "$IMAGE_PATH/$imagename.new" ]; then + rm -rf $IMAGE_PATH/$imagename.new + fi + imagename="$imagename.new" + fi + inform "Creating backup directory $IMAGE_PATH/$imagename..." "2" + if ! mkdir $IMAGE_PATH/$imagename ; then + pause "An error was encountered while creating backup directory. Aborting." + log "An error was encountered while creating backup directory. Aborting." + return 1 + else + inform "Creating backup directory $IMAGE_PATH/$imagename... done." + log "Backup directory is $IMAGE_PATH/$imagename." + # Copy any previous log/note files to new backup + log "Copying previous log/note files to new backup." + if ls $IMAGE_PATH/$finalimgname/*.log >/dev/null 2>&1 ; then + cp -f $IMAGE_PATH/$finalimgname/*.log $IMAGE_PATH/$imagename/ + fi + if ls $IMAGE_PATH/$finalimgname/*.notes >/dev/null 2>&1 ; then + cp -f $IMAGE_PATH/$finalimgname/*.notes $IMAGE_PATH/$imagename/ + fi + return 0 + fi +} + +function mediasetup() { + # Set up backup media + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and is performing media setup.">$MEDIA_MNT_DIR/$wkg_addr + fi + if [ -d $IMAGE_PATH ]; then + pause "Backup media appears to be already set up." + flush_input + if dialog --aspect 80 --defaultno \ + --yesno "CONTINUING WITH MEDIA SETUP WILL DELETE ANY BACKUPS STORED ON MEDIA! Select Yes to continue, or No to abort :" 0 0 ; then + inform "Removing old image path..." + rm -rf $IMAGE_PATH + sleep 3 + inform "Removing old image path...done." + sleep 1 + inform "Syncing drive..." + sync + sleep 3 + inform "Syncing drive...done." + sleep 1 + inform "Creating new image path..." + mkdir $IMAGE_PATH + sleep 3 + inform "Creating new image path...done." + sleep 1 + inform "Syncing drive..." + sync + sleep 3 + inform "Syncing drive...done." + inform "Media setup complete." + else + pause "Media setup aborted!" + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + return 1 + fi + fi + inform "Creating new image path..." + mkdir $IMAGE_PATH + sleep 3 + inform "Creating new image path...done." + sleep 1 + inform "Syncing drive..." + sync + sleep 3 + inform "Syncing drive...done." + inform "Media setup complete." + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + return 0 +} + +function main() { + # Main program function + # Fix the font so dialog boxes aren't corrupt + /usr/bin/setfont + + # Initialize variables to defaults + defaultsettings + + # Check to see if we were called by a rbruserver + # first parameter must be -localserver + # second parameter is the name of the local directory + # third and subsequent parameters are devices to exclude while doing a backup + if [ "$1" = "-localserver" ]; then + num_of_args=$# + LOCAL_SERVER_RUNNING=1 + shift + let "num_of_args -= 1" + LOCAL_DIR=$1 + LOCAL_STATUS=1 + local_dir=$LOCAL_DIR + media_type="Local" + shift + let "num_of_args -= 1" + while [ $num_of_args -gt 0 ]; do + exclude_dev $1 + shift + let "num_of_args -= 1" + done + fi + + # Create a tempfile for global progress reports + progfile=`mktemp -q` + # Remove any existing temporary log file and start a new one + rm -f $LOG_PATH/* + log "RescueBRU $PROG_VERSION" + log "Run started `date`" + + while true; do + mainmenu + case $mmchoice in + "p" | "P" ) + log "\"Exit and power down\" chosen from main menu." + shutdown_proc "shutdown" + reset + ;; + + "r" | "R" ) + log "\"Exit and reboot\" chosen from main menu." + shutdown_proc "reboot" + reset + ;; + + "s" | "S" ) + log "\"Exit to shell\" chosen from main menu." + log "Run finished." + if [ $LOCAL_SERVER_RUNNING ]; then + rm -f $progfile + dialog --sleep 3 --infobox "Returning to RescueBRU Server" 3 40 + exit 0 + fi + rm -f $progfile + inform "Exiting to shell" "2" + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + if ! check_route $remote_addr $ROUTE_TIMEOUT ; then + inform "Couldn't establish a route to $remote_addr after $ROUTE_TIMEOUT attempts. Aborting" + log "Couldn't establish a route to $remote_addr after $ROUTE_TIMEOUT attempts. Aborting." + umount -f $MEDIA_MNT_DIR + /etc/init.d/nfsmount stop >/dev/null 2>&1 + dhcpcd -q -k >/dev/null 2>&1 + ifconfig $interface 0.0.0.0 down + return 1 + fi + mount $remote_addr:$remote_dir $MEDIA_MNT_DIR + rm -f $MEDIA_MNT_DIR/$wkg_addr + umount $MEDIA_MNT_DIR + /etc/init.d/nfsmount stop >/dev/null 2>&1 + dhcpcd -q -k >/dev/null 2>&1 + ifconfig $interface 0.0.0.0 down + fi + reset + exit 0 + ;; + + "?" ) + log "\"Help\" chosen from main menu." + showhelp + ;; + + 7 ) + log "\"Show backups available on media\" chosen from main menu." + if media "mount" ; then + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and is viewing images.">$MEDIA_MNT_DIR/$wkg_addr + fi + showimages + if [ "$CLIENT_NET_STATUS" -eq 1 ]; then + echo "is allocated and idle.">$MEDIA_MNT_DIR/$wkg_addr + fi + media "unmount" + else + pause "Could not mount backup media. Unable to show backup images." + fi + ;; + + 6 ) + log "\"View logs or notes\" chosen from main menu." + if media "mount" ; then + lognoteview + media "unmount" + else + pause "Could not mount backup media. Unable to view logs." + fi + ;; + + 5 ) + log "\"Image management\" chosen from main menu" + log "Media type is $media_type" + do_image_mod + ;; + + 4 ) + log "\"Disk Utilities\" chosen from main menu" + log "Media type is $media_type" + if ! diskutil ; then + pause "A disk utility failed." + fi + ;; + + 3 ) + log "\"Do a restore\" chosen from main menu." + log "Media type is $media_type" + if ! do_restore ; then + pause "Restore failed." + fi + ;; + + 2 ) + log "\"Do a backup\" chosen from main menu." + log "Media type is $media_type" + log "Backup method is $bu_method" + if ! do_backup ; then + pause "Backup failed." + fi + ;; + + 1 ) + log "\"Settings\" chosen from main menu." + settings + ;; + esac + done +} + +main "$@" +exit $? diff --git a/customcd/files/root/rescuebru/showcapacitywindow.sh b/customcd/files/root/rescuebru/showcapacitywindow.sh new file mode 100644 index 0000000..10e9bb6 --- /dev/null +++ b/customcd/files/root/rescuebru/showcapacitywindow.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# showcapacitywindow.sh +# Rescue CD Backup & Restore Utility capacity window display +# version 7.2.5 +# Rod Wright 1/19/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +CAPACITY_FILE="/root/capacity.txt" + +if ps ax|grep rbruserver|grep -vq grep; then + windowtitle="RAID Capacity" +else + windowtitle="Media Capacity" +fi +while true ; do + if ! ps ax| grep "watch -t -n1"|grep -q $CAPACITY_FILE ; then + xfce4-terminal --disable-server --hide-menubar --hide-toolbar --title="$windowtitle" --geometry=25x4+2000+0 -e "watch -t -n1 'cat $CAPACITY_FILE'" + echo $! >$PID_FILE + fi + sleep 2 +done diff --git a/customcd/files/root/rescuebru/showfaultwindow.sh b/customcd/files/root/rescuebru/showfaultwindow.sh new file mode 100644 index 0000000..5badda1 --- /dev/null +++ b/customcd/files/root/rescuebru/showfaultwindow.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# showfaultwindow.sh +# Rescue CD Backup & Restore Utility fault window display +# version 7.2.5 +# Rod Wright 1/19/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +STATUS_FILE="/root/faultstatus.txt" + +windowtitle="Server Status" + +while true ; do + if ! ps ax|grep "watch -t -n1"|grep -q $STATUS_FILE ; then + xfce4-terminal --disable-server --hide-menubar --hide-toolbar --title="$windowtitle" --geometry=25x3+2000+100 -e "watch -c -t -n1 'cat $STATUS_FILE'" + fi + sleep 2 +done diff --git a/customcd/files/root/rescuebru/showstatuswindow.sh b/customcd/files/root/rescuebru/showstatuswindow.sh new file mode 100644 index 0000000..6ca06f2 --- /dev/null +++ b/customcd/files/root/rescuebru/showstatuswindow.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# showstatuswindow.sh +# Rescue CD Backup & Restore Utility status window display +# version 7.2.5 +# Rod Wright 1/19/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +STATUS_FILE="/root/status.txt" + +windowtitle="RescueBRU Status" + +while true ; do + if ! ps ax|grep "watch -t -n1"|grep -q $STATUS_FILE ; then + xfce4-terminal --disable-server --hide-menubar --hide-toolbar --title="$windowtitle" --geometry=110x13+0+480 -e "watch -t -n1 'cat $STATUS_FILE'" + fi + sleep 2 +done diff --git a/customcd/files/root/rescuebru/updatecapacity.sh b/customcd/files/root/rescuebru/updatecapacity.sh new file mode 100644 index 0000000..9ca6686 --- /dev/null +++ b/customcd/files/root/rescuebru/updatecapacity.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# updatecapacity.sh +# Rescue CD Backup & Restore Utility media capacity update script +# version 7.2.5 +# Rod Wright 1/19/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +RAID_MNT_PT="/mnt/rescuebru" +CAPACITY_FILE="/root/capacity.txt" +UPDATE_INTERVAL=10 + +while true; do + if ! mount|grep -q /mnt/rescuebru ; then + if ps ax|grep rbruserver|grep -vq grep; then + echo "Awaiting RAID mount...">$CAPACITY_FILE + else + echo "Awaiting backup media...">$CAPACITY_FILE + fi + else + dfout=`df -h $RAID_MNT_PT|grep $RAID_MNT_PT` + total=`echo $dfout|awk '{print $2}'` + used=`echo $dfout|awk '{print $3}'` + available=`echo $dfout|awk '{print $4}'` + percentage=`echo $dfout|awk '{print $5}'` + + echo "Total Capacity: $total">$CAPACITY_FILE + echo "Used: $used">>$CAPACITY_FILE + echo "Available: $available">>$CAPACITY_FILE + echo "Percent Usage: $percentage">>$CAPACITY_FILE + fi + + sleep $UPDATE_INTERVAL +done diff --git a/customcd/files/root/rescuebru/updatestatus.sh b/customcd/files/root/rescuebru/updatestatus.sh new file mode 100644 index 0000000..2c3aaeb --- /dev/null +++ b/customcd/files/root/rescuebru/updatestatus.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# updatestatus.sh +# Rescue CD Backup & Restore Utility status update script +# version 7.2.5 +# Rod Wright 1/19/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +STATUS_FILE="/root/status.txt" +INFO_FILE="/root/rbinfo.txt" +UPDATE_INTERVAL=1 + +while true; do + csplit -s -f opsum $INFO_FILE '/^Image/' + cat /root/opsum00 | tr '\n' '\t'>$STATUS_FILE + rm /root/opsum* + echo "\n" >>$STATUS_FILE + #csplit -s -f opsum $INFO_FILE '%^Image%-1' '/Devices + + sleep $UPDATE_INTERVAL +done diff --git a/customcd/files/root/rescuebru/xrbruserver.sh b/customcd/files/root/rescuebru/xrbruserver.sh new file mode 100644 index 0000000..3fc4039 --- /dev/null +++ b/customcd/files/root/rescuebru/xrbruserver.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# xrbruserver.sh +# Rescue CD Backup & Restore Utility graphical server startup +# version 7.2.5 +# Rod Wright 1/19/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +/root/rescuebru/faultmonitor.sh & +sleep 1 +/root/rescuebru/updatecapacity.sh & +sleep 1 +/root/rescuebru/showcapacitywindow.sh & +sleep 1 +/root/rescuebru/showfaultwindow.sh & +sleep 1 +/usr/bin/xfce4-terminal --disable-server --hide-menubar --hide-toolbar --title="RescueBRU Server" --geometry=80x25+0+0 -e /root/rescuebru/rbruserver.sh & diff --git a/customcd/files/root/rescuebru/xrescuebru.sh b/customcd/files/root/rescuebru/xrescuebru.sh new file mode 100644 index 0000000..21ca9dd --- /dev/null +++ b/customcd/files/root/rescuebru/xrescuebru.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# xrescuebru.sh +# Rescue CD Backup & Restore Utility graphical client start +# version 7.2.5 +# Rod Wright 1/19/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +xset dpms 0 0 0 +/root/rescuebru/updatecapacity.sh & +sleep 1 +/root/rescuebru/showcapacitywindow.sh & +sleep 2 +/usr/bin/xfce4-terminal --disable-server --hide-menubar --hide-toolbar --title="RescueBRU" --geometry=80x25+0+0 -e /root/rescuebru/rescuebru.sh & diff --git a/customcd/files/root/srcdtips b/customcd/files/root/srcdtips new file mode 100644 index 0000000..84f3f2d --- /dev/null +++ b/customcd/files/root/srcdtips @@ -0,0 +1,59 @@ +# srcdtips +# Rescue CD Backup & Restore Utility system rescue cd tips +# version 7.2.5 +# Rod Wright 1/16/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- + +# ============ PRINT MESSAGE =========================== +lc1='\e[01;31m' # light red +dc1='\e[00;31m' # dark red +lc2='\e[01;37m' # white +dc2='\e[00;37m' # gray + +# fix broken console with utf8 in the alternative-kernels +echo -n -e '\033%G' +kbd_mode -u + +LINES=$(stty size|cut -d" " -f1) +fbecho() +{ + [ $LINES -ge 28 ] && echo +} + +if [ -f /root/version ] +then + VERSION=" ${lc2}$(cat /root/version)${lc1} " +else + VERSION="" +fi + +fbecho +echo -e "${lc1} =========== ${lc2}SystemRescue-Cd${lc1} -----${VERSION}=========== ${lc2}$(basename $(tty))${dc2}/6 ${lc1}==" +echo -e " ${dc1}http://www.sysresccd.org/" +echo +echo -e "${dc1}*${dc2} You should stop the Network-Manager service if you want to configure " +echo -e " the network by hand. Just run this command: /etc/init.d/NetworkManager stop" +echo -e "${dc1}*${dc2} Type ${lc2}net-setup eth0${dc2} to specify ethernet configuration." +echo -e "${dc1}*${dc2} If your PC is on an ethernet local network, you can configure by hand:" +echo -e " ${dc1}-${dc2} ifconfig eth0 192.168.x.a (your static IP address)" +echo -e " ${dc1}-${dc2} route add default gw 192.168.x.b (IP address of the gateway)" +fbecho +echo -e "${dc1}*${dc2} To be sure there is an ssh server running, type ${lc2}/etc/init.d/sshd start${dc2}." +echo -e " You will need to create an user or to change the root password with ${lc2}passwd${dc2}." +fbecho +echo -e "${dc1}*${dc2} Available console text editors : ${lc2}nano${dc2}, ${lc2}vim${dc2}, ${lc2}qemacs${dc2}, ${lc2}joe${dc2}." +echo -e "${dc1}*${dc2} Web browser in the console: ${lc2}elinks www.web-site.org${dc2}." +fbecho +echo -e "${dc1}*${lc1} Ntfs-3g${dc2} : If you need a full Read-Write NTFS access, use Ntfs-3g." +echo -e " Mount the disk: ${lc2}ntfs-3g /dev/sda1 /mnt/windows${dc2}" +fbecho +echo -e "${dc1}*${lc1} Graphical environment${dc2} : use either ${lc2}Xorg${dc2} or ${lc2}Xfbdev${dc2}." +echo -e " Type ${lc2}wizard${dc2} to run the graphical environment (or ${lc2}startx${dc2} but it may fail)" +echo -e " X.Org comes with the XFCE environment and several graphical tools:" +echo -e " ${dc1}-${dc2} Partition manager:..${lc2}gparted${dc2}" +echo -e " ${dc1}-${dc2} Web browsers:.......${lc2}firefox-52.7.3${dc2}" +echo -e " ${dc1}-${dc2} Text editors:.......${lc2}gvim${dc2} and ${lc2}geany${dc2}" +echo +fbecho + diff --git a/customcd/files/root/xrescuebru.desktop b/customcd/files/root/xrescuebru.desktop new file mode 100644 index 0000000..5f09b0b --- /dev/null +++ b/customcd/files/root/xrescuebru.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=0.9.4 +Type=Application +Name=xrescuebru +Comment= +Exec=/root/rescuebru/xrescuebru.sh +OnlyShowIn=XFCE; +StartupNotify=false +Terminal=false +Hidden=false diff --git a/customcd/files/root/zshrc.rbruserver b/customcd/files/root/zshrc.rbruserver new file mode 100644 index 0000000..0f45e28 --- /dev/null +++ b/customcd/files/root/zshrc.rbruserver @@ -0,0 +1,48 @@ +# zshrc.rbruserver +# Rescue CD Backup & Restore Utility zsh configuration +# version 7.2.5 +# Rod Wright 1/16/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- +# +# This file is based on the configuration written by +# Bruno Bonfils, +# Written since summer 2001 + +# +# My functions (don't forget to modify fpath before call compinit !!) +fpath=($HOME/.zsh/functions $fpath) + +# colors +eval `dircolors $HOME/.zsh/colors` + +autoload -U zutil +autoload -U compinit +autoload -U complist + +bindkey '\e[A' history-search-backward +bindkey '\e[B' history-search-forward +bindkey '^K' kill-whole-line +bindkey "\e[H" beginning-of-line # Home (xorg) +bindkey "\e[1~" beginning-of-line # Home (console) +bindkey "\e[4~" end-of-line # End (console) +bindkey "\e[F" end-of-line # End (xorg) +bindkey "\e[2~" overwrite-mode # Ins +bindkey "\e[3~" delete-char # Delete +bindkey '\eOH' beginning-of-line +bindkey '\eOF' end-of-line + +# Activation +compinit + +# Resource files +for file in $HOME/.zsh/rc/*.rc; do + source $file +done + +#start the rescuebru server +if [ "$TTY" = "/dev/tty1" ]; then + /root/rescuebru/rbruserver +fi + + diff --git a/customcd/files/root/zshrc.rescuebru b/customcd/files/root/zshrc.rescuebru new file mode 100644 index 0000000..0ea9bec --- /dev/null +++ b/customcd/files/root/zshrc.rescuebru @@ -0,0 +1,50 @@ +# zshrc.rescuebru +# Rescue CD Backup & Restore Utility zshrc configuration +# version 7.2.5 +# Rod Wright 1/16/2024 +# Refer to CHANGELOG file for details. +# ----------------------------------------------------------------------------- +# +# This file is based on the configuration written by +# Bruno Bonfils, +# Written since summer 2001 + +# +# My functions (don't forget to modify fpath before call compinit !!) +fpath=($HOME/.zsh/functions $fpath) + +# colors +eval `dircolors $HOME/.zsh/colors` + +autoload -U zutil +autoload -U compinit +autoload -U complist + +bindkey '\e[A' history-search-backward +bindkey '\e[B' history-search-forward +bindkey '^K' kill-whole-line +bindkey "\e[H" beginning-of-line # Home (xorg) +bindkey "\e[1~" beginning-of-line # Home (console) +bindkey "\e[4~" end-of-line # End (console) +bindkey "\e[F" end-of-line # End (xorg) +bindkey "\e[2~" overwrite-mode # Ins +bindkey "\e[3~" delete-char # Delete +bindkey '\eOH' beginning-of-line +bindkey '\eOF' end-of-line + +# Activation +compinit + +# Resource files +for file in $HOME/.zsh/rc/*.rc; do + source $file +done + +# Eject the CD +/usr/bin/eject >/dev/null 2>&1 + +# Start rescuebru +if [ "$TTY" = "/dev/tty1" ]; then + /root/rescuebru/rescuebru +fi + diff --git a/customcd/isoroot/RescueBRU_Documentation/CHANGELOG.odt b/customcd/isoroot/RescueBRU_Documentation/CHANGELOG.odt new file mode 100644 index 0000000..b02e1d0 Binary files /dev/null and b/customcd/isoroot/RescueBRU_Documentation/CHANGELOG.odt differ diff --git a/customcd/isoroot/RescueBRU_Documentation/CHANGELOG.pdf b/customcd/isoroot/RescueBRU_Documentation/CHANGELOG.pdf new file mode 100644 index 0000000..a3cc05e Binary files /dev/null and b/customcd/isoroot/RescueBRU_Documentation/CHANGELOG.pdf differ diff --git a/customcd/isoroot/RescueBRU_Documentation/Creating Bootable USB.odt b/customcd/isoroot/RescueBRU_Documentation/Creating Bootable USB.odt new file mode 100644 index 0000000..c8b6c68 Binary files /dev/null and b/customcd/isoroot/RescueBRU_Documentation/Creating Bootable USB.odt differ diff --git a/customcd/isoroot/RescueBRU_Documentation/Creating Bootable USB.pdf b/customcd/isoroot/RescueBRU_Documentation/Creating Bootable USB.pdf new file mode 100644 index 0000000..bd59f92 Binary files /dev/null and b/customcd/isoroot/RescueBRU_Documentation/Creating Bootable USB.pdf differ diff --git a/customcd/isoroot/RescueBRU_Documentation/Manual RAID Set Creation.odt b/customcd/isoroot/RescueBRU_Documentation/Manual RAID Set Creation.odt new file mode 100644 index 0000000..79d95ea Binary files /dev/null and b/customcd/isoroot/RescueBRU_Documentation/Manual RAID Set Creation.odt differ diff --git a/customcd/isoroot/RescueBRU_Documentation/Manual RAID Set Creation.pdf b/customcd/isoroot/RescueBRU_Documentation/Manual RAID Set Creation.pdf new file mode 100644 index 0000000..917b547 Binary files /dev/null and b/customcd/isoroot/RescueBRU_Documentation/Manual RAID Set Creation.pdf differ diff --git a/customcd/isoroot/RescueBRU_Documentation/Release_Notes_7.2.5.odt b/customcd/isoroot/RescueBRU_Documentation/Release_Notes_7.2.5.odt new file mode 100644 index 0000000..1b58999 Binary files /dev/null and b/customcd/isoroot/RescueBRU_Documentation/Release_Notes_7.2.5.odt differ diff --git a/customcd/isoroot/RescueBRU_Documentation/Release_Notes_7.2.5.pdf b/customcd/isoroot/RescueBRU_Documentation/Release_Notes_7.2.5.pdf new file mode 100644 index 0000000..4a02b49 Binary files /dev/null and b/customcd/isoroot/RescueBRU_Documentation/Release_Notes_7.2.5.pdf differ diff --git a/customcd/isoroot/RescueBRU_Documentation/Server_Backup_Transfer.odt b/customcd/isoroot/RescueBRU_Documentation/Server_Backup_Transfer.odt new file mode 100644 index 0000000..64ca2f5 Binary files /dev/null and b/customcd/isoroot/RescueBRU_Documentation/Server_Backup_Transfer.odt differ diff --git a/customcd/isoroot/RescueBRU_Documentation/Server_Backup_Transfer.pdf b/customcd/isoroot/RescueBRU_Documentation/Server_Backup_Transfer.pdf new file mode 100644 index 0000000..3fc02ea Binary files /dev/null and b/customcd/isoroot/RescueBRU_Documentation/Server_Backup_Transfer.pdf differ diff --git a/customcd/isoroot/RescueBRU_Documentation/Windows Password Recovery.odt b/customcd/isoroot/RescueBRU_Documentation/Windows Password Recovery.odt new file mode 100644 index 0000000..f8836ea Binary files /dev/null and b/customcd/isoroot/RescueBRU_Documentation/Windows Password Recovery.odt differ diff --git a/customcd/isoroot/RescueBRU_Documentation/Windows Password Recovery.pdf b/customcd/isoroot/RescueBRU_Documentation/Windows Password Recovery.pdf new file mode 100644 index 0000000..3df889b Binary files /dev/null and b/customcd/isoroot/RescueBRU_Documentation/Windows Password Recovery.pdf differ diff --git a/customcd/isoroot/Revision.txt b/customcd/isoroot/Revision.txt new file mode 100644 index 0000000..e8cadee --- /dev/null +++ b/customcd/isoroot/Revision.txt @@ -0,0 +1 @@ +7.2.5.1 diff --git a/customcd/isoroot/boot/grub/grub-522.cfg.client b/customcd/isoroot/boot/grub/grub-522.cfg.client new file mode 100644 index 0000000..df3f66b --- /dev/null +++ b/customcd/isoroot/boot/grub/grub-522.cfg.client @@ -0,0 +1,77 @@ +# Global options +set timeout=30 +set default=1 +set fallback=0 +set pager=1 + +# Display settings +if loadfont /boot/grub/font.pf2 ; then + set gfxmode=auto + insmod efi_gop + insmod efi_uga + insmod gfxterm + insmod videotest + insmod videoinfo + terminal_output gfxterm +fi + +menuentry "RescueBRU - Run Rescue CD Backup/Restore Utility" { + set gfxpayload=keep + linux /isolinux/rescue64 scandelay=1 setkmap=us docache nolvm nodhcp nodmraid lowmem nonm ar_nowait autoruns=1 + initrd /isolinux/initram.igz +} + +menuentry "RescueBRU - Run Rescue CD Backup/Restore Utility in Xorg" { + set gfxpayload=keep + linux /isolinux/rescue64 scandelay=1 setkmap=us dostartx docache nolvm nodhcp nodmraid lowmem nonm ar_nowait autoruns=3 + initrd /isolinux/initram.igz +} + +menuentry "RescueBRU - Run Rescue CD Backup/Restore Server" { + set gfxpayload=keep + linux /isolinux/rescue64 scandelay=1 setkmap=us dostartx nolvm nodhcp nodmraid nonm ar_nowait autoruns=2 + initrd /isolinux/initram.igz +} + +menuentry "RescueBRU - Run Rescue CD Backup/Restore Utility (text mode)" { + set gfxpayload=keep + linux /isolinux/rescue64 scandelay=1 setkmap=us nolvm nodhcp nodmraid lowmem nonm ar_nowait autoruns=1 + initrd /isolinux/initram.igz +} + +menuentry "SystemRescueCd (64bit, default boot options)" { + set gfxpayload=keep + linux /isolinux/rescue64 + initrd /isolinux/initram.igz +} + +menuentry "SystemRescueCd (64bit, cache all files in memory)" { + set gfxpayload=keep + linux /isolinux/rescue64 docache + initrd /isolinux/initram.igz +} + +menuentry "SystemRescueCd (64bit, alternative kernel with default options)" { + set gfxpayload=keep + linux /isolinux/altker64 + initrd /isolinux/initram.igz +} + +menuentry "SystemRescueCd (64bit, disable Kernel-Mode-Settings)" { + set gfxpayload=keep + linux /isolinux/rescue64 nomodeset + initrd /isolinux/initram.igz +} + +menuentry "SystemRescueCd (64bit, directly start the graphical environment)" { + set gfxpayload=keep + linux /isolinux/rescue64 dostartx + initrd /isolinux/initram.igz +} + +menuentry "Boot existing Linux OS installed on the disk (64bit kernel)" { + set gfxpayload=keep + linux /isolinux/rescue64 root=auto + initrd /isolinux/initram.igz +} + diff --git a/customcd/isoroot/boot/grub/grub-522.cfg.server b/customcd/isoroot/boot/grub/grub-522.cfg.server new file mode 100644 index 0000000..e321bba --- /dev/null +++ b/customcd/isoroot/boot/grub/grub-522.cfg.server @@ -0,0 +1,77 @@ +# Global options +set timeout=5 +set default=2 +set fallback=1 +set pager=1 + +# Display settings +if loadfont /boot/grub/font.pf2 ; then + set gfxmode=auto + insmod efi_gop + insmod efi_uga + insmod gfxterm + insmod videotest + insmod videoinfo + terminal_output gfxterm +fi + +menuentry "RescueBRU - Run Rescue CD Backup/Restore Utility" { + set gfxpayload=keep + linux /isolinux/rescue64 scandelay=1 setkmap=us docache nolvm nodhcp nodmraid lowmem nonm ar_nowait autoruns=1 + initrd /isolinux/initram.igz +} + +menuentry "RescueBRU - Run Rescue CD Backup/Restore Utility in Xorg" { + set gfxpayload=keep + linux /isolinux/rescue64 scandelay=1 setkmap=us dostartx docache nolvm nodhcp nodmraid lowmem nonm ar_nowait autoruns=3 + initrd /isolinux/initram.igz +} + +menuentry "RescueBRU - Run Rescue CD Backup/Restore Server" { + set gfxpayload=keep + linux /isolinux/rescue64 scandelay=1 setkmap=us dostartx nolvm nodhcp nodmraid nonm ar_nowait autoruns=2 + initrd /isolinux/initram.igz +} + +menuentry "RescueBRU - Run Rescue CD Backup/Restore Utility (text mode)" { + set gfxpayload=keep + linux /isolinux/rescue64 scandelay=1 setkmap=us nolvm nodhcp nodmraid lowmem nonm ar_nowait autoruns=1 + initrd /isolinux/initram.igz +} + +menuentry "SystemRescueCd (64bit, default boot options)" { + set gfxpayload=keep + linux /isolinux/rescue64 + initrd /isolinux/initram.igz +} + +menuentry "SystemRescueCd (64bit, cache all files in memory)" { + set gfxpayload=keep + linux /isolinux/rescue64 docache + initrd /isolinux/initram.igz +} + +menuentry "SystemRescueCd (64bit, alternative kernel with default options)" { + set gfxpayload=keep + linux /isolinux/altker64 + initrd /isolinux/initram.igz +} + +menuentry "SystemRescueCd (64bit, disable Kernel-Mode-Settings)" { + set gfxpayload=keep + linux /isolinux/rescue64 nomodeset + initrd /isolinux/initram.igz +} + +menuentry "SystemRescueCd (64bit, directly start the graphical environment)" { + set gfxpayload=keep + linux /isolinux/rescue64 dostartx + initrd /isolinux/initram.igz +} + +menuentry "Boot existing Linux OS installed on the disk (64bit kernel)" { + set gfxpayload=keep + linux /isolinux/rescue64 root=auto + initrd /isolinux/initram.igz +} + diff --git a/customcd/isoroot/bootdisk/aida.img b/customcd/isoroot/bootdisk/aida.img new file mode 100644 index 0000000..62b3e2b Binary files /dev/null and b/customcd/isoroot/bootdisk/aida.img differ diff --git a/customcd/isoroot/bootdisk/dban.bzi b/customcd/isoroot/bootdisk/dban.bzi new file mode 100644 index 0000000..a0b6916 Binary files /dev/null and b/customcd/isoroot/bootdisk/dban.bzi differ diff --git a/customcd/isoroot/bootdisk/grubdisk.img b/customcd/isoroot/bootdisk/grubdisk.img new file mode 100644 index 0000000..1beda49 Binary files /dev/null and b/customcd/isoroot/bootdisk/grubdisk.img differ diff --git a/customcd/isoroot/isolinux/f1boot.msg b/customcd/isoroot/isolinux/f1boot.msg new file mode 100644 index 0000000..c285d29 --- /dev/null +++ b/customcd/isoroot/isolinux/f1boot.msg @@ -0,0 +1,24 @@ +0C + ____ ____ ____ _ _ +| _ \ ___ ___ ___ _ _ ___ | _ \| _ \| | | | +| |_) / _ \/ __|/ __| | | |/ _ \||_) /| |_) | | | | +| _ < __/\__ \ (__| |_| | __/||_) \| _ <| |_| | +|_| \_\___||___/\___|\__,_|\___||____/|_| \_ \___/ + +07 +0C*07 Welcome to RescueBRU-7.2.5, the Rescue CD Backup & Restore Utility +0C*07 +0C*07 Built 21 Sep 2021 by Rod Wright +0C*07 Based on SystemRescueCD 5.2.2. Visit http://www.sysresccd.org +0C*07 +0C*07 After booting, type rescuebru to perform backups or restorations, +0C*07 or type rbruserver to start the backup server. +0C*07 + + +0C*07 To boot, just press enter at the boot: prompt below. + +02==>07 0EPress F5 for help if you have boot problems with RescueBRU 02<==07 + +0fF2,F3,F4,F5,F6,F707 for boot options and more help. +0fEnter07 to boot. diff --git a/customcd/isoroot/isolinux/isolinux.cfg.client b/customcd/isoroot/isolinux/isolinux.cfg.client new file mode 100644 index 0000000..3f2b5c8 --- /dev/null +++ b/customcd/isoroot/isolinux/isolinux.cfg.client @@ -0,0 +1,564 @@ +UI vesamenu.c32 +F2 f2images.msg +F3 f3params.msg +F4 f4arun.msg +F5 f5troubl.msg +F6 f6pxe.msg +F7 f7net.msg + +PROMPT 0 +TIMEOUT 300 +ONTIMEOUT rescuebru + +MENU DEFAULT rescuebru +MENU TABMSG Press to edit options or ,,,,, for help +MENU TITLE RescueBRU 7.2.5 (System Rescue CD 5.2.2 (www.sysresccd.org)) +MENU ROWS 16 +MENU TIMEOUTROW 22 +MENU TABMSGROW 24 +MENU CMDLINEROW 24 +MENU HELPMSGROW 26 +MENU WIDTH 78 +MENU MARGIN 6 +MENU BACKGROUND #FF003333 + +MENU color title 1;31;40 #FFFF0000 #00000000 std +MENU color sel 7;37;40 #FF000000 #FFC0C0C0 all +MENU color unsel 37;44 #FFFFFFFF #00000000 none +MENU color hotsel 1;7;37;40 #FF000000 #FFC0C0C0 all +MENU color tabmsg 1;31;40 #FFFFFF00 #00000000 std +MENU color help 1;31;40 #FFFFFFFF #00000000 none + +LABEL rescuebru + MENU LABEL 1) RescueBRU: Run Rescue CD Backup/Restore Utility + KERNEL ifcpu64.c32 + APPEND rescue64 scandelay=1 setkmap=us dostartx docache nolvm nodhcp nodmraid lowmem nonm ar_nowait autoruns=3 -- rescue32 scandelay=1 setkmap=us dostartx docache nolvm nodhcp nodmraid lowmem nonm ar_nowait autoruns=3 + TEXT HELP + Standard RescueBRU Client running in GUI environment. Caches all + files to memory and ejects the CD. + ENDTEXT + +LABEL rescuebru_txt + MENU LABEL 2) RescueBRU: Run Rescue CD Backup/Restore Utility (text mode) + KERNEL ifcpu64.c32 + APPEND rescue64 scandelay=1 setkmap=us nolvm nodhcp nodmraid lowmem nonm ar_nowait autoruns=1 -- rescue32 scandelay=1 setkmap=us nolvm nodhcp nodmraid lowmem nonm ar_nowait autoruns=1 + TEXT HELP + Text mode RescueBRU Client for systems with less than 1Gb + of memory or lack of graphics capability. Runs directly from CD. + CD will not eject after boot. Must remove CD manually after reboot. + ENDTEXT + +LABEL rbruserver + MENU LABEL 3) RescueBRU Server: Run Rescue CD Backup/Restore Server + KERNEL ifcpu64.c32 + APPEND rescue64 scandelay=1 setkmap=us dostartx nolvm nodhcp nodmraid nonm ar_nowait autoruns=2 -- rescue32 scandelay=1 setkmap=us dostartx nolvm nodhcp nodmraid nonm ar_nowait autoruns=2 + TEXT HELP + Automatically start RescueBRU Server.Runs directly from CD. + CD will not eject after boot. Must remove CD manually after reboot. + ENDTEXT + +MENU SEPARATOR + +LABEL memtest + MENU LABEL 4) MEMTEST: Memory test using Memtest86+ + kernel /bootdisk/memtestp + append - + TEXT HELP + Use this tool if you suspect your RAM may be damaged. Damaged memory can + explain crashes or unexpected bahaviors on stable operating systems. + ENDTEXT + +LABEL ntpass + MENU LABEL 5) NTPASSWD: Reset or edit Windows passwords + kernel /ntpasswd/vmlinuz + append rw vga=1 initrd=/ntpasswd/initrd.cgz,/ntpasswd/scsi.cgz + TEXT HELP + This tool can be used to reset windows users accounts. It works will all + windows user accounts including the administrator. You can use this tool if + you forgot the administrator's password. + ENDTEXT + +LABEL dban + MENU LABEL 6) DBAN: erase all data from the disk + kernel /bootdisk/dban.bzi + append nuke="dwipe" silent + +LABEL rescuecd_auto + MENU LABEL 7) Boot an existing Linux system installed on the disk + KERNEL ifcpu64.c32 + APPEND rescue64 root=auto -- rescue32 root=auto + TEXT HELP + Detect partition where linux is installed and boot from it. You can use + this to boot Linux if your boot loader (eg: Grub) is broken or has been + removed by another OS. + ENDTEXT + +LABEL freedos + MENU LABEL 8) FREEDOS: Clone of the MSDOS Operating System + kernel memdisk + append initrd=/bootdisk/freedos.img floppy + TEXT HELP + FreeDOS can be used to execute DOS programs such as BIOS upgrade tools + ENDTEXT + +MENU SEPARATOR + +LABEL rescuecd_std + MENU LABEL 9) SystemRescueCd: default boot options + KERNEL ifcpu64.c32 + APPEND rescue64 scandelay=1 autoruns=no setkmap=us -- rescue32 scandelay=1 autoruns=no setkmap=us + TEXT HELP + Boot standard kernel with default options (should always work) + You should use this entry if you don't know which one to use + ENDTEXT + +LABEL rescuecd_docache + MENU LABEL 10) SystemRescueCd: all files cached to memory (docache) + KERNEL ifcpu64.c32 + APPEND rescue64 scandelay=1 autoruns=no setkmap=us docache -- rescue32 scandelay=1 autoruns=no setkmap=us docache + TEXT HELP + Boot standard kernel and run system from RAM (cdrom can be removed) + It requires 512 MB of memory to work and takes some time during the + boot process, but the cdrom can be removed and system will be faster. + ENDTEXT + +LABEL rescuecd_791 + MENU LABEL 11) SystemRescueCd: console in high resolution (framebuffer) + KERNEL ifcpu64.c32 + APPEND rescue64 nomodeset vga=791 scandelay=1 autoruns=no setkmap=us -- rescue32 nomodeset vga=791 scandelay=1 autoruns=no setkmap=us + TEXT HELP + Boot standard kernel with console in high resolution + This mode is useful only if you want to work in console mode + ENDTEXT + +LABEL rescuecd_us + MENU LABEL 12) SystemRescueCd: do not ask for keyboard, use US keymap + KERNEL ifcpu64.c32 + APPEND rescue64 scandelay=1 setkmap=us autoruns=no -- rescue32 scandelay=1 setkmap=us autoruns=no + TEXT HELP + Boot standard kernel and use the keymap for american keyboards + This way it will not prompt for the keymap during the boot process + ENDTEXT + +LABEL rescuecd_xorg + MENU LABEL 13) SystemRescueCd: directly start the graphical environment + KERNEL ifcpu64.c32 + APPEND rescue64 scandelay=1 dostartx autoruns=no setkmap=us -- rescue32 scandelay=1 dostartx autoruns=no setkmap=us + TEXT HELP + Boot standard kernel and start the XFCE graphical environment + directly. You can also get in this environment by typing "startx" from + the console. + ENDTEXT + +MENU SEPARATOR + +# ------------------------------------------------------------------------------ + +MENU BEGIN +MENU TITLE A) Run system tools from floppy disk image... + +LABEL grubdisk +MENU LABEL SGD: Super Grub2 Disk +kernel memdisk +append initrd=/bootdisk/grubdisk.img floppy raw + +LABEL netboot +MENU LABEL NETBOOT: Boot from the network +kernel netboot +append - + +LABEL hdt +MENU LABEL HDT: recent hardware diagnostics tool +kernel memdisk +append initrd=/bootdisk/hdt.img floppy +TEXT HELP +This diagnostic tool will give you information about your hardware +ENDTEXT + +LABEL aida +MENU LABEL AIDA: old hardware diagnostics tool +kernel memdisk +append initrd=/bootdisk/aida.img floppy + +LABEL mhdd +MENU LABEL MHDD: Low-level Hard Drive diagnostic tool +kernel memdisk +append initrd=/bootdisk/mhdd.img floppy + +MENU SEPARATOR + +LABEL return +MENU LABEL Return to main menu +MENU EXIT + +MENU END + +# ------------------------------------------------------------------------------ + +MENU BEGIN +MENU TITLE B) Standard 32bit kernel (rescue32) with more choice... + +LABEL rescue32_1 +MENU LABEL 1. SystemRescueCd with default options +LINUX rescue32 +INITRD initram.igz +TEXT HELP +Boot standard 32bit kernel with default options (should always work) +ENDTEXT + +LABEL rescue32_2 +MENU LABEL 2. SystemRescueCd with all files cached to memory +LINUX rescue32 +INITRD initram.igz +APPEND docache +TEXT HELP +Boot standard 32bit kernel and run system from memory. +It requires 512 MB of memory to work and takes some time during the +boot process, but the cdrom can be removed and system will be faster. +ENDTEXT + +LABEL rescue32_3 +MENU LABEL 3. SystemRescueCd with console in high resolution (1024x768) +LINUX rescue32 +INITRD initram.igz +APPEND nomodeset vga=791 +TEXT HELP +Boot standard 32bit kernel with framebuffer console in high resolution +KMS graphic drivers (Kernel-Mode-Settings) will be disabled. +ENDTEXT + +LABEL rescue32_4 +MENU LABEL 4. SystemRescueCd with a standard VGA console (no KMS) +LINUX rescue32 +INITRD initram.igz +APPEND nomodeset +TEXT HELP +Boot standard 32bit kernel and use standard low-resolution VGA console +KMS graphic drivers (Kernel-Mode-Settings) will be disabled. +Try this if you can't get a working console or new a low-resolution mode +ENDTEXT + +LABEL rescue32_5 +MENU LABEL 5. SystemRescueCd with a console in 800x600 +LINUX rescue32 +INITRD initram.igz +APPEND video=800x600 +TEXT HELP +Boot standard 32bit kernel and use the default graphic driver in 800x600 +KMS graphic drivers (Kernel-Mode-Settings) will be used if appropriate. +Use that to get a 800x600 resolution and have a KMS compatible card. +ENDTEXT + +LABEL rescue32_6 +MENU LABEL 6. Boot an existing Linux OS installed on the disk +LINUX rescue32 +INITRD initram.igz +APPEND root=auto +TEXT HELP +Detect partition where linux is installed and boot from it. You can use +this to boot Linux if your boot loader (eg: Grub) is broken or has been +removed by another OS. +ENDTEXT + +LABEL rescue32_7 +MENU LABEL 7. SystemRescueCd with the default graphical environment +LINUX rescue32 +INITRD initram.igz +APPEND dostartx +TEXT HELP +Boot standard 32bit kernel and start the XFCE graphical environment +directly. You can also get in this environment by typing "startx" from +the console. +ENDTEXT + +LABEL rescue32_8 +MENU LABEL 8. SystemRescueCd with VESA based graphical environment +LINUX rescue32 +INITRD initram.igz +APPEND nomodeset vga=791 dostartx forcevesa +TEXT HELP +Boot standard 32bit kernel and use VESA based graphical environment +Try this if you have problems to get the default graphical environment +ENDTEXT + +MENU SEPARATOR + +LABEL return +MENU LABEL Return to main menu +MENU EXIT + +MENU END + +# ------------------------------------------------------------------------------ + +MENU BEGIN +MENU TITLE C) Standard 64bit kernel (rescue64) with more choice... + +LABEL rescue64_1 +MENU LABEL 1. SystemRescueCd with default options +LINUX rescue64 +INITRD initram.igz +TEXT HELP +Boot standard 64bit kernel with default options (should always work) +ENDTEXT + +LABEL rescue64_2 +MENU LABEL 2. SystemRescueCd with all files cached to memory +LINUX rescue64 +INITRD initram.igz +APPEND docache +TEXT HELP +Boot standard 64bit kernel and run system from RAM (cdrom can be removed) +It requires 512 MB of memory to work and takes some time during the +boot process, but the cdrom can be removed and system will be faster. +ENDTEXT + +LABEL rescue64_3 +MENU LABEL 3. SystemRescueCd with console in high resolution (1024x768) +LINUX rescue64 +INITRD initram.igz +APPEND nomodeset vga=791 +TEXT HELP +Boot standard 64bit kernel with framebuffer console in high resolution +KMS graphic drivers (Kernel-Mode-Settings) will be disabled. +ENDTEXT + +LABEL rescue64_4 +MENU LABEL 4. SystemRescueCd with a standard VGA console (no KMS) +LINUX rescue64 +INITRD initram.igz +APPEND nomodeset +TEXT HELP +Boot standard 64bit kernel and use standard low-resolution VGA console +KMS graphic drivers (Kernel-Mode-Settings) will be disabled. +Try this if you can't get a working console or new a low-resolution mode +ENDTEXT + +LABEL rescue64_5 +MENU LABEL 5. SystemRescueCd with a console in 800x600 +LINUX rescue64 +INITRD initram.igz +APPEND video=800x600 +TEXT HELP +Boot standard 64bit kernel and use the default graphic driver in 800x600 +KMS graphic drivers (Kernel-Mode-Settings) will be used if appropriate. +Use that to get a 800x600 resolution and have a KMS compatible card. +ENDTEXT + +LABEL rescue64_6 +MENU LABEL 6. Boot an existing Linux OS installed on the disk +LINUX rescue64 +INITRD initram.igz +APPEND root=auto +TEXT HELP +Detect partition where linux is installed and boot from it. You can use +this to boot Linux if your boot loader (eg: Grub) is broken or has been +removed by another OS. +ENDTEXT + +LABEL rescue64_7 +MENU LABEL 7. SystemRescueCd with the default graphical environment +LINUX rescue64 +INITRD initram.igz +APPEND dostartx +TEXT HELP +Boot standard 64bit kernel and start the XFCE graphical environment +directly. You can also get in this environment by typing "startx" from +the console. +ENDTEXT + +LABEL rescue64_8 +MENU LABEL 8. SystemRescueCd with VESA based graphical environment +LINUX rescue64 +INITRD initram.igz +APPEND nomodeset vga=791 dostartx forcevesa +TEXT HELP +Boot standard 64bit kernel and use VESA based graphical environment +Try this if you have problems to get the default graphical environment +ENDTEXT + +MENU SEPARATOR + +LABEL return +MENU LABEL Return to main menu +MENU EXIT + +MENU END + +# ------------------------------------------------------------------------------ + +MENU SEPARATOR + +LABEL local1 +MENU LABEL *) Boot from first hard disk +kernel chain.c32 +append hd0 +TEXT HELP +Boot local OS installed on first hard disk +ENDTEXT + +LABEL local2 +MENU LABEL *) Boot from second hard disk +kernel chain.c32 +append hd1 +TEXT HELP +Boot local OS installed on second hard disk +ENDTEXT + +LABEL rescuecd +MENU HIDE +KERNEL ifcpu64.c32 +APPEND rescue64 -- rescue32 + +LABEL rescue32 +MENU HIDE +LINUX rescue32 +INITRD initram.igz + +LABEL rescue64 +MENU HIDE +LINUX rescue64 +INITRD initram.igz + +LABEL altker32 +MENU HIDE +LINUX altker32 +INITRD initram.igz + +LABEL altker64 +MENU HIDE +LINUX altker64 +INITRD initram.igz + +LABEL azerty +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/azerty.ktl +LABEL be +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/be.ktl +LABEL bg +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/bg.ktl +LABEL by +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/by.ktl +LABEL cf +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/cf.ktl +LABEL croat +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/croat.ktl +LABEL cz +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/cz.ktl +LABEL de +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/de.ktl +LABEL dk +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/dk.ktl +LABEL dvorak +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/dvorak.ktl +LABEL es +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/es.ktl +LABEL et +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/et.ktl +LABEL fi +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/fi.ktl +LABEL fr_CH +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/fr_CH.ktl +LABEL fr +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/fr.ktl +LABEL gr +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/gr.ktl +LABEL hu +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/hu.ktl +LABEL il +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/il.ktl +LABEL it +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/it.ktl +LABEL lt +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/lt.ktl +LABEL mk +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/mk.ktl +LABEL nl +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/nl.ktl +LABEL no +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/no.ktl +LABEL pl +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/pl.ktl +LABEL ru +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/ru.ktl +LABEL sg +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/sg.ktl +LABEL slovene +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/slovene.ktl +LABEL trf +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/trf.ktl +LABEL trq +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/trq.ktl +LABEL ua +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/ua.ktl +LABEL uk +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/uk.ktl +LABEL us +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/us.ktl +LABEL wangbe +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/wangbe.ktl diff --git a/customcd/isoroot/isolinux/isolinux.cfg.pxeclient b/customcd/isoroot/isolinux/isolinux.cfg.pxeclient new file mode 100644 index 0000000..dab3518 --- /dev/null +++ b/customcd/isoroot/isolinux/isolinux.cfg.pxeclient @@ -0,0 +1,536 @@ +UI vesamenu.c32 +F2 f2images.msg +F3 f3params.msg +F4 f4arun.msg +F5 f5troubl.msg +F6 f6pxe.msg +F7 f7net.msg + +PROMPT 0 +TIMEOUT 300 +ONTIMEOUT rescuebru + +MENU DEFAULT rescuebru +MENU TABMSG Press to edit options or ,,,,, for help +MENU TITLE RescueBRU 7.2.5 (System Rescue CD 5.2.2 (www.sysresccd.org)) +MENU ROWS 16 +MENU TIMEOUTROW 22 +MENU TABMSGROW 24 +MENU CMDLINEROW 24 +MENU HELPMSGROW 26 +MENU WIDTH 78 +MENU MARGIN 6 +MENU BACKGROUND #FF003333 + +MENU color title 1;31;40 #FFFF0000 #00000000 std +MENU color sel 7;37;40 #FF000000 #FFC0C0C0 all +MENU color unsel 37;44 #FFFFFFFF #00000000 none +MENU color hotsel 1;7;37;40 #FF000000 #FFC0C0C0 all +MENU color tabmsg 1;31;40 #FFFFFF00 #00000000 std +MENU color help 1;31;40 #FFFFFFFF #00000000 none + +LABEL rescuebru + MENU LABEL 1) RescueBRU: Run Rescue CD Backup/Restore Utility + KERNEL ifcpu64.c32 + APPEND rescue64 scandelay=1 setkmap=us dostartx docache nolvm nodmraid lowmem nonm ar_nowait autoruns=3 netboot=http://10.111.1.1/sysrcd.dat -- rescue32 scandelay=1 setkmap=us dostartx docache nolvm nodmraid lowmem nonm ar_nowait autoruns=3 netboot=http://10.111.1.1/sysrcd.dat + TEXT HELP + Standard RescueBRU Client running in GUI environment. Caches all + files to memory and ejects the CD. + ENDTEXT + +LABEL rescuebru_txt + MENU LABEL 2) RescueBRU: Run Rescue CD Backup/Restore Utility (text mode) + KERNEL ifcpu64.c32 + APPEND rescue64 scandelay=1 setkmap=us docache nolvm nodmraid lowmem nonm ar_nowait autoruns=1 netboot=http://10.111.1.1/sysrcd.dat -- rescue32 scandelay=1 setkmap=us nolvm nodmraid lowmem nonm ar_nowait autoruns=1 netboot=http://10.111.1.1/sysrcd.dat + TEXT HELP + Text mode RescueBRU Client for systems with less than 1Gb + of memory or lack of graphics capability. Runs directly from CD. + CD will not eject after boot. Must remove CD manually after reboot. + ENDTEXT + +MENU SEPARATOR + +LABEL memtest + MENU LABEL 3) MEMTEST: Memory test using Memtest86+ + kernel /bootdisk/memtestp + append - + TEXT HELP + Use this tool if you suspect your RAM may be damaged. Damaged memory can + explain crashes or unexpected bahaviors on stable operating systems. + ENDTEXT + +LABEL ntpass + MENU LABEL 4) NTPASSWD: Reset or edit Windows passwords + kernel /ntpasswd/vmlinuz + append rw vga=1 initrd=/ntpasswd/initrd.cgz,/ntpasswd/scsi.cgz + TEXT HELP + This tool can be used to reset windows users accounts. It works will all + windows user accounts including the administrator. You can use this tool if + you forgot the administrator's password. + ENDTEXT + + LABEL dban + MENU LABEL 5) DBAN: erase all data from the disk + kernel /bootdisk/dban.bzi + append nuke="dwipe" silent + +LABEL rescuecd_auto + MENU LABEL 6) Boot an existing Linux system installed on the disk + KERNEL ifcpu64.c32 + APPEND rescue64 root=auto -- rescue32 root=auto + TEXT HELP + Detect partition where linux is installed and boot from it. You can use + this to boot Linux if your boot loader (eg: Grub) is broken or has been + removed by another OS. + ENDTEXT + +LABEL freedos + MENU LABEL 7) FREEDOS: Clone of the MSDOS Operating System + kernel memdisk + append initrd=/bootdisk/freedos.img floppy + TEXT HELP + FreeDOS can be used to execute DOS programs such as BIOS upgrade tools + ENDTEXT + +MENU SEPARATOR + +LABEL rescuecd_std + MENU LABEL 8) SystemRescueCd: default boot options + KERNEL ifcpu64.c32 + APPEND rescue64 scandelay=1 autoruns=no setkmap=us netboot=http://10.111.1.1/sysrcd.dat -- rescue32 scandelay=1 autoruns=no setkmap=us netboot=http://10.111.1.1/sysrcd.dat + TEXT HELP + Boot standard kernel with default options (should always work) + You should use this entry if you don't know which one to use + ENDTEXT + +LABEL rescuecd_791 + MENU LABEL 9) SystemRescueCd: console in high resolution (framebuffer) + KERNEL ifcpu64.c32 + APPEND rescue64 nomodeset vga=791 scandelay=1 autoruns=no setkmap=us netboot=http://10.111.1.1/sysrcd.dat -- rescue32 nomodeset vga=791 scandelay=1 autoruns=no setkmap=us netboot=http://10.111.1.1/sysrcd.dat + TEXT HELP + Boot standard kernel with console in high resolution + This mode is useful only if you want to work in console mode + ENDTEXT + +LABEL rescuecd_us + MENU LABEL 10) SystemRescueCd: do not ask for keyboard, use US keymap + KERNEL ifcpu64.c32 + APPEND rescue64 scandelay=1 setkmap=us autoruns=no netboot=http://10.111.1.1/sysrcd.dat -- rescue32 scandelay=1 setkmap=us autoruns=no netboot=http://10.111.1.1/sysrcd.dat + TEXT HELP + Boot standard kernel and use the keymap for american keyboards + This way it will not prompt for the keymap during the boot process + ENDTEXT + +LABEL rescuecd_xorg + MENU LABEL 11) SystemRescueCd: directly start the graphical environment + KERNEL ifcpu64.c32 + APPEND rescue64 scandelay=1 dostartx autoruns=no setkmap=us netboot=http://10.111.1.1/sysrcd.dat -- rescue32 scandelay=1 dostartx autoruns=no setkmap=us netboot=http://10.111.1.1/sysrcd.dat + TEXT HELP + Boot standard kernel and start the XFCE graphical environment + directly. You can also get in this environment by typing "startx" from + the console. + ENDTEXT + +MENU SEPARATOR + +# ------------------------------------------------------------------------------ + +MENU BEGIN +MENU TITLE A) Run system tools from floppy disk image... + +LABEL grubdisk +MENU LABEL SGD: Super Grub2 Disk +kernel memdisk +append initrd=/bootdisk/grubdisk.img floppy raw + +LABEL netboot +MENU LABEL NETBOOT: Boot from the network +kernel netboot +append - + +LABEL hdt +MENU LABEL HDT: recent hardware diagnostics tool +kernel memdisk +append initrd=/bootdisk/hdt.img floppy +TEXT HELP +This diagnostic tool will give you information about your hardware +ENDTEXT + +LABEL aida +MENU LABEL AIDA: old hardware diagnostics tool +kernel memdisk +append initrd=/bootdisk/aida.img floppy + +LABEL mhdd +MENU LABEL MHDD: Low-level Hard Drive diagnostic tool +kernel memdisk +append initrd=/bootdisk/mhdd.img floppy + +MENU SEPARATOR + +LABEL return +MENU LABEL Return to main menu +MENU EXIT + +MENU END + +# ------------------------------------------------------------------------------ + +MENU BEGIN +MENU TITLE B) Standard 32bit kernel (rescue32) with more choice... + +LABEL rescue32_1 +MENU LABEL 1. SystemRescueCd with default options +LINUX rescue32 +INITRD initram.igz +APPEND scandelay=1 autoruns=no setkmap=us netboot=http://10.111.1.1/sysrcd.dat +TEXT HELP +Boot standard 32bit kernel with default options (should always work) +ENDTEXT + +LABEL rescue32_3 +MENU LABEL 3. SystemRescueCd with console in high resolution (1024x768) +LINUX rescue32 +INITRD initram.igz +APPEND nomodeset vga=791 autoruns=no setkmap=us netboot=http://10.111.1.1/sysrcd.dat +TEXT HELP +Boot standard 32bit kernel with framebuffer console in high resolution +KMS graphic drivers (Kernel-Mode-Settings) will be disabled. +ENDTEXT + +LABEL rescue32_4 +MENU LABEL 4. SystemRescueCd with a standard VGA console (no KMS) +LINUX rescue32 +INITRD initram.igz +APPEND nomodeset autoruns=no setkmap=us netboot=http://10.111.1.1/sysrcd.dat +TEXT HELP +Boot standard 32bit kernel and use standard low-resolution VGA console +KMS graphic drivers (Kernel-Mode-Settings) will be disabled. +Try this if you can't get a working console or new a low-resolution mode +ENDTEXT + +LABEL rescue32_5 +MENU LABEL 5. SystemRescueCd with a console in 800x600 +LINUX rescue32 +INITRD initram.igz +APPEND video=800x600 autoruns=no setkmap=us netboot=http://10.111.1.1/sysrcd.dat +TEXT HELP +Boot standard 32bit kernel and use the default graphic driver in 800x600 +KMS graphic drivers (Kernel-Mode-Settings) will be used if appropriate. +Use that to get a 800x600 resolution and have a KMS compatible card. +ENDTEXT + +LABEL rescue32_6 +MENU LABEL 6. Boot an existing Linux OS installed on the disk +LINUX rescue32 +INITRD initram.igz +APPEND root=auto +TEXT HELP +Detect partition where linux is installed and boot from it. You can use +this to boot Linux if your boot loader (eg: Grub) is broken or has been +removed by another OS. +ENDTEXT + +LABEL rescue32_7 +MENU LABEL 7. SystemRescueCd with the default graphical environment +LINUX rescue32 +INITRD initram.igz +APPEND dostartx autoruns=no setkmap=us netboot=http://10.111.1.1/sysrcd.dat +TEXT HELP +Boot standard 32bit kernel and start the XFCE graphical environment +directly. You can also get in this environment by typing "startx" from +the console. +ENDTEXT + +LABEL rescue32_8 +MENU LABEL 8. SystemRescueCd with VESA based graphical environment +LINUX rescue32 +INITRD initram.igz +APPEND nomodeset vga=791 dostartx forcevesa autoruns=no setkmap=us netboot=http://10.111.1.1/sysrcd.dat +TEXT HELP +Boot standard 32bit kernel and use VESA based graphical environment +Try this if you have problems to get the default graphical environment +ENDTEXT + +MENU SEPARATOR + +LABEL return +MENU LABEL Return to main menu +MENU EXIT + +MENU END + +# ------------------------------------------------------------------------------ + +MENU BEGIN +MENU TITLE C) Standard 64bit kernel (rescue64) with more choice... + +LABEL rescue64_1 +MENU LABEL 1. SystemRescueCd with default options +LINUX rescue64 +INITRD initram.igz +APPEND autoruns=no setkmap=us netboot=http://10.111.1.1/sysrcd.dat +TEXT HELP +Boot standard 64bit kernel with default options (should always work) +ENDTEXT + +LABEL rescue64_2 +MENU LABEL 2. SystemRescueCd with all files cached to memory +LINUX rescue64 +INITRD initram.igz +APPEND docache autoruns=no setkmap=us netboot=http://10.111.1.1/sysrcd.dat +TEXT HELP +Boot standard 64bit kernel and run system from RAM (cdrom can be removed) +It requires 512 MB of memory to work and takes some time during the +boot process, but the cdrom can be removed and system will be faster. +ENDTEXT + +LABEL rescue64_3 +MENU LABEL 3. SystemRescueCd with console in high resolution (1024x768) +LINUX rescue64 +INITRD initram.igz +APPEND nomodeset vga=791 autoruns=no setkmap=us netboot=http://10.111.1.1/sysrcd.dat +TEXT HELP +Boot standard 64bit kernel with framebuffer console in high resolution +KMS graphic drivers (Kernel-Mode-Settings) will be disabled. +ENDTEXT + +LABEL rescue64_4 +MENU LABEL 4. SystemRescueCd with a standard VGA console (no KMS) +LINUX rescue64 +INITRD initram.igz +APPEND nomodeset autoruns=no setkmap=us netboot=http://10.111.1.1/sysrcd.dat +TEXT HELP +Boot standard 64bit kernel and use standard low-resolution VGA console +KMS graphic drivers (Kernel-Mode-Settings) will be disabled. +Try this if you can't get a working console or new a low-resolution mode +ENDTEXT + +LABEL rescue64_5 +MENU LABEL 5. SystemRescueCd with a console in 800x600 +LINUX rescue64 +INITRD initram.igz +APPEND video=800x600 autoruns=no setkmap=us netboot=http://10.111.1.1/sysrcd.dat +TEXT HELP +Boot standard 64bit kernel and use the default graphic driver in 800x600 +KMS graphic drivers (Kernel-Mode-Settings) will be used if appropriate. +Use that to get a 800x600 resolution and have a KMS compatible card. +ENDTEXT + +LABEL rescue64_6 +MENU LABEL 6. Boot an existing Linux OS installed on the disk +LINUX rescue64 +INITRD initram.igz +APPEND root=auto +TEXT HELP +Detect partition where linux is installed and boot from it. You can use +this to boot Linux if your boot loader (eg: Grub) is broken or has been +removed by another OS. +ENDTEXT + +LABEL rescue64_7 +MENU LABEL 7. SystemRescueCd with the default graphical environment +LINUX rescue64 +INITRD initram.igz +APPEND dostartx autoruns=no setkmap=us netboot=http://10.111.1.1/sysrcd.dat +TEXT HELP +Boot standard 64bit kernel and start the XFCE graphical environment +directly. You can also get in this environment by typing "startx" from +the console. +ENDTEXT + +LABEL rescue64_8 +MENU LABEL 8. SystemRescueCd with VESA based graphical environment +LINUX rescue64 +INITRD initram.igz +APPEND nomodeset vga=791 dostartx forcevesa autoruns=no setkmap=us netboot=http://10.111.1.1/sysrcd.dat +TEXT HELP +Boot standard 64bit kernel and use VESA based graphical environment +Try this if you have problems to get the default graphical environment +ENDTEXT + +MENU SEPARATOR + +LABEL return +MENU LABEL Return to main menu +MENU EXIT + +MENU END + +# ------------------------------------------------------------------------------ + +MENU SEPARATOR + +LABEL local1 +MENU LABEL *) Boot from first hard disk +kernel chain.c32 +append hd0 +TEXT HELP +Boot local OS installed on first hard disk +ENDTEXT + +LABEL local2 +MENU LABEL *) Boot from second hard disk +kernel chain.c32 +append hd1 +TEXT HELP +Boot local OS installed on second hard disk +ENDTEXT + +LABEL rescuecd +MENU HIDE +KERNEL ifcpu64.c32 +APPEND rescue64 -- rescue32 + +LABEL rescue32 +MENU HIDE +LINUX rescue32 +INITRD initram.igz + +LABEL rescue64 +MENU HIDE +LINUX rescue64 +INITRD initram.igz + +LABEL altker32 +MENU HIDE +LINUX altker32 +INITRD initram.igz + +LABEL altker64 +MENU HIDE +LINUX altker64 +INITRD initram.igz + +LABEL azerty +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/azerty.ktl +LABEL be +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/be.ktl +LABEL bg +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/bg.ktl +LABEL by +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/by.ktl +LABEL cf +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/cf.ktl +LABEL croat +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/croat.ktl +LABEL cz +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/cz.ktl +LABEL de +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/de.ktl +LABEL dk +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/dk.ktl +LABEL dvorak +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/dvorak.ktl +LABEL es +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/es.ktl +LABEL et +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/et.ktl +LABEL fi +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/fi.ktl +LABEL fr_CH +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/fr_CH.ktl +LABEL fr +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/fr.ktl +LABEL gr +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/gr.ktl +LABEL hu +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/hu.ktl +LABEL il +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/il.ktl +LABEL it +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/it.ktl +LABEL lt +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/lt.ktl +LABEL mk +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/mk.ktl +LABEL nl +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/nl.ktl +LABEL no +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/no.ktl +LABEL pl +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/pl.ktl +LABEL ru +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/ru.ktl +LABEL sg +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/sg.ktl +LABEL slovene +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/slovene.ktl +LABEL trf +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/trf.ktl +LABEL trq +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/trq.ktl +LABEL ua +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/ua.ktl +LABEL uk +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/uk.ktl +LABEL us +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/us.ktl +LABEL wangbe +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/wangbe.ktl diff --git a/customcd/isoroot/isolinux/isolinux.cfg.server b/customcd/isoroot/isolinux/isolinux.cfg.server new file mode 100644 index 0000000..b8e790b --- /dev/null +++ b/customcd/isoroot/isolinux/isolinux.cfg.server @@ -0,0 +1,564 @@ +UI vesamenu.c32 +F2 f2images.msg +F3 f3params.msg +F4 f4arun.msg +F5 f5troubl.msg +F6 f6pxe.msg +F7 f7net.msg + +PROMPT 0 +TIMEOUT 50 +ONTIMEOUT rbruserver + +MENU DEFAULT rbruserver +MENU TABMSG Press to edit options or ,,,,, for help +MENU TITLE RescueBRU 7.2.5 (System Rescue CD 5.2.2 (www.sysresccd.org)) +MENU ROWS 16 +MENU TIMEOUTROW 22 +MENU TABMSGROW 24 +MENU CMDLINEROW 24 +MENU HELPMSGROW 26 +MENU WIDTH 78 +MENU MARGIN 6 +MENU BACKGROUND #FF003333 + +MENU color title 1;31;40 #FFFF0000 #00000000 std +MENU color sel 7;37;40 #FF000000 #FFC0C0C0 all +MENU color unsel 37;44 #FFFFFFFF #00000000 none +MENU color hotsel 1;7;37;40 #FF000000 #FFC0C0C0 all +MENU color tabmsg 1;31;40 #FFFFFF00 #00000000 std +MENU color help 1;31;40 #FFFFFFFF #00000000 none + +LABEL rescuebru + MENU LABEL 1) RescueBRU: Run Rescue CD Backup/Restore Utility + KERNEL ifcpu64.c32 + APPEND rescue64 scandelay=1 setkmap=us dostartx docache nolvm nodhcp nodmraid lowmem nonm ar_nowait autoruns=3 -- rescue32 scandelay=1 setkmap=us dostartx docache nolvm nodhcp nodmraid lowmem nonm ar_nowait autoruns=3 + TEXT HELP + Standard RescueBRU Client running in GUI environment. Caches all + files to memory and ejects the CD. + ENDTEXT + +LABEL rescuebru_txt + MENU LABEL 2) RescueBRU: Run Rescue CD Backup/Restore Utility (text mode) + KERNEL ifcpu64.c32 + APPEND rescue64 scandelay=1 setkmap=us nolvm nodhcp nodmraid lowmem nonm ar_nowait autoruns=1 -- rescue32 scandelay=1 setkmap=us nolvm nodhcp nodmraid lowmem nonm ar_nowait autoruns=1 + TEXT HELP + Text mode RescueBRU Client for systems with less than 1Gb + of memory or lack of graphics capability. Runs directly from CD. + CD will not eject after boot. Must remove CD manually after reboot. + ENDTEXT + +LABEL rbruserver + MENU LABEL 3) RescueBRU Server: Run Rescue CD Backup/Restore Server + KERNEL ifcpu64.c32 + APPEND rescue64 scandelay=1 setkmap=us dostartx nolvm nodhcp nodmraid nonm ar_nowait autoruns=2 -- rescue32 scandelay=1 setkmap=us dostartx nolvm nodhcp nodmraid nonm ar_nowait autoruns=2 + TEXT HELP + Automatically start RescueBRU Server.Runs directly from CD. + CD will not eject after boot. Must remove CD manually after reboot. + ENDTEXT + +MENU SEPARATOR + +LABEL memtest + MENU LABEL 4) MEMTEST: Memory test using Memtest86+ + kernel /bootdisk/memtestp + append - + TEXT HELP + Use this tool if you suspect your RAM may be damaged. Damaged memory can + explain crashes or unexpected bahaviors on stable operating systems. + ENDTEXT + +LABEL ntpass + MENU LABEL 5) NTPASSWD: Reset or edit Windows passwords + kernel /ntpasswd/vmlinuz + append rw vga=1 initrd=/ntpasswd/initrd.cgz,/ntpasswd/scsi.cgz + TEXT HELP + This tool can be used to reset windows users accounts. It works will all + windows user accounts including the administrator. You can use this tool if + you forgot the administrator's password. + ENDTEXT + +LABEL dban + MENU LABEL 6) DBAN: erase all data from the disk + kernel /bootdisk/dban.bzi + append nuke="dwipe" silent + +LABEL rescuecd_auto + MENU LABEL 7) Boot an existing Linux system installed on the disk + KERNEL ifcpu64.c32 + APPEND rescue64 root=auto -- rescue32 root=auto + TEXT HELP + Detect partition where linux is installed and boot from it. You can use + this to boot Linux if your boot loader (eg: Grub) is broken or has been + removed by another OS. + ENDTEXT + +LABEL freedos + MENU LABEL 8) FREEDOS: Clone of the MSDOS Operating System + kernel memdisk + append initrd=/bootdisk/freedos.img floppy + TEXT HELP + FreeDOS can be used to execute DOS programs such as BIOS upgrade tools + ENDTEXT + +MENU SEPARATOR + +LABEL rescuecd_std + MENU LABEL 9) SystemRescueCd: default boot options + KERNEL ifcpu64.c32 + APPEND rescue64 scandelay=1 autoruns=no setkmap=us -- rescue32 scandelay=1 autoruns=no setkmap=us + TEXT HELP + Boot standard kernel with default options (should always work) + You should use this entry if you don't know which one to use + ENDTEXT + +LABEL rescuecd_docache + MENU LABEL 10) SystemRescueCd: all files cached to memory (docache) + KERNEL ifcpu64.c32 + APPEND rescue64 scandelay=1 autoruns=no setkmap=us docache -- rescue32 scandelay=1 autoruns=no setkmap=us docache + TEXT HELP + Boot standard kernel and run system from RAM (cdrom can be removed) + It requires 512 MB of memory to work and takes some time during the + boot process, but the cdrom can be removed and system will be faster. + ENDTEXT + +LABEL rescuecd_791 + MENU LABEL 11) SystemRescueCd: console in high resolution (framebuffer) + KERNEL ifcpu64.c32 + APPEND rescue64 nomodeset vga=791 scandelay=1 autoruns=no setkmap=us -- rescue32 nomodeset vga=791 scandelay=1 autoruns=no setkmap=us + TEXT HELP + Boot standard kernel with console in high resolution + This mode is useful only if you want to work in console mode + ENDTEXT + +LABEL rescuecd_us + MENU LABEL 12) SystemRescueCd: do not ask for keyboard, use US keymap + KERNEL ifcpu64.c32 + APPEND rescue64 scandelay=1 setkmap=us autoruns=no -- rescue32 scandelay=1 setkmap=us autoruns=no + TEXT HELP + Boot standard kernel and use the keymap for american keyboards + This way it will not prompt for the keymap during the boot process + ENDTEXT + +LABEL rescuecd_xorg + MENU LABEL 13) SystemRescueCd: directly start the graphical environment + KERNEL ifcpu64.c32 + APPEND rescue64 scandelay=1 dostartx autoruns=no setkmap=us -- rescue32 scandelay=1 dostartx autoruns=no setkmap=us + TEXT HELP + Boot standard kernel and start the XFCE graphical environment + directly. You can also get in this environment by typing "startx" from + the console. + ENDTEXT + +MENU SEPARATOR + +# ------------------------------------------------------------------------------ + +MENU BEGIN +MENU TITLE A) Run system tools from floppy disk image... + +LABEL grubdisk +MENU LABEL SGD: Super Grub2 Disk +kernel memdisk +append initrd=/bootdisk/grubdisk.img floppy raw + +LABEL netboot +MENU LABEL NETBOOT: Boot from the network +kernel netboot +append - + +LABEL hdt +MENU LABEL HDT: recent hardware diagnostics tool +kernel memdisk +append initrd=/bootdisk/hdt.img floppy +TEXT HELP +This diagnostic tool will give you information about your hardware +ENDTEXT + +LABEL aida +MENU LABEL AIDA: old hardware diagnostics tool +kernel memdisk +append initrd=/bootdisk/aida.img floppy + +LABEL mhdd +MENU LABEL MHDD: Low-level Hard Drive diagnostic tool +kernel memdisk +append initrd=/bootdisk/mhdd.img floppy + +MENU SEPARATOR + +LABEL return +MENU LABEL Return to main menu +MENU EXIT + +MENU END + +# ------------------------------------------------------------------------------ + +MENU BEGIN +MENU TITLE B) Standard 32bit kernel (rescue32) with more choice... + +LABEL rescue32_1 +MENU LABEL 1. SystemRescueCd with default options +LINUX rescue32 +INITRD initram.igz +TEXT HELP +Boot standard 32bit kernel with default options (should always work) +ENDTEXT + +LABEL rescue32_2 +MENU LABEL 2. SystemRescueCd with all files cached to memory +LINUX rescue32 +INITRD initram.igz +APPEND docache +TEXT HELP +Boot standard 32bit kernel and run system from memory. +It requires 512 MB of memory to work and takes some time during the +boot process, but the cdrom can be removed and system will be faster. +ENDTEXT + +LABEL rescue32_3 +MENU LABEL 3. SystemRescueCd with console in high resolution (1024x768) +LINUX rescue32 +INITRD initram.igz +APPEND nomodeset vga=791 +TEXT HELP +Boot standard 32bit kernel with framebuffer console in high resolution +KMS graphic drivers (Kernel-Mode-Settings) will be disabled. +ENDTEXT + +LABEL rescue32_4 +MENU LABEL 4. SystemRescueCd with a standard VGA console (no KMS) +LINUX rescue32 +INITRD initram.igz +APPEND nomodeset +TEXT HELP +Boot standard 32bit kernel and use standard low-resolution VGA console +KMS graphic drivers (Kernel-Mode-Settings) will be disabled. +Try this if you can't get a working console or new a low-resolution mode +ENDTEXT + +LABEL rescue32_5 +MENU LABEL 5. SystemRescueCd with a console in 800x600 +LINUX rescue32 +INITRD initram.igz +APPEND video=800x600 +TEXT HELP +Boot standard 32bit kernel and use the default graphic driver in 800x600 +KMS graphic drivers (Kernel-Mode-Settings) will be used if appropriate. +Use that to get a 800x600 resolution and have a KMS compatible card. +ENDTEXT + +LABEL rescue32_6 +MENU LABEL 6. Boot an existing Linux OS installed on the disk +LINUX rescue32 +INITRD initram.igz +APPEND root=auto +TEXT HELP +Detect partition where linux is installed and boot from it. You can use +this to boot Linux if your boot loader (eg: Grub) is broken or has been +removed by another OS. +ENDTEXT + +LABEL rescue32_7 +MENU LABEL 7. SystemRescueCd with the default graphical environment +LINUX rescue32 +INITRD initram.igz +APPEND dostartx +TEXT HELP +Boot standard 32bit kernel and start the XFCE graphical environment +directly. You can also get in this environment by typing "startx" from +the console. +ENDTEXT + +LABEL rescue32_8 +MENU LABEL 8. SystemRescueCd with VESA based graphical environment +LINUX rescue32 +INITRD initram.igz +APPEND nomodeset vga=791 dostartx forcevesa +TEXT HELP +Boot standard 32bit kernel and use VESA based graphical environment +Try this if you have problems to get the default graphical environment +ENDTEXT + +MENU SEPARATOR + +LABEL return +MENU LABEL Return to main menu +MENU EXIT + +MENU END + +# ------------------------------------------------------------------------------ + +MENU BEGIN +MENU TITLE C) Standard 64bit kernel (rescue64) with more choice... + +LABEL rescue64_1 +MENU LABEL 1. SystemRescueCd with default options +LINUX rescue64 +INITRD initram.igz +TEXT HELP +Boot standard 64bit kernel with default options (should always work) +ENDTEXT + +LABEL rescue64_2 +MENU LABEL 2. SystemRescueCd with all files cached to memory +LINUX rescue64 +INITRD initram.igz +APPEND docache +TEXT HELP +Boot standard 64bit kernel and run system from RAM (cdrom can be removed) +It requires 512 MB of memory to work and takes some time during the +boot process, but the cdrom can be removed and system will be faster. +ENDTEXT + +LABEL rescue64_3 +MENU LABEL 3. SystemRescueCd with console in high resolution (1024x768) +LINUX rescue64 +INITRD initram.igz +APPEND nomodeset vga=791 +TEXT HELP +Boot standard 64bit kernel with framebuffer console in high resolution +KMS graphic drivers (Kernel-Mode-Settings) will be disabled. +ENDTEXT + +LABEL rescue64_4 +MENU LABEL 4. SystemRescueCd with a standard VGA console (no KMS) +LINUX rescue64 +INITRD initram.igz +APPEND nomodeset +TEXT HELP +Boot standard 64bit kernel and use standard low-resolution VGA console +KMS graphic drivers (Kernel-Mode-Settings) will be disabled. +Try this if you can't get a working console or new a low-resolution mode +ENDTEXT + +LABEL rescue64_5 +MENU LABEL 5. SystemRescueCd with a console in 800x600 +LINUX rescue64 +INITRD initram.igz +APPEND video=800x600 +TEXT HELP +Boot standard 64bit kernel and use the default graphic driver in 800x600 +KMS graphic drivers (Kernel-Mode-Settings) will be used if appropriate. +Use that to get a 800x600 resolution and have a KMS compatible card. +ENDTEXT + +LABEL rescue64_6 +MENU LABEL 6. Boot an existing Linux OS installed on the disk +LINUX rescue64 +INITRD initram.igz +APPEND root=auto +TEXT HELP +Detect partition where linux is installed and boot from it. You can use +this to boot Linux if your boot loader (eg: Grub) is broken or has been +removed by another OS. +ENDTEXT + +LABEL rescue64_7 +MENU LABEL 7. SystemRescueCd with the default graphical environment +LINUX rescue64 +INITRD initram.igz +APPEND dostartx +TEXT HELP +Boot standard 64bit kernel and start the XFCE graphical environment +directly. You can also get in this environment by typing "startx" from +the console. +ENDTEXT + +LABEL rescue64_8 +MENU LABEL 8. SystemRescueCd with VESA based graphical environment +LINUX rescue64 +INITRD initram.igz +APPEND nomodeset vga=791 dostartx forcevesa +TEXT HELP +Boot standard 64bit kernel and use VESA based graphical environment +Try this if you have problems to get the default graphical environment +ENDTEXT + +MENU SEPARATOR + +LABEL return +MENU LABEL Return to main menu +MENU EXIT + +MENU END + +# ------------------------------------------------------------------------------ + +MENU SEPARATOR + +LABEL local1 +MENU LABEL *) Boot from first hard disk +kernel chain.c32 +append hd0 +TEXT HELP +Boot local OS installed on first hard disk +ENDTEXT + +LABEL local2 +MENU LABEL *) Boot from second hard disk +kernel chain.c32 +append hd1 +TEXT HELP +Boot local OS installed on second hard disk +ENDTEXT + +LABEL rescuecd +MENU HIDE +KERNEL ifcpu64.c32 +APPEND rescue64 -- rescue32 + +LABEL rescue32 +MENU HIDE +LINUX rescue32 +INITRD initram.igz + +LABEL rescue64 +MENU HIDE +LINUX rescue64 +INITRD initram.igz + +LABEL altker32 +MENU HIDE +LINUX altker32 +INITRD initram.igz + +LABEL altker64 +MENU HIDE +LINUX altker64 +INITRD initram.igz + +LABEL azerty +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/azerty.ktl +LABEL be +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/be.ktl +LABEL bg +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/bg.ktl +LABEL by +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/by.ktl +LABEL cf +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/cf.ktl +LABEL croat +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/croat.ktl +LABEL cz +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/cz.ktl +LABEL de +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/de.ktl +LABEL dk +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/dk.ktl +LABEL dvorak +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/dvorak.ktl +LABEL es +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/es.ktl +LABEL et +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/et.ktl +LABEL fi +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/fi.ktl +LABEL fr_CH +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/fr_CH.ktl +LABEL fr +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/fr.ktl +LABEL gr +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/gr.ktl +LABEL hu +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/hu.ktl +LABEL il +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/il.ktl +LABEL it +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/it.ktl +LABEL lt +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/lt.ktl +LABEL mk +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/mk.ktl +LABEL nl +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/nl.ktl +LABEL no +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/no.ktl +LABEL pl +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/pl.ktl +LABEL ru +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/ru.ktl +LABEL sg +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/sg.ktl +LABEL slovene +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/slovene.ktl +LABEL trf +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/trf.ktl +LABEL trq +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/trq.ktl +LABEL ua +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/ua.ktl +LABEL uk +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/uk.ktl +LABEL us +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/us.ktl +LABEL wangbe +MENU HIDE +KERNEL kbdmap.c32 +APPEND maps/wangbe.ktl