#!/bin/bash # rbruserver.sh # Rescue CD Backup & Restore Utility Server Script # version 7.2.5 # Rod Wright 1/19/2024 # Refer to CHANGELOG file for details. # ----------------------------------------------------------------------------- PROG_NAME="rbruserver.sh" PROG_VERSION=7.2.5 RBRU_INSTALL_PATH="/root/rescuebru" source $RBRU_INSTALL_PATH/functions.sh RAID_MEMBERS="" RAID_MNT_PT="/mnt/rescuebru" IMAGE_PATH="$RAID_MNT_PT/rescuebru-backups" NET_ADDR="10.111." EXPRT_ARGS="*(rw,no_root_squash,no_subtree_check,fsid=1)" SVR_STAT=0 PXE_STAT=0 NET_STAT=0 LOGGING_ENABLED=0 CLIENT_NET_STATUS=0 NOTES_TEMPLATE=$RAID_MNT_PT/notes_template.txt TRUE=1 FALSE=0 function editnotestemplate { # Edit the template for notes where rescuebru client expects it templatetext=`mktemp -q` touch $NOTES_TEMPLATE if dialog --title "Notes Template" \ --backtitle "Edit template then Tab to or and press enter." \ --ok-label "Save" \ --editbox $NOTES_TEMPLATE 20 80 2>$templatetext ; then cp -f $templatetext $NOTES_TEMPLATE else pause "Couldn't edit notes template." rm -f $templatetext fi } function clientstatus { # show connected clients and their status if client_files=`ls $RAID_MNT_PT/10.* 2>/dev/null` ; then cstmp=`mktemp -q` for cfname in $client_files; do # see if the client still responds client_addr=`basename $cfname` if ! ping -q -c3 $client_addr 1>/dev/null 2>&1 ; then echo "$client_addr is allocated but not responding. Mark file will be removed on next server stop.">>$cstmp else echo "$client_addr `cat $cfname`">>$cstmp fi done dialog --title "Client Status" --aspect 80 --msgbox "$(cat $cstmp)" 0 0 else inform "No connected clients." fi rm -f $cstmp return 0 } function raidtest { # Show RAID status # Takes one argument, the string "inform" or "pause" that determines if it waits for acknowledgement $1 "`mdadm -D $raid_dev |awk '/\/dev\/md|Array Size|Dev Size|Devices|State|\/dev\/sd|\/dev\/nvme/ {print}'`" "6" return 0 } function mainmenu { # Show the main menu mmtemp=`mktemp -q` if [ "$SVR_STAT" = 0 ]; then svr_stat_txt="Start server" else svr_stat_txt="Stop Server" fi if [ "$PXE_STAT" = 0 ]; then pxe_stat_txt="Start the PXE boot server" else pxe_stat_txt="Stop the PXE boot server" fi dialog --clear --no-cancel \ --title "RescueBRU Server Main Menu"\ --menu "Welcome to Rescue CD Backup & Restore Server __ Version $PROG_VERSION __ Please enter choice:" 23 50 23 \ "1" "$svr_stat_txt" \ "2" "Show backups available on media" \ "3" "Show storage capacity" \ "4" "Show RAID status" \ "5" "Show client status" \ "6" "Image management" \ "7" "$pxe_stat_txt" \ "8" "Run RescueBru (for local backup/restore)" \ "9" "View logs or notes" \ "10" "Edit notes template" \ "S" "Exit to shell" \ "R" "Exit and reboot" \ "P" "Exit and power down" 2> $mmtemp mainmc=`cat $mmtemp` rm -f $mmtemp return 0 } function server_start { #clean up stale client mark files for cmfile in `ls $RAID_MNT_PT|grep 10.`; do rm -f $RAID_MNT_PT/$cmfile done # kill netplugd to keep it from interfering killall netplugd >/dev/null 2>&1 # Since sysresccd-1.0.4, we have to manually start nfs if ! /etc/init.d/nfs start >/dev/null 2>&1 ; then pause "NFS service failed to start." return 1 fi sleep 2 # Bring up the network # Build array of interfaces ifname=( ) for nif in `cat /proc/net/dev|grep eth|cut -d : -f1`; do ifname=( ${ifname[@]} $nif ) done if [ "$NET_STAT" -eq 1 ]; then inform "Network is already up" else inform "Bringing up the networks..." ifidx=1 for nif in ${ifname[@]} ; do inform "$nif as $NET_ADDR$ifidx.1" "1" ifconfig $nif $NET_ADDR$ifidx.1 netmask 255.255.255.0 let "ifidx += 1" done sleep 2 inform "Starting DHCP server..." cp /etc/dhcp/dhcpd.conf.rbruserver /etc/dhcp/dhcpd.conf if ! /etc/init.d/dhcpd restart >/dev/null 2>&1 ; then pause "DHCP server failed to start." return 1 fi sleep 2 NET_STAT=1 fi # NFS export the RAID set inform "Exporting the RAID set to NFS clients..." if ! exportfs -r >/dev/null 2>&1 ; then pause "An error was encountered while exporting the RAID set." return 1 fi sleep 5 SVR_STAT=1 } function server_stop { # Check to see if all clients have exited if ls $RAID_MNT_PT |grep -q 10. ; then if ! approved "It appears that not all clients have exited. Stopping server now may cause client or server lockups, corrupt backups, or other problems. Do you want to stop the server anyway?" "n"; then return 1 fi fi # Un-export the RAID set # exportfs -u \*:/mnt/rescuebru # Turn off nfs inform "Stopping NFS..." if ! /etc/init.d/nfs stop >/dev/null 2>&1 ; then inform "Could not stop NFS." fi # Turn off dhcpd inform "Stopping DHCP server..." if ! /etc/init.d/dhcpd stop >/dev/null 2>&1 ; then inform "Could not stop DHCP server." fi rm -f /etc/dhcp/dhcpd.conf # Bring down the networks inform "Bringing down the networks..." for nif in ${ifname[@]} ; do inform "$nif ..." "1" ifconfig $nif 0.0.0.0 ifconfig $nif down done NET_STAT=0 # Clean up IP mark files rm -f $RAID_MNT_PT/10.* >/dev/null 2>&1 SVR_STAT=0 return 0 } function show_usage { local total=`df -h $RAID_MNT_PT|grep $RAID_MNT_PT|awk '{print $2}'` local used=`df -h $RAID_MNT_PT|grep $RAID_MNT_PT|awk '{print $3}'` local available=`df -h $RAID_MNT_PT|grep $RAID_MNT_PT|awk '{print $4}'` local percentage=`df -h $RAID_MNT_PT|grep $RAID_MNT_PT|awk '{print $5}'` pause "Total capacity: $total\nUsed: $used\nAvailable: $available\nPercent usage: $percentage" } function cleanup() { # Perform cleanup actions prior to exit if [ "$SVR_STAT" -eq 1 ]; then if server_stop ; then if mount|grep -q $RAID_MNT_PT ; then umount $RAID_MNT_PT sleep 2 fi return 0 else return 1 fi else if mount|grep -q $RAID_MNT_PT ; then umount $RAID_MNT_PT sleep 2 fi return 0 fi } function pxe_start() { # Start the PXE boot server if [ ! -d /tftpboot/pxelinux.cfg ]; then mkdir -p /tftpboot/pxelinux.cfg fi if [ ! -f /tftpboot/pxelinux.0 ]; then cp /usr/share/syslinux/pxelinux.0 /tftpboot/ fi if [ -f /tftpboot/pxelinux.cfg/default.bak ]; then rm -f /tftpboot/pxelinux.cfg/default.bak fi if [ -f /tftpboot/pxelinux.cfg/default ]; then mv /tftpboot/pxelinux.cfg/default /tftpboot/pxelinux.cfg/default.bak fi cp --remove-destination /livemnt/boot/???linux/{*msg,*c32,*.0,memdisk,netboot} /tftpboot/ cp --remove-destination /livemnt/boot/???linux/???linux.cfg.pxeclient /tftpboot/pxelinux.cfg/default touch /etc/exports sed -i -e 's!^/tftpboot!#/tftpboot!g' /etc/exports echo "/tftpboot *(fsid=0,ro,no_subtree_check,all_squash,insecure,anonuid=1000,anongid=1000)" >> /etc/exports exportfs -r rm -f /etc/dhcp/dhcpd.conf cp /etc/dhcp/dhcpd.conf.rbruserver.pxeboot /etc/dhcp/dhcpd.conf if ! /etc/init.d/dhcpd restart >/tmp/dhcpdrestart.log 2>&1; then pause "Unable to restart DHCP server. Aborting." return 1 fi if ! /etc/init.d/thttpd restart >/tmp/thttpdrestart.log 2>&1; then pause "Unable to restart thttp server. Aborting." return 1 fi if ! /etc/init.d/in.tftpd restart >/tmp/tftpdrestart.log 2>&1; then pause "Unable to restart tftp server. Aborting." return 1 fi return 0 } function pxe_stop() { # Stop the PXE boot server rm -f /etc/dhcp/dhcpd.conf cp /etc/dhcp/dhcpd.conf.rbruserver /etc/dhcp/dhcpd.conf if ! /etc/init.d/dhcpd restart >/tmp/dhcpdrestart.log 2>&1; then pause "Unable to restart DHCP server. Aborting." return 1 fi if ! /etc/init.d/thttpd stop >/tmp/thttpdstop.log 2>&1; then pause "Unable to stop thttp server. Aborting." return 1 fi if ! /etc/init.d/in.tftpd stop >/tmp/tftpdstop.log 2>&1; then pause "Unable to stop tftp server. Aborting." return 1 fi return 0 } function createraid() { # Creates a RAID set from existing drives # Build an array of existing drives declare -A drives for rdrive in `ls /dev/sd? /dev/nvme?n?` ; do rdrive_bytes=`fdisk -l $rdrive|grep $rdrive:|egrep -oe "[0-9]+ bytes"|egrep -oe "[0-9]+"` drives[$rdrive]=$rdrive_bytes done # Prompt for drives to use prompttext="Select drives you would like to configure as RAID members" # Generate an array of devices for the list dialog local listitems=( ) tagtmp=`mktemp -q` for dev in `echo ${!drives[@]}|tr " " "\n"|sort|tr "\n" " "` ; do drivegb=$(( ${drives[$dev]} / 1073741824 )) listitems+=( "$dev" "$drivegb Gb" "off" ) done # Select devices declare -A selraiddevs unset finished flush_input while [ ! $finished ] ; do if ! dialog --checklist "$prompttext" 20 60 20 "${listitems[@]}" 2>$tagtmp ; then inform "Device selection canceled." "3" rm -f $tagtmp return 1 fi for devname in `cat $tagtmp` ; do selraiddevs[$devname]="${drives[$devname]}" done local finished=1 if [ ${#selraiddevs[@]} -eq 0 ]; then pause "You didn't select any devices. If this was your intent, press enter to return to the selection list and select Cancel." unset finished fi done rm -f $tagtmp # Determine possible RAID levels case ${#selraiddevs[@]} in 1 ) # single disk RAID0 is only option raidlvlopts="0" ;; 2 ) # options are RAID0 or RAID1 raidlvlopts="0 1" ;; * ) # options are RAID0, RAID1, or RAID5 raidlvlopts="0 1 5" ;; esac # Choose configuration local lvlitems=( ) tagtmp=`mktemp -q` for level in $raidlvlopts ; do if [ "$level" = "0" ]; then # size is capacity of smallest selected device * number of selected devices smallestcap=$(printf "%d\n" ${selraiddevs[@]} | sort -rn | tail -n1) numdrives=${#selraiddevs[@]} let "totalbytes=smallestcap*numdrives" totalgb=$(( $totalbytes / 1073741824 )) lvlitems+=( "$level" "striped RAID no parity, $totalgb Gb, NO REDUNDANCY" "off" ) fi if [ "$level" = "1" ]; then # size is capacity of smallest selected device totalbytes=$(printf "%d\n" ${selraiddevs[@]} | sort -rn | tail -n1) totalgb=$(( $totalbytes / 1073741824 )) lvlitems+=( "$level" "mirrored RAID, $totalgb Gb, fault tolerant" "off" ) fi if [ "$level" = "5" ]; then # size is capacity of smallest selected device * number of selected devices - capacity of smallest selected device smallestcap=$(printf "%d\n" ${selraiddevs[@]} | sort -rn | tail -n1) numdrives=${#selraiddevs[@]} let "totalbytes=smallestcap*numdrives-smallestcap" totalgb=$(( $totalbytes / 1073741824 )) lvlitems+=( "$level" "striped RAID with parity, $totalgb Gb, fault tolerant" "off" ) fi done prompttext="Select desired RAID level" tagtmp=`mktemp -q` # Select level unset finished flush_input while [ ! $finished ] ; do if ! dialog --radiolist "$prompttext" 20 60 20 "${lvlitems[@]}" 2>$tagtmp ; then inform "Level selection canceled." rm -f $tagtmp return 1 fi sellevel=`cat $tagtmp` finished=1 done rm -f $tagtmp # Confirm data destruction if ! approved "WARNING! All existing data on the devices you selected will be destroyed. Proceed?" "n"; then inform "RAID creation cancelled." return 1 fi # Remove any existing partitions and RAID metadata inform "Clearing partition tables and old RAID metadata" "1" newraidparts=( ) for rdevice in ${!selraiddevs[@]} ; do sgdisk -Z $rdevice >/dev/null 2>&1 dd if=/dev/zero of=$rdevice bs=1024k count=2000 >/dev/null 2>&1 dd if=/dev/zero of=$rdevice bs=512 count=2048 seek=$((`blockdev --getsz $rdevice` -2048)) >/dev/null 2>&1 if echo $rdevice | grep -q sd ; then newraidparts+=( "$rdevice""1" ) elif echo $rdevice | grep -q nvme ; then newraidparts+=( "$rdevice""p1" ) fi done # Create a single GPT partition using entire drive for each selected drive inform "Creating new partition tables" "1" for rdevice in ${!selraiddevs[@]} ; do parted -s $rdevice mklabel gpt parted -s $rdevice mkpart primary ext2 0% 100% parted -s $rdevice set 1 raid on sleep 2 partprobe $rdevice done # Create RAID set of selected level and create filesystem. inform "Creating RAID set" "1" case $sellevel in 0 ) # Create raid 0. Use force if single drive. if [[ ${#newraidparts[@]} == 1 ]]; then if ! mdadm --create /dev/md0 --quiet --level=0 --force --raid-devices=1 ${newraidparts[@]} ; then pause "RAID set creation failed." return 1 else echo "32768" > /sys/block/md0/md/stripe_cache_size fi else if ! mdadm --create /dev/md0 --quiet --level=0 --raid-devices=${#newraidparts[@]} ${newraidparts[@]} ; then pause "RAID set creation failed." return 1 else echo "32768" > /sys/block/md0/md/stripe_cache_size fi fi sleep 3 # Create filesystem if ! mkfs.ext4 -b 4096 -m .1 /dev/md0 | dialog --progressbox "Creating filesystem. This make take a while..." 24 80 ; then pause "Filesystem creation failed." return 1 fi if [ ! -d "$RAID_MNT_PT" ]; then mkdir $RAID_MNT_PT fi inform "Mounting RAID set and creating new image path..." mount /dev/md0 $RAID_MNT_PT sleep 2 mkdir $IMAGE_PATH;; 1 ) # Create raid 1 if ! mdadm --create /dev/md0 --quiet --level=1 --raid-devices=${#newraidparts[@]} ${newraidparts[@]} ; then pause "RAID set creation failed." return 1 else echo "32768" > /sys/block/md0/md/stripe_cache_size fi sleep 3 # Create filesystem if ! mkfs.ext4 -b 4096 -m .1 /dev/md0| dialog --progressbox "Creating filesystem. This make take a while..." 24 80 ; then pause "Filesystem creation failed." return 1 fi if [ ! -d "$RAID_MNT_PT" ]; then mkdir $RAID_MNT_PT fi inform "Mounting RAID set and creating new image path..." mount /dev/md0 $RAID_MNT_PT sleep 2 mkdir $IMAGE_PATH ;; 5 ) # Create raid 5 if ! mdadm --create /dev/md0 --quiet --level=5 --raid-devices=${#newraidparts[@]} ${newraidparts[@]} ; then pause "RAID set creation failed." return 1 else echo "32768" > /sys/block/md0/md/stripe_cache_size fi sleep 3 # Create filesystem if ! mkfs.ext4 -b 4096 -m .1 -E stride=128,stripe-width=$((128*(${#newraidparts[@]}-1))) /dev/md0 | dialog --progressbox "Creating filesystem. This make take a while..." 24 80 ; then pause "Filesystem creation failed." return 1 fi if [ ! -d "$RAID_MNT_PT" ]; then mkdir $RAID_MNT_PT fi inform "Mounting RAID set and creating new image path..." mount /dev/md0 $RAID_MNT_PT sleep 2 mkdir $IMAGE_PATH ;; * ) # ? pause "Invalid RAID level. RAID creation failed." return 1 ;; esac return 0 } function export() { # Export backups to other media pause "the export() function would run now." # Select export media if ! iedevselect ; then pause "Couldn't select export media." return 1 fi # we now have ie_media_type, ie_media_dev, ie_media_cap # Select images to export buildimagelist imgcount=`wc -l $radiotmp|cut -d " " -f1` if [ $imgcount -eq 1 ]; then # only one image found imagename=`cat $radiotmp|cut -d " " -f1|tr -d '"'` pause "$imagename was the only image found. Selecting that to export." rm -f $radiotmp return 0 else if ! pickimagename "export" "multiple"; then rm -f $radiotmp pause "Couldn't select images to export." return 1 fi fi # we now have imagename if [ "$ie_media_type" = "optical" ]; then for expimage in $imagename ; do imagesz=$(du $IMAGE_PATH/$expimage | awk '{print $1}') done fi # Determine total size of images to export (for non-optical media) tcap=0 for expimage in $imagename ; do imagesz=$(du $IMAGE_PATH/$expimage | awk '{print $1}') tcap=$(echo "$tcap + $imagesz"|bc) done # we now have total required size in tcap if [ "$ie_media_type" = "optical" ]; then numdiscs=$(echo "fd=$tcap/$ie_media_cap;scale=0;fd/1+1"|bc) fi } function iedevselect() { # Prompt user to select export or import media type and device. Mount # device if it's not optical media. # Takes one argument, "import" or "export". # Sets variables, ie_media_type, ie_media_dev, ie_media_cap. ie_op=$1 iemttemp=`mktemp -q` while true ; do if ! dialog --menu "Select $ie_op media type" 12 40 8 \ "O" "Optical" \ "U" "USB" \ "L" "Local" \ "?" "import/export help" 2> $iemttemp ; then rm -f $iemttemp return 0 else iemt=`cat $iemttemp` rm -f $iemttemp fi case $iemt in "O" ) ie_media_type="optical" log "$ie_op media type set to $media_type." unset ieoptdrive for optdrive in `ls /dev/sr{0,1} 2>/dev/null`; do if ! mount|grep -q $optdrive ; then ieoptdrive=$optdrive; fi done if [ ! $ieoptdrive ]; then pause "No usable optical drive found." return 1 fi ie_media_dev=$ieoptdrive if [ "$ie_op" = "export" ]; then omttemp=`mktemp -q` if ! dialog --menu "Select optical media type" 12 40 8 \ "1" "700MB CD-R" \ "2" "4.3GB DVD+R" \ "3" "7.9GB DVD+R DL" \ "4" "22.5GB BD-R" \ "5" "46.5GB BD-R DL" 2> $omttemp ; then rm -f $omttemp return 0 else omt=`cat $omttemp` rm -f $omttemp fi case $omt in 1 ) ie_media_cap=$(echo "700*1024"|bc) ;; 2 ) ie_media_cap=$(echo "4.3*1024*1024"|bc) ;; 3 ) ie_media_cap=$(echo "7.9*1024*1024"|bc) ;; 4 ) ie_media_cap=$(echo "22.5*1024*1024"|bc) ;; 5 ) ie_media_cap=$(echo "46.5*1024*1024"|bc) ;; * ) ie_media_cap=0 ;; esac fi return 0 ;; "U" ) ie_media_type="USB" log "$ie_op media type set to $media_type." local infotext="Searching for USB drive" flush_input searching=1 while [ $searching ]; do infotext="$infotext ." dialog --begin 3 5 --infobox "Plug in USB drive now or press any key to abort. If drive is already plugged in, and is not detected, unplug it, wait a few seconds, and plug it in again." 0 0 \ --and-widget \ --begin 10 5 --sleep 1 --infobox "$infotext" 14 70 if read -s -n1 -t1 kp <&1 ; then pause "USB media mounting aborted." log "USB media mounting aborted." unset searching return 1 fi if [ -e /tmp/usbdriveinfo ] ; then unset searching fi done ie_media_dev=$(grep DEVNAME /tmp/usbdriveinfo|cut -d"=" -f2) if [ ! -e "$ie_media_dev""1" ]; then if approved "The USB drive you inserted doesn't appear to be partitioned. Would you like to partition and create a filesystem on it now (all existing data will be lost)?" "n" ; then parted -s $ie_media_dev mklabel gpt parted -s $ie_media_dev mkpart primary ext2 0% 100% sleep 2 partprobe $rdevice mkfs.ext4 -b 4096 -m .1 $ie_media_dev"1" | dialog --progressbox "Creating filesystem. Please wait..." 24 80 else pause "USB device $ie_media_dev is not usable." return 1 fi fi ie_media_dev=$ie_media_dev"1" if ! mount $ie_media_dev /mnt/usb ; then pause "Could not mount USB device for $ie_op. Aborting." return 1 fi ie_media_cap=$(df --output=avail /mnt/usb|tail -1|tr -d " ") return 0 ;; "L" ) ie_media_type="Local" log "$ie_op media type set to $media_type." # Determine correct local directory localdirtmp=`mktemp -q` path_invalid=true unset local_dir while [ $path_invalid ]; do flush_input if dialog --inputbox "Enter full path of $ie_op directory" 8 78 "$LOCAL_DIR" 2>$localdirtmp ; then local_dir=`cat $localdirtmp` if [ "$local_dir" = "" ]; then inform "You must enter a valid path or select Cancel to abort." "5" fi if [ -d "$local_dir" ]; then unset path_invalid elif [ "$local_dir" = "" ]; then : else pause "Specified directory does not exist. Perhaps you made a typo.\nTry again." fi else pause "Local directory setup cancelled." log "Local directory setup cancelled." rm -f $localdirtemp return 1 fi done log "Local $ie_op directory is $local_dir" rm -f $localdirtemp ie_media_cap=$(df --output=avail $local_dir|tail -1|tr -d " ") return 0 ;; "?" ) if [ -r "$HELP_PATH/importexport.txt" ]; then dialog --title "RescueBRU Help - Import/export" \ --no-shadow --textbox $HELP_PATH/importexport.txt 25 80 else pause "Help file $HELP_PATH/importexport.txt could not be found. Check your installation." fi ;; esac done } ##### Execution begins here ##### # Fix the font so dialog boxes aren't corrupt /usr/bin/setfont # Check for presence of RAID set if ! cat /proc/mdstat|grep -q md ; then pause "Server RAID set was not found." # Check for presence of unconfigured drives if ls /dev/sd* || ls /dev/nvme?n? >/dev/null 2>&1; then if approved "One or more drives were found that are not configured as part of a RAID set. Would you like to configure a new RAID set?" "n" ; then if ! createraid ; then pause "Cannot start server without backup storage." exit 1 fi fi else pause "Cannot start server without backup storage." exit 1 fi fi # Increase RAID cache size to improve performance for mddir in `ls /sys/block |egrep -e "md[0-9]+"` ; do echo "32768" > /sys/block/$mddir/md/stripe_cache_size 2>/dev/null done # Kill off any running DHCP client daemon dhcpcd -q -k # configure /etc/exports echo "$RAID_MNT_PT $EXPRT_ARGS" > /etc/exports # Determine RAID array members for raiddrv in `cat /proc/mdstat|grep -o -e "sd[a-z]|nvme[0-9]n[0-9]"`; do RAID_MEMBERS=$RAID_MEMBERS" /dev/$raiddrv" done for raidpart in `cat /proc/mdstat|grep -o -e "sd[a-z][1-9]|nvme[0-9]n[0-9]p[0-9]"`; do RAID_MEMBERS=$RAID_MEMBERS" /dev/$raidpart" done # Mount the RAID set if [ ! -d "$RAID_MNT_PT" ]; then mkdir $RAID_MNT_PT fi if ! mount|grep -q $RAID_MNT_PT ; then inform "Mounting RAID set..." for possible_raid in `ls /dev|egrep -e "md[0-9]+"` ; do possible_raid_path="/dev/$possible_raid" if mount $possible_raid_path $RAID_MNT_PT 1>/dev/null 2>&1 ; then raid_dev=$possible_raid_path break fi done sleep 2 else raid_dev=`mount|grep $RAID_MNT_PT|egrep -o -e "/dev/md[0-9]+"` inform "RAID set appears to be mounted." fi # Show RAID status raidtest "inform" sleep 5 # Start server by default server_start echo "0000" > /var/lib/nfs/state while true; do mainmenu case $mainmc in "P" | "p" ) shutdown_proc "shutdown" ;; "R" | "r" ) shutdown_proc "reboot" ;; "S" | "s" ) if cleanup ; then inform "Exiting to shell" "2" reset exit 0 else pause "Could not perform cleanup options. Not exiting." return 1 fi ;; 10 ) editnotestemplate ;; 9 ) lognoteview ;; 8 ) inform "Starting RescueBRU" rescuebru -localserver $IMAGE_PATH $raid_dev $RAID_MEMBERS ;; 7 ) if [ "$PXE_STAT" = 0 ]; then inform "Starting PXE boot server" if ! pxe_start ; then pause "Errors were encountered while starting PXE boot server." else PXE_STAT=1 fi else inform "Stopping PXE boot server" if ! pxe_stop ; then pause "Errors were encountered while stopping PXE boot server." else PXE_STAT=0 fi fi ;; 6 ) image_mod ;; 5 ) clientstatus ;; 4 ) raidtest "pause" ;; 3 ) show_usage ;; 2 ) showimages ;; 1 ) echo if [ "$SVR_STAT" = 0 ]; then server_start else server_stop fi ;; esac done echo "End of script! If you see this, something is wrong!" exit 1