Clean up echo statements and add echo statements

pull/46/head
Dan Puttick 2017-01-10 22:03:33 -05:00
parent d5e73354c2
commit fca8ac922c
5 changed files with 40 additions and 19 deletions

View File

@ -15,10 +15,12 @@
# been modified to start the grooming process on boot.
clean(){
echo 'Rc Local done, quit.'
echo "GROOMER: rc.local done, shutting down."
/sbin/shutdown -P -h now
}
echo "GROOMER: end of boot, running rc.local."
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
@ -36,4 +38,6 @@ if [ -e /dev/sda ]; then
fi
fi
sleep 60
exit 0

View File

@ -13,7 +13,7 @@ DST="dst"
TEMP="/media/${DST}/temp"
ZIPTEMP="/media/${DST}/ziptemp"
LOGS="/media/${DST}/logs"
GROOM_LOG="/var/tmp/groomer_log.txt"
# commands
SYNC='/bin/sync'

View File

@ -5,18 +5,20 @@ set -x
source ./constraint.sh
if ! [ "${ID}" -ge "1000" ]; then
echo "This script cannot run as root."
echo "GROOMER: This script cannot run as root."
exit
fi
clean(){
echo Cleaning.
echo "GROOMER: Cleaning up after groomer.sh."
${SYNC}
# Cleanup source
cp ${GROOM_LOG} ${SRC}/groomer_log.txt
pumount ${SRC}
# Cleanup destination
cp ${GROOM_LOG} ${LOGS}/groomer_log.txt
rm -rf ${TEMP}
rm -rf ${ZIPTEMP}
pumount ${DST}
@ -28,19 +30,19 @@ trap clean EXIT TERM INT
# De we have a source device
if [ ! -b ${DEV_SRC} ]; then
echo "Source device (${DEV_SRC}) does not exists."
echo "GROOMER: Source device (${DEV_SRC}) does not exist."
exit
fi
# Find the partition names on the source device
DEV_PARTITIONS=`ls "${DEV_SRC}"* | grep "${DEV_SRC}[1-9][0-6]*" || true`
if [ -z "${DEV_PARTITIONS}" ]; then
echo "${DEV_SRC} does not have any partitions."
echo "GROOMER: ${DEV_SRC} does not have any partitions."
exit
fi
# Do we have a destination device
if [ ! -b "/dev/${DEV_DST}" ]; then
echo "Destination device (/dev/${DEV_DST}) does not exists."
echo "GROOMER: Destination device (/dev/${DEV_DST}) does not exist."
exit
fi
@ -51,10 +53,10 @@ fi
# uid= only works on a vfat FS. What should wedo if we get an ext* FS ?
${PMOUNT} -w ${DEV_DST} ${DST}
if [ ${?} -ne 0 ]; then
echo "Unable to mount /dev/${DEV_DST} on /media/${DST}"
echo "GROOMER: Unable to mount /dev/${DEV_DST} on /media/${DST}"
exit
else
echo "Target USB device (/dev/${DEV_DST}) mounted at /media/${DST}"
echo "GROOMER: Target USB device (/dev/${DEV_DST}) mounted at /media/${DST}"
rm -rf "/media/${DST}/FROM_PARTITION_"*
# prepare temp dirs and make sure it's empty
@ -67,6 +69,8 @@ else
rm -rf "${LOGS}/"*
fi
sleep 30
# Groom da kitteh!
# Find the FS types
@ -76,7 +80,7 @@ PARTCOUNT=1
for partition in ${DEV_PARTITIONS}
do
# Processing a partition
echo "Processing partition: ${partition}"
echo "GROOMER: Processing partition ${partition}"
if [ `${MOUNT} | grep -c ${SRC}` -ne 0 ]; then
${PUMOUNT} ${SRC}
fi
@ -86,22 +90,22 @@ do
${PUMOUNT} ${SRC}
${PMOUNT} -r ${partition} ${SRC}
if [ ${?} -ne 0 ]; then
echo "Unable to mount ${partition} on /media/${SRC}"
echo "GROOMER: Unable to mount ${partition} on /media/${SRC}"
else
echo "${partition} mounted at /media/${SRC}"
echo "GROOMER: ${partition} mounted at /media/${SRC}"
# Print the filenames on the current partition in a logfile
find "/media/${SRC}" -fls "${LOGS}/Content_partition_${PARTCOUNT}.txt"
# create a directory on ${DST} named PARTION_$PARTCOUNT
target_dir="/media/${DST}/FROM_PARTITION_${PARTCOUNT}"
echo "copying to: ${target_dir}"
echo "GROOMER: Copying to ${target_dir}"
mkdir -p "${target_dir}"
LOGFILE="${LOGS}/processing.txt"
echo "==== Starting processing of /media/${SRC} to ${target_dir}. ====" >> ${LOGFILE}
echo "GROOMER: ==== Starting processing of /media/${SRC} to ${target_dir}. ====" >> ${LOGFILE}
filecheck.py --source /media/${SRC} --destination ${target_dir} || true
echo "==== Done with /media/${SRC} to ${target_dir}. ====" >> ${LOGFILE}
echo "GROOMER: ==== Done with /media/${SRC} to ${target_dir}. ====" >> ${LOGFILE}
ls -lR "${target_dir}"
fi

View File

@ -6,12 +6,12 @@ set -x
source ./constraint.sh
if [ ${ID} -ne 0 ]; then
echo "This script has to be run as root."
echo "GROOMER: This script has to be run as root."
exit
fi
clean(){
echo Done, cleaning.
echo "GROOMER: cleaning up after init.sh."
${SYNC}
kill -9 $(cat /tmp/music.pid)
rm -f /tmp/music.pid
@ -21,6 +21,6 @@ trap clean EXIT TERM INT
./music.sh &
echo $! > /tmp/music.pid
echo "GROOMER: music started."
su ${USERNAME} -c ./groomer.sh
su ${USERNAME} -c ./groomer.sh | tee ${GROOM_LOG}

View File

@ -0,0 +1,13 @@
#!/bin/bash
set -e
set -x
mount /dev/sdb2 /mnt/rpi
cp /media/sf_ubuntu-shared/Circlean-Ubuntu/fs_filecheck/opt/groomer/init.sh /mnt/rpi/opt/groomer/init.sh
cp /media/sf_ubuntu-shared/Circlean-Ubuntu/fs_filecheck/opt/groomer/groomer.sh /mnt/rpi/opt/groomer/groomer.sh
cp /media/sf_ubuntu-shared/Circlean-Ubuntu/fs_filecheck/opt/groomer/constraint.sh /mnt/rpi/opt/groomer/constraint.sh
cp /media/sf_ubuntu-shared/Circlean-Ubuntu/fs_filecheck/etc/rc.local /mnt/rpi/etc/rc.local
umount /mnt/rpi