mirror of
https://github.com/PartialVolume/shredos.x86_64.git
synced 2026-02-20 09:35:26 +00:00
Add a=archive to USB option available on completion
When nwipe has completed erasing the drives and the user hits return to exit which then creates the PDF certificates, the PDF and log files are then either automatically transferred to a USB stick, assuming that's where you booted ShredOS from or the files are transferred to a network server, if the ShredOS grub.cfg files were configured to do that. However, say there was a network failure or somebody inadvertently removed the USB drive, the PDF files & logs would not get saved. Previously you would have had to manually copy the files using the command line. Now when you get to the stage where ShredOS asks whether you want to reboot, shutdown or restart nwipe, if there are any PDF files that have not been saved a new options 'a' archive to USB will be available. This option will only show up if there are PDFs that have not been saved. So the message will read: r=reboot, s=shutdown, a=archive to USB, spacebar=restart nwipe Apart from the above scenario, this feature may also prove useful to somebody, wiping many computers while using a single USB stick. For those that don't know, it's not necessary to keep the USB stick plugged into the computer. Once nwipe has appeared you can pull the USB stick out and use it to boot another computer. Returning it to the first computer when the wipes have completed and you want to save the PDFs to USB. This patch also standardises the date format used in the ShredOS logs so it matches the nwipe format.
This commit is contained in:
@@ -14,6 +14,9 @@
|
||||
#
|
||||
# Written by PartialVolume, archive_log.sh is a component of ShredOS - the disk eraser.
|
||||
|
||||
# This is the default date format used by ShredOS and nwipe for logs
|
||||
date_format="+%Y/%m/%d %H:%M:%S"
|
||||
|
||||
exit_code=0
|
||||
mode=""
|
||||
|
||||
@@ -45,17 +48,17 @@ sent_directory="/sent"
|
||||
drive_partition=$(find_shredos_boot_disc.sh)
|
||||
|
||||
if [ "$drive_partition" == "" ]; then
|
||||
printf "[`date`] archive_log.sh: No exFAT/FAT32 drive found, unable to archive nwipe log files to USB\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: No exFAT/FAT32 drive found, unable to archive nwipe log files to USB\n" 2>&1 | tee -a transfer.log
|
||||
exit 1
|
||||
else
|
||||
printf "[`date`] Archiving nwipe logs to $drive_partition\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Archiving nwipe logs to $drive_partition\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
|
||||
# Create the temporary directory we will mount the FAT32 partition onto.
|
||||
if [ ! -d "$archive_drive_directory" ]; then
|
||||
mkdir "$archive_drive_directory"
|
||||
if [ $? != 0 ]; then
|
||||
printf "[`date`] archive_log.sh: FAILED to create the temporary mount directory $archive_drive_directory\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: FAILED to create the temporary mount directory $archive_drive_directory\n" 2>&1 | tee -a transfer.log
|
||||
exit_code=2
|
||||
fi
|
||||
fi
|
||||
@@ -65,40 +68,40 @@ mount $drive_partition $archive_drive_directory
|
||||
status=$?
|
||||
if [ $status != 0 ] && [ $status != 32 ]; then
|
||||
# exit only if error, except code 32 which means already mounted
|
||||
printf "[`date`] archive_log.sh: FAILED to mount the FAT32 partition $drive_partition to $archive_drive_directory\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: FAILED to mount the FAT32 partition $drive_partition to $archive_drive_directory\n" 2>&1 | tee -a transfer.log
|
||||
exit_code=3
|
||||
else
|
||||
printf "[`date`] archive_log.sh: exFAT/FAT32 partition $drive_partition is now mounted to $archive_drive_directory\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: exFAT/FAT32 partition $drive_partition is now mounted to $archive_drive_directory\n" 2>&1 | tee -a transfer.log
|
||||
|
||||
# Copy the dmesg.txt and PDF files over to the exFAT/FAT32 partition
|
||||
dmesg > dmesg.txt
|
||||
cp /dmesg.txt "$archive_drive_directory/"
|
||||
if [ $? != 0 ]; then
|
||||
printf "[`date`] archive_log.sh: FAILED to copy the dmesg.txt file to the root of $drive_partition:/\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: FAILED to copy the dmesg.txt file to the root of $drive_partition:/\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] archive_log.sh: Copied dmesg.txt to $drive_partition:/\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: Copied dmesg.txt to $drive_partition:/\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
|
||||
# Copy the PDF certificates over to the exFAT/FAT32 partition
|
||||
cp /nwipe_report_*pdf "$archive_drive_directory/"
|
||||
if [ $? != 0 ]; then
|
||||
printf "[`date`] archive_log.sh: Unable to copy the nwipe_report...pdf file to the root of $drive_partition:/\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: Unable to copy the nwipe_report...pdf file to the root of $drive_partition:/\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] archive_log.sh: Copied nwipe_report...pdf to $drive_partition:/\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: Copied nwipe_report...pdf to $drive_partition:/\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
|
||||
# Copy the nwipe log files over to the exFAT/FAT32 partition
|
||||
cp /nwipe_log* "$archive_drive_directory/"
|
||||
if [ $? != 0 ]; then
|
||||
printf "[`date`] archive_log.sh: Unable to copy the nwipe log files to the root of $drive_partition:/\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: Unable to copy the nwipe log files to the root of $drive_partition:/\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] archive_log.sh: Copied the nwipe logs to $drive_partition:/\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: Copied the nwipe logs to $drive_partition:/\n" 2>&1 | tee -a transfer.log
|
||||
|
||||
# Create the temporary sent directory we will move log files that have already been copied
|
||||
if [ ! -d "$sent_directory" ]; then
|
||||
mkdir "$sent_directory"
|
||||
if [ $? != 0 ]; then
|
||||
printf "[`date`] archive_log.sh: FAILED to create the temporary directory $sent_directory on the RAM disc\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: FAILED to create the temporary directory $sent_directory on the RAM disc\n" 2>&1 | tee -a transfer.log
|
||||
exit_code=5
|
||||
fi
|
||||
fi
|
||||
@@ -107,17 +110,17 @@ else
|
||||
# Move the nwipe logs into the RAM disc sent directory
|
||||
mv /nwipe_log* "$sent_directory/"
|
||||
if [ $? != 0 ]; then
|
||||
printf "[`date`] archive_log.sh: Unable to move the nwipe logs into the $sent_directory on the RAM disc\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: Unable to move the nwipe logs into the $sent_directory on the RAM disc\n" 2>&1 | tee -a transfer.log
|
||||
exit_code=6
|
||||
else
|
||||
printf "[`date`] archive_log.sh: Moved the nwipe logs into the $sent_directory\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: Moved the nwipe logs into the $sent_directory\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
# Move the nwipe PDF certificates into the RAM disc sent directory
|
||||
mv /nwipe_report*pdf "$sent_directory/"
|
||||
if [ $? != 0 ]; then
|
||||
printf "[`date`] archive_log.sh: Unable to move the PDF certificates into the $sent_directory on the RAM disc\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: Unable to move the PDF certificates into the $sent_directory on the RAM disc\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] archive_log.sh: Moved the PDF certificates into the $sent_directory\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: Moved the PDF certificates into the $sent_directory\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@@ -131,9 +134,9 @@ else
|
||||
then
|
||||
mkdir "/etc/nwipe"
|
||||
if [ $? != 0 ]; then
|
||||
printf "[`date`] archive_log.sh: FAILED to create directory /etc/nwipe on ShredOS ram drive\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: FAILED to create directory /etc/nwipe on ShredOS ram drive\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] archive_log.sh: Created directory /etc/nwipe on ShredOS ram drive\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: Created directory /etc/nwipe on ShredOS ram drive\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
fi
|
||||
if [[ "$mode" == "read" ]]; then
|
||||
@@ -144,9 +147,9 @@ else
|
||||
# Copy nwipe.conf from USB flash to ShredOS ram disc
|
||||
cp "$archive_drive_directory/etc/nwipe/nwipe.conf" /etc/nwipe/nwipe.conf
|
||||
if [ $? != 0 ]; then
|
||||
printf "[`date`] archive_log.sh: FAILED to copy $drive_partition:/etc/nwipe/nwipe.conf to ShredOS's ram disc\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: FAILED to copy $drive_partition:/etc/nwipe/nwipe.conf to ShredOS's ram disc\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] archive_log.sh: Copied $drive_partition:/etc/nwipe/nwipe.conf to ShredOS's ram disc\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: Copied $drive_partition:/etc/nwipe/nwipe.conf to ShredOS's ram disc\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -157,9 +160,9 @@ else
|
||||
# Copy nwipe.conf from USB flash to ShredOS ram disc
|
||||
cp "$archive_drive_directory/etc/nwipe/nwipe_customers.csv" /etc/nwipe/nwipe_customers.csv
|
||||
if [ $? != 0 ]; then
|
||||
printf "[`date`] archive_log.sh: FAILED to copy $drive_partition:/etc/nwipe/nwipe_customers.csv to /etc/nwipe/nwipe_customers.csv\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: FAILED to copy $drive_partition:/etc/nwipe/nwipe_customers.csv to /etc/nwipe/nwipe_customers.csv\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] archive_log.sh: Copied $drive_partition:/etc/nwipe/nwipe_customers.csv to /etc/nwipe/nwipe_customers.csv\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: Copied $drive_partition:/etc/nwipe/nwipe_customers.csv to /etc/nwipe/nwipe_customers.csv\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@@ -173,9 +176,9 @@ else
|
||||
then
|
||||
mkdir "$archive_drive_directory/etc"
|
||||
if [ $? != 0 ]; then
|
||||
printf "[`date`] archive_log.sh: FAILED to create directory /etc on $drive_partition:/\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: FAILED to create directory /etc on $drive_partition:/\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] archive_log.sh: Created directory /etc on $drive_partition:/\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: Created directory /etc on $drive_partition:/\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -184,9 +187,9 @@ else
|
||||
then
|
||||
mkdir "$archive_drive_directory/etc/nwipe"
|
||||
if [ $? != 0 ]; then
|
||||
printf "[`date`] archive_log.sh: FAILED to create directory /etc/nwipe on $drive_partition:/\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: FAILED to create directory /etc/nwipe on $drive_partition:/\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] archive_log.sh: Created directory /etc/nwipe on $drive_partition:/\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: Created directory /etc/nwipe on $drive_partition:/\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
fi
|
||||
if [[ "$mode" == "write" ]]; then
|
||||
@@ -196,9 +199,9 @@ else
|
||||
then
|
||||
cp /etc/nwipe/nwipe.conf "$archive_drive_directory/etc/nwipe/nwipe.conf"
|
||||
if [ $? != 0 ]; then
|
||||
printf "[`date`] archive_log.sh: FAILED to copy /etc/nwipe/nwipe.conf to $drive_partition:/etc/nwipe/nwipe.conf\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: FAILED to copy /etc/nwipe/nwipe.conf to $drive_partition:/etc/nwipe/nwipe.conf\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] archive_log.sh: Copied /etc/nwipe/nwipe.conf to $drive_partition:/etc/nwipe/nwipe.conf\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: Copied /etc/nwipe/nwipe.conf to $drive_partition:/etc/nwipe/nwipe.conf\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -208,9 +211,9 @@ else
|
||||
then
|
||||
cp /etc/nwipe/nwipe_customers.csv "$archive_drive_directory/etc/nwipe/nwipe_customers.csv"
|
||||
if [ $? != 0 ]; then
|
||||
printf "[`date`] archive_log.sh: FAILED to copy /etc/nwipe/nwipe_customers.csv file to the root of $drive_partition:/etc/nwipe/nwipe_customers.csv\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: FAILED to copy /etc/nwipe/nwipe_customers.csv file to the root of $drive_partition:/etc/nwipe/nwipe_customers.csv\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] archive_log.sh: Copied /etc/nwipe/nwipe_customers.csv to $drive_partition:/etc/nwipe/nwipe_customers.csv\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: Copied /etc/nwipe/nwipe_customers.csv to $drive_partition:/etc/nwipe/nwipe_customers.csv\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@@ -220,13 +223,13 @@ fi
|
||||
sleep 1
|
||||
umount "$archive_drive_directory"
|
||||
if [ $? != 0 ]; then
|
||||
printf "[`date`] archive_log.sh: FAILED to unmount the FAT partition\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: FAILED to unmount the FAT partition\n" 2>&1 | tee -a transfer.log
|
||||
exit_code=7
|
||||
else
|
||||
printf "[`date`] archive_log.sh: Unmounted $archive_drive_directory ($drive_partition)\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: Unmounted $archive_drive_directory ($drive_partition)\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
|
||||
if [ $exit_code != 0 ]; then
|
||||
printf "[`date`] archive_log.sh: FAILED to copy nwipe log files to $drive_partition, exit code $exit_code\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] archive_log.sh: FAILED to copy nwipe log files to $drive_partition, exit code $exit_code\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
exit $exit_code
|
||||
|
||||
@@ -7,6 +7,9 @@ trap "echo" INT
|
||||
# ignore the case
|
||||
shopt -s nocasematch
|
||||
|
||||
# date format used by nwipe & shredos in all logs
|
||||
date_format="+%Y/%m/%d %H:%M:%S"
|
||||
|
||||
# Check dmesg for USB activity, do not proceed until there has been no
|
||||
# activity for 5 seconds or automatically proceed after 30 seconds.
|
||||
#
|
||||
@@ -53,8 +56,8 @@ while (( loop_count_total > 0 )); do
|
||||
done
|
||||
printf "\n"
|
||||
|
||||
echo "[`date`] Transfer log" > transfer.log
|
||||
echo "[`date`] wget log" > wget.log
|
||||
echo "[`date "$date_format"`] Transfer log" > transfer.log
|
||||
echo "[`date "$date_format"`] wget log" > wget.log
|
||||
|
||||
# If it doesn't already exist create a directory where we can
|
||||
# store the incoming config file when using a remote server.
|
||||
@@ -65,9 +68,9 @@ then
|
||||
mkdir /imported
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
printf "[`date`] Created the /imported directory\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Created the /imported directory\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] FAILED to create the /imported directory\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] FAILED to create the /imported directory\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -79,9 +82,9 @@ then
|
||||
mkdir /etc/nwipe
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
printf "[`date`] Created the /etc/nwipe directory\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Created the /etc/nwipe directory\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] FAILED to create the /etc/nwipe directory\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] FAILED to create the /etc/nwipe directory\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -91,9 +94,9 @@ if [ ! -d "exported" ]; then
|
||||
mkdir /exported
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
printf "[`date`] Created the /exported directory\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Created the /exported directory\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] FAILED to create the /exported directory\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] FAILED to create the /exported directory\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -102,13 +105,13 @@ fi
|
||||
# exFAT/FAT32/FAT16 drive it comes across. If it doesn't find any exFAT/FAT32/FAT16
|
||||
# drive then it reurns "".
|
||||
#
|
||||
printf "[`date`] nwipe_launcher: Searching for exFAT/FAT32/FAT16 USB drive.\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] nwipe_launcher: Searching for exFAT/FAT32/FAT16 USB drive.\n" 2>&1 | tee -a transfer.log
|
||||
drive_partition=$(find_shredos_boot_disc.sh)
|
||||
|
||||
if [ "$drive_partition" == "" ]; then
|
||||
printf "[`date`] nwipe_launcher: No exFAT/FAT32/FAT16 USB drive found: Unable to archive PDF/logs $drive.\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] nwipe_launcher: No exFAT/FAT32/FAT16 USB drive found: Unable to archive PDF/logs $drive.\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] nwipe_launcher: Found a exFAT/FAT32/FAT16 USB drive $drive\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] nwipe_launcher: Found a exFAT/FAT32/FAT16 USB drive $drive\n" 2>&1 | tee -a transfer.log
|
||||
if [ -f /boot_device.txt ]
|
||||
then
|
||||
drive=$(cat /boot_device.txt)
|
||||
@@ -181,9 +184,9 @@ then
|
||||
config_debug=""
|
||||
fi
|
||||
|
||||
printf "[`date`] Remote Server protocol = $config_protocol\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date`] Remote Server IP = $config_ip\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date`] Remote Server path = $config_path\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Remote Server protocol = $config_protocol\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Remote Server IP = $config_ip\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Remote Server path = $config_path\n" 2>&1 | tee -a transfer.log
|
||||
|
||||
# Ping the ftp at 1 second intervals. Proceed as soon as a response is received
|
||||
# If no response after 30 seconds proceed anyway and log a warning.
|
||||
@@ -196,16 +199,16 @@ then
|
||||
if test ${PIPESTATUS[0]} -eq 0
|
||||
then
|
||||
config_server_status="online"
|
||||
printf "[`date`] Server $config_ip online\n"
|
||||
printf "[`date "$date_format"`] Server $config_ip online\n"
|
||||
break
|
||||
fi
|
||||
printf "[`date`] Waiting for ping response from sftp/ftp server, timeout in $loop_count_total \r"
|
||||
printf "[`date "$date_format"`] Waiting for ping response from sftp/ftp server, timeout in $loop_count_total \r"
|
||||
((loop_count_total--))
|
||||
sleep 1
|
||||
done
|
||||
if (( $loop_count_total == 0 ))
|
||||
then
|
||||
printf "[`date`] \nsftp/ftp ping timout\n"
|
||||
printf "[`date "$date_format"`] \nsftp/ftp ping timout\n"
|
||||
fi
|
||||
|
||||
if [[ "$config_server_status" == "online" ]]
|
||||
@@ -214,7 +217,7 @@ then
|
||||
# If the protocol in shredos_config=".." is ftp then read the remote nwipe.conf and customers.csv files
|
||||
if [[ "$config_protocol" == "ftp" ]]
|
||||
then
|
||||
printf "[`date`][FTP:] Using ftp protocol\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`][FTP:] Using ftp protocol\n" 2>&1 | tee -a transfer.log
|
||||
# we test lftp transferred successfully by checking whether the file exists
|
||||
lftp $config_debug -c "set xfer:clobber yes; open $config_ip; user $config_user $config_password; cd $config_path; get -O /imported -c $config_file; close" 2>&1 | tee -a transfer.log
|
||||
test -f "/imported/nwipe.conf"
|
||||
@@ -223,12 +226,12 @@ then
|
||||
cp "/imported/nwipe.conf" "/etc/nwipe/nwipe.conf" 2>&1 | tee -a transfer.log
|
||||
if test ${PIPESTATUS[0]} -eq 0
|
||||
then
|
||||
printf "[`date`][FTP:] Retrieved nwipe.conf from ftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`][FTP:] Retrieved nwipe.conf from ftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`][FTP:] [FAILED] to copy nwipe.conf from /imported/ to /etc/nwipe/\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`][FTP:] [FAILED] to copy nwipe.conf from /imported/ to /etc/nwipe/\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
else
|
||||
printf "[`date`][FTP:][FAILED] Could not retrieve nwipe.conf from ftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`][FTP:][FAILED] Could not retrieve nwipe.conf from ftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
|
||||
lftp $config_debug -c "set xfer:clobber yes; open $config_ip; user $config_user $config_password; cd $config_path; get -O /imported -c $customers_file; close" 2>&1 | tee -a transfer.log
|
||||
@@ -238,12 +241,12 @@ then
|
||||
cp "/imported/nwipe_customers.csv" "/etc/nwipe/nwipe_customers.csv" 2>&1 | tee -a transfer.log
|
||||
if test ${PIPESTATUS[0]} -eq 0
|
||||
then
|
||||
printf "[`date`][FTP:] Retrieved nwipe_customers.csv from ftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`][FTP:] Retrieved nwipe_customers.csv from ftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`][FTP:] [FAILED] to copy nwipe_customers.csv from /imported/ to /etc/nwipe/\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`][FTP:] [FAILED] to copy nwipe_customers.csv from /imported/ to /etc/nwipe/\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
else
|
||||
printf "[`date`][FTP:][FAILED] Could not retrieve nwipe_customers.csv from ftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`][FTP:][FAILED] Could not retrieve nwipe_customers.csv from ftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
|
||||
# Send a copy of dmesg
|
||||
@@ -251,16 +254,16 @@ then
|
||||
lftp $config_debug -c "set xfer:clobber yes; open $config_ip; user $config_user $config_password; cd $config_path; put -e $dmesg_file; close" 2>&1 | tee -a transfer.log
|
||||
if test ${PIPESTATUS[0]} -eq 0
|
||||
then
|
||||
printf "[`date`][FTP:] Sent dmesg.txt to ftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`][FTP:] Sent dmesg.txt to ftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`][FTP:][FAILED] Could not send dmesg.txt to ftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`][FTP:][FAILED] Could not send dmesg.txt to ftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
else
|
||||
# ***** TFTP TRANSFER *****
|
||||
#
|
||||
if [[ "$config_protocol" == "tftp" ]]
|
||||
then
|
||||
printf "[`date`][TFTP:]Using tftp protocol\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`][TFTP:]Using tftp protocol\n" 2>&1 | tee -a transfer.log
|
||||
# tftp uses a subset of the ftp commands. It does not support authentication or changing directories
|
||||
# It also uses port 69 as standard unlike ftp which uses 20 & 21. The tftp server needs to support
|
||||
# write access and creation of files by the client. In the case of tftpd_hpa that means adding -c
|
||||
@@ -274,12 +277,12 @@ then
|
||||
cp "/imported/nwipe.conf" "/etc/nwipe/nwipe.conf" 2>&1 | tee -a transfer.log
|
||||
if test ${PIPESTATUS[0]} -eq 0
|
||||
then
|
||||
printf "[`date`][TFTP:] Retrieved nwipe.conf from tftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`][TFTP:] Retrieved nwipe.conf from tftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`][TFTP:][FAILED] to copy nwipe.conf from /imported/ to /etc/nwipe/\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`][TFTP:][FAILED] to copy nwipe.conf from /imported/ to /etc/nwipe/\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
else
|
||||
printf "[`date`][TFTP:][FAILED] Could not retrieve nwipe.conf from tftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`][TFTP:][FAILED] Could not retrieve nwipe.conf from tftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
|
||||
tftp $config_ip -v -m binary -c get $config_path/$customers_file /imported/$customers_file 2>&1 | tee -a transfer.log
|
||||
@@ -289,12 +292,12 @@ then
|
||||
cp "/imported/nwipe_customers.csv" "/etc/nwipe/nwipe_customers.csv" 2>&1 | tee -a transfer.log
|
||||
if test ${PIPESTATUS[0]} -eq 0
|
||||
then
|
||||
printf "[`date`][TFTP:] Retrieved nwipe_customers.csv from tftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`][TFTP:] Retrieved nwipe_customers.csv from tftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`][TFTP:] [FAILED] to copy nwipe_customers.csv from /imported/ to /etc/nwipe/\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`][TFTP:] [FAILED] to copy nwipe_customers.csv from /imported/ to /etc/nwipe/\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
else
|
||||
printf "[`date`][TFTP:][FAILED] Could not retrieve nwipe_customers.csv from tftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`][TFTP:][FAILED] Could not retrieve nwipe_customers.csv from tftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
|
||||
# Send a copy of dmesg
|
||||
@@ -302,14 +305,14 @@ then
|
||||
tftp $config_ip -v -m binary -c put $config_path/$dmesg_file 2>&1 | tee -a transfer.log
|
||||
if test ${PIPESTATUS[0]} -eq 0
|
||||
then
|
||||
printf "[`date`][TFTP:] Sent dmesg.txt to tftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`][TFTP:] Sent dmesg.txt to tftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`][TFTP:][FAILED] Could not send dmesg.txt to tftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`][TFTP:][FAILED] Could not send dmesg.txt to tftp server $config_ip:$config_path\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
printf "[`date`] [FAILED] No ping response from $config_ip, Check RJ45 network connection\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] [FAILED] No ping response from $config_ip, Check RJ45 network connection\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
else
|
||||
# if the shredos_config=".." doesn't exist on the kernel cmdline then we have to assume we booted from USB
|
||||
@@ -453,32 +456,32 @@ do
|
||||
lftp_command_line=$(kernel_cmdline_extractor lftp)
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
printf "[`date`] Found lftp commands on kernel command line in grub.cfg\n"
|
||||
printf "[`date`] Executing users lftp commands\n"
|
||||
printf "[`date "$date_format"`] Found lftp commands on kernel command line in grub.cfg\n"
|
||||
printf "[`date "$date_format"`] Executing users lftp commands\n"
|
||||
lftp -c "$lftp_command_line"
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
printf "[`date`] lftp completed sucessfully\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date`] moving nwipe logs to ../exported\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] lftp completed sucessfully\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] moving nwipe logs to ../exported\n" 2>&1 | tee -a transfer.log
|
||||
mv $logfile exported/
|
||||
else
|
||||
printf "[`date`] lftp command failed, See above and transfer.log for details\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] lftp command failed, See above and transfer.log for details\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
fi
|
||||
|
||||
http_post_url=$(kernel_cmdline_extractor http_post_url)
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
printf "[`date`] Found http_post config on kernel command line in grub.cfg\n"
|
||||
printf "[`date`] Executing users http_post request\n"
|
||||
printf "[`date "$date_format"`] Found http_post config on kernel command line in grub.cfg\n"
|
||||
printf "[`date "$date_format"`] Executing users http_post request\n"
|
||||
wget --method PUT --body-file="$logfile" "$http_post_url" -O - -nv >> wget.log
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
printf "[`date`] wget completed sucessfully\n"
|
||||
printf "[`date`] moving nwipe logs to ../exported\n"
|
||||
printf "[`date "$date_format"`] wget completed sucessfully\n"
|
||||
printf "[`date "$date_format"`] moving nwipe logs to ../exported\n"
|
||||
mv $logfile exported/
|
||||
else
|
||||
printf "[`date`] wget command failed, See above and wget.log for details\n"
|
||||
printf "[`date "$date_format"`] wget command failed, See above and wget.log for details\n"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -538,9 +541,9 @@ do
|
||||
output_debug=""
|
||||
fi
|
||||
|
||||
printf "[`date`] Remote Server protocol = $output_protocol\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date`] Remote Server IP = $output_ip\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date`] Remote Server path = $output_path\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Remote Server protocol = $output_protocol\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Remote Server IP = $output_ip\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Remote Server path = $output_path\n" 2>&1 | tee -a transfer.log
|
||||
|
||||
# Ping the ftp at 1 second intervals. Proceed as soon as a response is received
|
||||
# If no response after 30 seconds proceed anyway and log a warning.
|
||||
@@ -551,10 +554,10 @@ do
|
||||
if test ${PIPESTATUS[0]} -eq 0
|
||||
then
|
||||
output_server_status="online"
|
||||
printf "[`date`] Server $output_ip online\n"
|
||||
printf "[`date "$date_format"`] Server $output_ip online\n"
|
||||
break
|
||||
fi
|
||||
printf "[`date`] Waiting for ping response from sftp/ftp server, timeout in $loop_count_total \r"
|
||||
printf "[`date "$date_format"`] Waiting for ping response from sftp/ftp server, timeout in $loop_count_total \r"
|
||||
((loop_count_total--))
|
||||
sleep 1
|
||||
done
|
||||
@@ -576,10 +579,10 @@ do
|
||||
lftp $output_debug -c "set xfer:clobber yes; open $output_ip; user $output_user $output_password; lcd /; cd $output_path; put -e $pdf; close" 2>&1 | tee -a transfer.log
|
||||
if test ${PIPESTATUS[0]} -eq 0
|
||||
then
|
||||
printf "[`date`] Sent $pdf to ftp server $output_ip:$output_path\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Sent $pdf to ftp server $output_ip:$output_path\n" 2>&1 | tee -a transfer.log
|
||||
mv $pdf exported/ 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] Failed to send $pdf to ftp server $output_ip:$output_path\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Failed to send $pdf to ftp server $output_ip:$output_path\n" 2>&1 | tee -a transfer.log
|
||||
transfer_status="FAIL"
|
||||
fi
|
||||
done
|
||||
@@ -590,10 +593,10 @@ do
|
||||
lftp $output_debug -c "set xfer:clobber yes; open $output_ip; user $output_user $output_password; lcd /; cd $output_path; put -e $log; close" 2>&1 | tee -a transfer.log
|
||||
if test ${PIPESTATUS[0]} -eq 0
|
||||
then
|
||||
printf "[`date`] Sent $log to ftp server $output_ip:$output_path\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Sent $log to ftp server $output_ip:$output_path\n" 2>&1 | tee -a transfer.log
|
||||
mv $log exported/ 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] Failed to send $log to ftp server $output_ip:$output_path\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Failed to send $log to ftp server $output_ip:$output_path\n" 2>&1 | tee -a transfer.log
|
||||
transfer_status="FAIL"
|
||||
fi
|
||||
done
|
||||
@@ -609,10 +612,10 @@ do
|
||||
more tftp_status.txt | grep -i "$tftp_errors"
|
||||
if test ${PIPESTATUS[1]} -ne 0
|
||||
then
|
||||
printf "[`date`] Sent $pdf to tftp server $output_ip:$output_path\n\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Sent $pdf to tftp server $output_ip:$output_path\n\n" 2>&1 | tee -a transfer.log
|
||||
mv $pdf exported/ 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] FAILED to send $pdf to tftp server $output_ip:$output_path\n\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] FAILED to send $pdf to tftp server $output_ip:$output_path\n\n" 2>&1 | tee -a transfer.log
|
||||
transfer_status="FAIL"
|
||||
fi
|
||||
rm tftp_status.txt
|
||||
@@ -625,10 +628,10 @@ do
|
||||
more tftp_status.txt | grep -i "$tftp_errors"
|
||||
if test ${PIPESTATUS[1]} -ne 0
|
||||
then
|
||||
printf "[`date`] Sent $log to tftp server $output_ip:$output_path\n\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Sent $log to tftp server $output_ip:$output_path\n\n" 2>&1 | tee -a transfer.log
|
||||
mv $log exported/ 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] FAILED to send $log to tftp server $output_ip:$output_path\n\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] FAILED to send $log to tftp server $output_ip:$output_path\n\n" 2>&1 | tee -a transfer.log
|
||||
transfer_status="FAIL"
|
||||
fi
|
||||
rm tftp_status.txt
|
||||
@@ -636,7 +639,7 @@ do
|
||||
fi
|
||||
fi
|
||||
else
|
||||
printf "[`date`] Pinging $output_ip FAILED, Check RJ45 network connection\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Pinging $output_ip FAILED, Check RJ45 network connection\n" 2>&1 | tee -a transfer.log
|
||||
transfer_status="FAIL"
|
||||
fi
|
||||
else
|
||||
@@ -664,22 +667,22 @@ do
|
||||
# ***** FTP TRANSFER *****
|
||||
#
|
||||
if [[ "$config_protocol" == "ftp" ]]; then
|
||||
printf "[`date`] FTP protocol selected by the user\n" | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] FTP protocol selected by the user\n" | tee -a transfer.log
|
||||
lftp $output_debug -c "set xfer:clobber yes; open $config_ip; user $config_user $config_password; lcd /etc/nwipe; cd $config_path; put -e $config_file; close" 2>&1 | tee -a transfer.log
|
||||
if test ${PIPESTATUS[0]} -eq 0
|
||||
then
|
||||
printf "[`date`] Sent nwipe.conf to ftp server $config_ip:$config_path\n\n" | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Sent nwipe.conf to ftp server $config_ip:$config_path\n\n" | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] FAILED to send nwipe.conf to ftp server $config_ip:$config_path\n\n" | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] FAILED to send nwipe.conf to ftp server $config_ip:$config_path\n\n" | tee -a transfer.log
|
||||
transfer_status="FAIL"
|
||||
fi
|
||||
|
||||
lftp $output_debug -c "set xfer:clobber yes; open $config_ip; user $config_user $config_password; lcd /etc/nwipe; cd $config_path; put -e $customers_file; close" 2>&1 | tee -a transfer.log
|
||||
if test ${PIPESTATUS[0]} -eq 0
|
||||
then
|
||||
printf "[`date`] Sent customers.csv to ftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Sent customers.csv to ftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] FAILED to send customers.csv to ftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] FAILED to send customers.csv to ftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
transfer_status="FAIL"
|
||||
fi
|
||||
|
||||
@@ -687,32 +690,32 @@ do
|
||||
lftp $output_debug -c "set xfer:clobber yes; open $config_ip; user $config_user $config_password; lcd /; cd $config_path; put -e $dmesg_file; close" 2>&1 | tee -a transfer.log
|
||||
if [ ${PIPESTATUS[0]} -eq 0 ]
|
||||
then
|
||||
printf "[`date`] Sent dmesg.txt to ftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Sent dmesg.txt to ftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] FAILED to send dmesg.txt to ftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] FAILED to send dmesg.txt to ftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
transfer_status="FAIL"
|
||||
fi
|
||||
|
||||
lftp $output_debug -c "set xfer:clobber yes; open $config_ip; user $config_user $config_password; lcd /; cd $config_path; put -e $transfer_log_file; close" 2>&1 | tee -a transfer.log
|
||||
if [ ${PIPESTATUS[0]} -eq 0 ]
|
||||
then
|
||||
printf "[`date`] Sent $transfer_log_file to ftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Sent $transfer_log_file to ftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] FAILED to send $transfer_log_file to ftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] FAILED to send $transfer_log_file to ftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
transfer_status="FAIL"
|
||||
fi
|
||||
else
|
||||
# ***** TFTP TRANSFER *****
|
||||
#
|
||||
if [[ "$config_protocol" == "tftp" ]]; then
|
||||
printf "[`date`] TFTP protocol selected by the user\n" | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] TFTP protocol selected by the user\n" | tee -a transfer.log
|
||||
tftp $config_ip -v -m binary -c put /etc/nwipe/$config_file $config_path/$config_file 2>&1 | tee -a transfer.log tftp_status.txt
|
||||
more tftp_status.txt | grep -i "$tftp_errors"
|
||||
if test ${PIPESTATUS[1]} -ne 0
|
||||
then
|
||||
printf "[`date`] Sent nwipe.conf to tftp server $config_ip:$config_path\n\n" | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Sent nwipe.conf to tftp server $config_ip:$config_path\n\n" | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] FAILED to send nwipe.conf to tftp server $config_ip:$config_path\n\n" | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] FAILED to send nwipe.conf to tftp server $config_ip:$config_path\n\n" | tee -a transfer.log
|
||||
transfer_status="FAIL"
|
||||
fi
|
||||
rm tftp_status.txt
|
||||
@@ -721,9 +724,9 @@ do
|
||||
more tftp_status.txt | grep -i "$tftp_errors"
|
||||
if test ${PIPESTATUS[1]} -ne 0
|
||||
then
|
||||
printf "[`date`] Sent customers.csv to tftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Sent customers.csv to tftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] FAILED to send customers.csv to tftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] FAILED to send customers.csv to tftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
transfer_status="FAIL"
|
||||
fi
|
||||
rm tftp_status.txt
|
||||
@@ -733,9 +736,9 @@ do
|
||||
more tftp_status.txt | grep -i "$tftp_errors"
|
||||
if [ ${PIPESTATUS[1]} -ne 0 ]
|
||||
then
|
||||
printf "[`date`] Sent dmesg.txt to tftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Sent dmesg.txt to tftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] FAILED to send dmesg.txt to tftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] FAILED to send dmesg.txt to tftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
transfer_status="FAIL"
|
||||
fi
|
||||
rm tftp_status.txt
|
||||
@@ -744,9 +747,9 @@ do
|
||||
more tftp_status.txt | grep -i "$tftp_errors"
|
||||
if [ ${PIPESTATUS[1]} -ne 0 ]
|
||||
then
|
||||
printf "[`date`] Sent transfer.log to tftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Sent transfer.log to tftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
else
|
||||
printf "[`date`] FAILED to send transfer.log to tftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] FAILED to send transfer.log to tftp server $config_ip:$config_path\n\n" 2>&1 | tee -a transfer.log
|
||||
transfer_status="FAIL"
|
||||
fi
|
||||
fi
|
||||
@@ -764,7 +767,7 @@ do
|
||||
# Waits while shutdown does it's stuff, without this sleep, the message above gets redisplayed.
|
||||
sleep 30
|
||||
else
|
||||
printf "[`date`] Although auto reboot requested, a transfer error occurred, waiting for user to review transfer.log\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Although auto reboot requested, a transfer error occurred, waiting for user to review transfer.log\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -776,7 +779,7 @@ do
|
||||
then
|
||||
init 0
|
||||
else
|
||||
printf "[`date`] Although auto power off requested, a transfer error occurred, so wait for user to review transfer.log\n" 2>&1 | tee -a transfer.log
|
||||
printf "[`date "$date_format"`] Although auto power off requested, a transfer error occurred, so wait for user to review transfer.log\n" 2>&1 | tee -a transfer.log
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -784,7 +787,26 @@ do
|
||||
while [ "$exitloop" == "1" ]
|
||||
do
|
||||
printf ""
|
||||
printf "Paused, press r to reboot, s to shutdown, spacebar to restart nwipe.\n"
|
||||
|
||||
# Are there any *.pdf certificates left in the '/' of the shredos virtual drive? i.e. did transfer to USB
|
||||
# or to a network server fail? If yes then change the 'reboot, shutdown, restart nwipe' message to include a
|
||||
# option to archive to USB. So in the event of something going wrong, like the USB stick is missing or the
|
||||
# network or server is offline, this allows the user to archive the certificates to a FAT formatted USB
|
||||
# drive. Note once PDF files/logs have been sent to USB or network server they are moved from '/' to '/sent/'
|
||||
# hence why we only search '/' for pdfs.
|
||||
#
|
||||
grep -i "Model" /*.pdf 2>/dev/null
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
printf ">> WARNING << There are PDF's that have not been saved, plug in a USB drive\n"
|
||||
printf " and press the 'a' key to archive to USB.\n\n"
|
||||
printf "Paused, press r=reboot, s=shutdown, a=archive to USB, spacebar=restart nwipe.\n"
|
||||
Final_message_plus=1
|
||||
else
|
||||
printf "[GOOD] All PDFs and logs have been saved\n\n"
|
||||
printf "Paused.. press r to reboot, s to shutdown, spacebar to restart nwipe.\n"
|
||||
Final_message_plus=0
|
||||
fi
|
||||
printf ">"
|
||||
read -rsn1 input
|
||||
printf "\n"
|
||||
@@ -803,6 +825,14 @@ do
|
||||
sleep 10
|
||||
;;
|
||||
|
||||
A)
|
||||
if [ $Final_message_plus == 1 ]
|
||||
then
|
||||
# no need to tee the output of archive_log.sh, it's done in the script.
|
||||
archive_log.sh write
|
||||
fi
|
||||
;;
|
||||
|
||||
'')
|
||||
printf "Restart Nwipe\n"
|
||||
exitloop="0"
|
||||
|
||||
Reference in New Issue
Block a user