mirror of
https://github.com/PartialVolume/shredos.x86_64.git
synced 2026-02-20 05:32:11 +00:00
- Nwipe reads /etc/nwipe/nwipe.conf and /etc/nwipe/nwipe_customers.csv from the USB flash drive at boot. Nwipe now writes /etc/nwipe/nwipe.conf and /etc/nwipe/nwipe_customers.csv from ShredOS's ram drive back to USB flash drive on nwipe exit. This means any changes to nwipe's configuration via nwipes configuration screen or any changes manually made to the files will be saved back to the flash drive. Initial commit, further debugging of nwipe.conf restore from USB to ram drive required.
This commit is contained in:
@@ -1,12 +1,41 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This script will archive the nwipe log file/s and dmesg.txt file to a
|
||||
# FAT32 formatted partition. If there is more than one FAT32 drive this
|
||||
# script will always archive to the first drive found.
|
||||
# This script will archive the nwipe log file/s, dmesg.txt files and PDF certificates
|
||||
# to the first FAT32 formatted partition found, which should normally be the ShredOS
|
||||
# USB flash drive. If there is more than one FAT32 drive this script will always
|
||||
# archive to the first drive found. This is independant of the mode of operation, the
|
||||
# log, dmesg and PDF files will always be written from ShredOS's RAM drive to the USB
|
||||
# flash drive.
|
||||
#
|
||||
# It also checks whether /etc/nwipe/nwipe.conf and /etc/nwipe/customers.csv exist
|
||||
# on the USB flash drive and assuming mode 0, read (-r argument) has been selected will
|
||||
# read those two files from the USB drive into ShredOS's RAM disc, this is normally done
|
||||
# prior to nwipe launch. Alternatively if mode 1, write (-w argument) is selected both
|
||||
# /etc/nwipe/nwipe.conf and /etc/nwipe/customers.csv are copied from ShredOS's RAM
|
||||
# disc back to the USB flash drive, which is normally done on Nwipe exit.
|
||||
#
|
||||
# Written by PartialVolume, a component of ShredOS - the disk eraser.
|
||||
|
||||
exit_code=0
|
||||
mode=""
|
||||
|
||||
# What mode is required (read or write)
|
||||
while getopts 'rw' opt; do
|
||||
case "$opt" in
|
||||
r)
|
||||
mode="read"
|
||||
;;
|
||||
|
||||
w)
|
||||
mode="write"
|
||||
;;
|
||||
|
||||
?)
|
||||
echo -e "Invalid command option.\nUsage: $(basename $0) [-r] [-w]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is the temporary directory that the FAT32 drive is to be mounted on
|
||||
archive_drive_directory="/archive_drive"
|
||||
@@ -46,13 +75,20 @@ else
|
||||
# Copy the dmesg.txt and PDF files over to the FAT32 partition
|
||||
dmesg > dmesg.txt
|
||||
cp /dmesg.txt "$archive_drive_directory/"
|
||||
cp /nwipe_report_*pdf "$archive_drive_directory/"
|
||||
if [ $? != 0 ]; then
|
||||
printf "archive_log.sh: Unable to copy the dmesg.txt file to the root of $drive:/\n"
|
||||
else
|
||||
printf "archive_log.sh: Sucessfully copied dmesg.txt to $drive:/\n"
|
||||
fi
|
||||
|
||||
# Copy the PDF certificates over to the FAT32 partition
|
||||
cp /nwipe_report_*pdf "$archive_drive_directory/"
|
||||
if [ $? != 0 ]; then
|
||||
printf "archive_log.sh: Unable to copy the nwipe_report...pdf file to the root of $drive:/\n"
|
||||
else
|
||||
printf "archive_log.sh: Sucessfully copied nwipe_report...pdf to $drive:/\n"
|
||||
fi
|
||||
|
||||
# Copy the nwipe log files over to the FAT32 partition
|
||||
cp /nwipe_log* "$archive_drive_directory/"
|
||||
if [ $? != 0 ]; then
|
||||
@@ -72,13 +108,112 @@ else
|
||||
if [ exit_code != 5 ]; then
|
||||
# Move the nwipe logs into the RAM disc sent directory
|
||||
mv /nwipe_log* "$sent_directory/"
|
||||
mv /nwipe_report*pdf "$sent_directory/"
|
||||
if [ $? != 0 ]; then
|
||||
printf "archive_log.sh: Unable to move the nwipe logs into the $sent_directory on the RAM disc\n"
|
||||
exit_code=6
|
||||
else
|
||||
printf "archive_log.sh: Moved the nwipe logs into the $sent_directory\n"
|
||||
fi
|
||||
# Move the nwipe PDF certificates into the RAM disc sent directory
|
||||
mv /nwipe_report*pdf "$sent_directory/"
|
||||
if [ $? != 0 ]; then
|
||||
printf "archive_log.sh: Unable to move the PDF certificates into the $sent_directory on the RAM disc\n"
|
||||
else
|
||||
printf "archive_log.sh: Moved the PDF certificates into the $sent_directory\n"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
# If mode 0 (read USB flash drive), read the /etc/nwipe/nwipe.conf and /etc/nwipe/customers.csv files from
|
||||
# the USB flash drive into the ShredOS RAM disc
|
||||
#
|
||||
#
|
||||
# Check that the /etc/nwipe directory exists on the ShredOS ram drive, if not create it.
|
||||
test -d "/etc/nwipe"
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
mkdir "/etc/nwipe"
|
||||
if [ $? != 0 ]; then
|
||||
printf "archive_log.sh: Unable to create directory /etc/nwipe on ShredOS ram drive\n"
|
||||
else
|
||||
printf "archive_log.sh: Successfully created directory /etc/nwipe on ShredOS ram drive\n"
|
||||
fi
|
||||
fi
|
||||
if [[ "$mode" == "read" ]]; then
|
||||
# Copy /etc/nwipe/nwipe.conf from USB to ShredOS's ram disc
|
||||
test -f "$archive_drive_directory/etc/nwipe/nwipe.conf"
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
# Copy nwipe.conf from USB flash to ShredOS ram disc
|
||||
cp "$archive_drive_directory/etc/nwipe/nwipe.conf" /etc/nwipe.conf
|
||||
if [ $? != 0 ]; then
|
||||
printf "archive_log.sh: Unable to copy $drive:/etc/nwipe/nwipe.conf to ShredOS's ram disc\n"
|
||||
else
|
||||
printf "archive_log.sh: Sucessfully copied $drive:/etc/nwipe/nwipe.conf to ShredOS's ram disc\n"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Copy /etc/nwipe/customers.csv from USB to ShredOS's ram disc
|
||||
test -f "$archive_drive_directory/etc/nwipe/nwipe_customers.csv"
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
# 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 "archive_log.sh: Unable to copy $drive:/etc/nwipe/nwipe_customers.csv to /etc/nwipe/nwipe_customers.csv\n"
|
||||
else
|
||||
printf "archive_log.sh: Sucessfully copied $drive:/etc/nwipe/nwipe_customers.csv to /etc/nwipe/nwipe_customers.csv\n"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
# If mode 1 (write USB flash drive), write the /etc/nwipe/nwipe.conf and /etc/nwipe/customers.csv files to
|
||||
# the USB flash drive from the ShredOS RAM disc.
|
||||
#
|
||||
#
|
||||
# Check the /etc/ and /etc/nwipe directories exist on the USB drive, if not create them
|
||||
test -d "$archive_drive_directory/etc"
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
mkdir "$archive_drive_directory/etc"
|
||||
if [ $? != 0 ]; then
|
||||
printf "archive_log.sh: Unable to create directory /etc on $drive:/\n"
|
||||
else
|
||||
printf "archive_log.sh: Successfully created directory /etc on $drive:/\n"
|
||||
fi
|
||||
fi
|
||||
|
||||
test -d "$archive_drive_directory/etc/nwipe"
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
mkdir "$archive_drive_directory/etc/nwipe"
|
||||
if [ $? != 0 ]; then
|
||||
printf "archive_log.sh: Unable to create directory /etc/nwipe on $drive:/\n"
|
||||
else
|
||||
printf "archive_log.sh: Successfully created directory /etc/nwipe on $drive:/\n"
|
||||
fi
|
||||
fi
|
||||
if [[ "$mode" == "write" ]]; then
|
||||
# Copy /etc/nwipe/nwipe.conf from ShredOS's ram disc to USB
|
||||
test -f "/etc/nwipe/nwipe.conf"
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
cp /etc/nwipe/nwipe.conf "$archive_drive_directory/etc/nwipe/nwipe.conf"
|
||||
if [ $? != 0 ]; then
|
||||
printf "archive_log.sh: Unable to copy /etc/nwipe/nwipe.conf to $drive:/etc/nwipe/nwipe.conf\n"
|
||||
else
|
||||
printf "archive_log.sh: Successfully copied /etc/nwipe/nwipe.conf to $drive:/etc/nwipe/nwipe.conf\n"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Copy /etc/nwipe/customers.csv from ShredOS's ram disc to USB
|
||||
test -f "/etc/nwipe/nwipe_customers.csv"
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
cp /etc/nwipe/nwipe_customers.csv "$archive_drive_directory/etc/nwipe/nwipe_customers.csv"
|
||||
if [ $? != 0 ]; then
|
||||
printf "archive_log.sh: Unable to copy /etc/nwipe/nwipe_customers.csv file to the root of $drive:/etc/nwipe/nwipe_customers.csv\n"
|
||||
else
|
||||
printf "archive_log.sh: Successfully copied /etc/nwipe/nwipe_customers.csv to $drive:/etc/nwipe/nwipe_customers.csv\n"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -34,9 +34,13 @@ while [ 1 ]; do
|
||||
fi
|
||||
done
|
||||
printf "\n"
|
||||
|
||||
# archive dmesg.txt and nwipe logs prior to launching nwipe. This is done just
|
||||
# in case there are any display issues and we want to take a look at the dmesg data.
|
||||
/usr/bin/archive_log.sh
|
||||
#
|
||||
# archive_log.sh -r also reads the /etc/nwipe/nwipe.conf and /etc/nwipe/customers.csv
|
||||
# files from the USB flash drive to ShredOS's ram disc
|
||||
/usr/bin/archive_log.sh -r
|
||||
|
||||
# initialise
|
||||
#
|
||||
@@ -173,7 +177,13 @@ then
|
||||
fi
|
||||
fi
|
||||
|
||||
/usr/bin/archive_log.sh
|
||||
# Now nwipe has exited, archive dmesg.txt, nwipe logs and PDF certificates to USB
|
||||
# flash drive. This is done just in case there are any display issues and we want
|
||||
# to take a look at the dmesg data.
|
||||
#
|
||||
# archive_log.sh -w also writes the /etc/nwipe/nwipe.conf and /etc/nwipe/customers.csv
|
||||
# files to the USB flash drive from ShredOS's ram disc.
|
||||
/usr/bin/archive_log.sh -w
|
||||
|
||||
# If the user specified --autopoweroff as a nwipe option then shutdown now
|
||||
#
|
||||
|
||||
@@ -18,7 +18,7 @@ BR2_ROOTFS_OVERLAY="board/shredos/fsoverlay"
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="board/shredos/doimg.sh"
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/shredos/kernel-6.3-defconfig.config"
|
||||
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/shredos/kernel-6.4-defconfig.config"
|
||||
BR2_PACKAGE_LINUX_TOOLS_CPUPOWER=y
|
||||
BR2_PACKAGE_LINUX_TOOLS_PERF=y
|
||||
BR2_PACKAGE_LINUX_TOOLS_SELFTESTS=y
|
||||
@@ -41,6 +41,7 @@ BR2_PACKAGE_DOSFSTOOLS_FATLABEL=y
|
||||
BR2_PACKAGE_DOSFSTOOLS_FSCK_FAT=y
|
||||
BR2_PACKAGE_DOSFSTOOLS_MKFS_FAT=y
|
||||
BR2_PACKAGE_E2FSPROGS=y
|
||||
BR2_PACKAGE_EXFATPROGS=y
|
||||
BR2_PACKAGE_ASCII_INVADERS=y
|
||||
BR2_PACKAGE_DIRECTFB=y
|
||||
BR2_PACKAGE_DIRECTFB_ATI128=y
|
||||
|
||||
Reference in New Issue
Block a user