Initial commit

This commit is contained in:
2026-03-03 19:53:38 -05:00
parent 64e854364b
commit bfd1006698
82 changed files with 9540 additions and 0 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1 @@
7.2.5

View File

@@ -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

View File

@@ -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 dont have a dedicated
RescueBRU Server running, youll 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.

View File

@@ -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 <target>"
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 $?

View File

@@ -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 <source> <destination>"
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 $?

View File

@@ -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

View File

@@ -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 <Esc> to abort or <Enter> 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
}

View File

@@ -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 <Save> or <Cancel> 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

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

File diff suppressed because it is too large Load Diff

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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 &

View File

@@ -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 &

View File

@@ -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

View File

@@ -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

View File

@@ -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, <asyd@debian-fr.org>
# 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

View File

@@ -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, <asyd@debian-fr.org>
# 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