Simplify scripts for testing

pull/46/head
Dan Puttick 2017-01-11 11:34:09 -05:00
parent fca8ac922c
commit 733b5fd637
5 changed files with 61 additions and 71 deletions

View File

@ -19,25 +19,19 @@ clean(){
/sbin/shutdown -P -h now
}
trap clean EXIT TERM INT
echo "GROOMER: end of boot, running rc.local."
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
if [ -e /dev/sda ]; then
if [ -e /dev/sdb ]; then
# if [ -e /dev/sda ]; then
# if [ -e /dev/sdb ]; then
# avoid possible misuse
/sbin/ifconfig eth0 down
trap clean EXIT TERM INT
cd /opt/groomer
/usr/sbin/led &
./init.sh
fi
fi
#fdisk -l
echo "Testing, did anything happen." >> /var/tmp/thing.txt
sleep 60
cd /opt/groomer
./init.sh | tee "/var/tmp/groomer_log.txt"
sleep 20
exit 0

View File

@ -1,5 +1,6 @@
DEV_SRC='/dev/sda'
DEV_DST='sdb1'
DEV_SRCONE='dev/sda1'
DEV_DST='/dev/sdb1'
# User allowed to do the following commands without password
USERNAME='kitten'
@ -17,7 +18,6 @@ GROOM_LOG="/var/tmp/groomer_log.txt"
# commands
SYNC='/bin/sync'
TIMIDITY='/usr/bin/timidity'
MOUNT='/bin/mount'
PMOUNT='/usr/bin/pmount -A -s'
PUMOUNT='/usr/bin/pumount'

View File

@ -13,12 +13,14 @@ clean(){
echo "GROOMER: Cleaning up after groomer.sh."
${SYNC}
cp "${GROOM_LOG} ${SRC}/groomer_log.txt"
cp "${GROOM_LOG} ${DST}/groomer_log.txt"
# 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}
@ -31,19 +33,17 @@ trap clean EXIT TERM INT
# De we have a source device
if [ ! -b ${DEV_SRC} ]; then
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 "GROOMER: ${DEV_SRC} does not have any partitions."
exit
fi
# Do we have a destination device
if [ ! -b "/dev/${DEV_DST}" ]; then
if [ ! -b "${DEV_DST}" ]; then
echo "GROOMER: Destination device (/dev/${DEV_DST}) does not exist."
exit
fi
# mount and prepare destination device
@ -53,21 +53,23 @@ 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 "GROOMER: Unable to mount /dev/${DEV_DST} on /media/${DST}"
echo "GROOMER: Unable to mount /dev/${DEV_DST} on ${DST}"
exit
else
echo "GROOMER: Target USB device (/dev/${DEV_DST}) mounted at /media/${DST}"
rm -rf "/media/${DST}/FROM_PARTITION_"*
echo "GROOMER: Target USB device (/dev/${DEV_DST}) mounted at ${DST}"
# rm -rf "/media/${DST}/FROM_PARTITION_"*
# prepare temp dirs and make sure it's empty
mkdir -p "${TEMP}"
mkdir -p "${ZIPTEMP}"
mkdir -p "${LOGS}"
# mkdir -p "${TEMP}"
# mkdir -p "${ZIPTEMP}"
# mkdir -p "${LOGS}"
rm -rf "${TEMP}/"*
rm -rf "${ZIPTEMP}/"*
rm -rf "${LOGS}/"*
# rm -rf "${TEMP}/"*
# rm -rf "${ZIPTEMP}/"*
# rm -rf "${LOGS}/"*
fi
${PMOUNT} -w ${DEV_SRCONE} ${SRC}
sleep 30
@ -76,41 +78,41 @@ sleep 30
# Find the FS types
# lsblk -n -o name,fstype,mountpoint,label,uuid -r
PARTCOUNT=1
for partition in ${DEV_PARTITIONS}
do
# Processing a partition
echo "GROOMER: Processing partition ${partition}"
if [ `${MOUNT} | grep -c ${SRC}` -ne 0 ]; then
${PUMOUNT} ${SRC}
fi
# PARTCOUNT=1
# for partition in ${DEV_PARTITIONS}
# do
# # Processing a partition
# echo "GROOMER: Processing partition ${partition}"
# if [ `${MOUNT} | grep -c ${SRC}` -ne 0 ]; then
# ${PUMOUNT} ${SRC}
# fi
${PMOUNT} -w ${partition} ${SRC}
ls "/media/${SRC}" | grep -i autorun.inf | xargs -I {} mv "/media/${SRC}"/{} "/media/${SRC}"/DANGEROUS_{}_DANGEROUS || true
${PUMOUNT} ${SRC}
${PMOUNT} -r ${partition} ${SRC}
if [ ${?} -ne 0 ]; then
echo "GROOMER: Unable to mount ${partition} on /media/${SRC}"
else
echo "GROOMER: ${partition} mounted at /media/${SRC}"
# ${PMOUNT} -w ${partition} ${SRC}
# ls "/media/${SRC}" | grep -i autorun.inf | xargs -I {} mv "/media/${SRC}"/{} "/media/${SRC}"/DANGEROUS_{}_DANGEROUS || true
# ${PUMOUNT} ${SRC}
# ${PMOUNT} -r ${partition} ${SRC}
# if [ ${?} -ne 0 ]; then
# echo "GROOMER: Unable to mount ${partition} on /media/${SRC}"
# else
# 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"
# # 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 "GROOMER: Copying to ${target_dir}"
mkdir -p "${target_dir}"
LOGFILE="${LOGS}/processing.txt"
# # create a directory on ${DST} named PARTION_$PARTCOUNT
# target_dir="/media/${DST}/FROM_PARTITION_${PARTCOUNT}"
# echo "GROOMER: Copying to ${target_dir}"
# mkdir -p "${target_dir}"
# LOGFILE="${LOGS}/processing.txt"
echo "GROOMER: ==== Starting processing of /media/${SRC} to ${target_dir}. ====" >> ${LOGFILE}
filecheck.py --source /media/${SRC} --destination ${target_dir} || true
echo "GROOMER: ==== Done with /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 "GROOMER: ==== Done with /media/${SRC} to ${target_dir}. ====" >> ${LOGFILE}
ls -lR "${target_dir}"
fi
let PARTCOUNT=`expr $PARTCOUNT + 1`
done
# ls -lR "${target_dir}"
# fi
# let PARTCOUNT=`expr $PARTCOUNT + 1`
# done
# The cleanup is automatically done in the function clean called when
# the program quits

View File

@ -13,14 +13,8 @@ fi
clean(){
echo "GROOMER: cleaning up after init.sh."
${SYNC}
kill -9 $(cat /tmp/music.pid)
rm -f /tmp/music.pid
}
trap clean EXIT TERM INT
./music.sh &
echo $! > /tmp/music.pid
echo "GROOMER: music started."
su ${USERNAME} -c ./groomer.sh | tee ${GROOM_LOG}
su ${USERNAME} -c ./groomer.sh

View File

@ -3,7 +3,7 @@
set -e
set -x
mount /dev/sdb2 /mnt/rpi
# 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