mirror of https://github.com/CIRCL/Circlean
Simplify scripts for testing
parent
fca8ac922c
commit
733b5fd637
|
@ -19,25 +19,19 @@ clean(){
|
||||||
/sbin/shutdown -P -h now
|
/sbin/shutdown -P -h now
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trap clean EXIT TERM INT
|
||||||
|
|
||||||
echo "GROOMER: end of boot, running rc.local."
|
echo "GROOMER: end of boot, running rc.local."
|
||||||
|
|
||||||
# Print the IP address
|
# if [ -e /dev/sda ]; then
|
||||||
_IP=$(hostname -I) || true
|
# if [ -e /dev/sdb ]; then
|
||||||
if [ "$_IP" ]; then
|
|
||||||
printf "My IP address is %s\n" "$_IP"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -e /dev/sda ]; then
|
|
||||||
if [ -e /dev/sdb ]; then
|
|
||||||
# avoid possible misuse
|
# avoid possible misuse
|
||||||
/sbin/ifconfig eth0 down
|
#fdisk -l
|
||||||
trap clean EXIT TERM INT
|
echo "Testing, did anything happen." >> /var/tmp/thing.txt
|
||||||
cd /opt/groomer
|
|
||||||
/usr/sbin/led &
|
|
||||||
./init.sh
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
sleep 60
|
cd /opt/groomer
|
||||||
|
./init.sh | tee "/var/tmp/groomer_log.txt"
|
||||||
|
|
||||||
|
sleep 20
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
DEV_SRC='/dev/sda'
|
DEV_SRC='/dev/sda'
|
||||||
DEV_DST='sdb1'
|
DEV_SRCONE='dev/sda1'
|
||||||
|
DEV_DST='/dev/sdb1'
|
||||||
|
|
||||||
# User allowed to do the following commands without password
|
# User allowed to do the following commands without password
|
||||||
USERNAME='kitten'
|
USERNAME='kitten'
|
||||||
|
@ -17,7 +18,6 @@ GROOM_LOG="/var/tmp/groomer_log.txt"
|
||||||
|
|
||||||
# commands
|
# commands
|
||||||
SYNC='/bin/sync'
|
SYNC='/bin/sync'
|
||||||
TIMIDITY='/usr/bin/timidity'
|
|
||||||
MOUNT='/bin/mount'
|
MOUNT='/bin/mount'
|
||||||
PMOUNT='/usr/bin/pmount -A -s'
|
PMOUNT='/usr/bin/pmount -A -s'
|
||||||
PUMOUNT='/usr/bin/pumount'
|
PUMOUNT='/usr/bin/pumount'
|
||||||
|
|
|
@ -13,12 +13,14 @@ clean(){
|
||||||
echo "GROOMER: Cleaning up after groomer.sh."
|
echo "GROOMER: Cleaning up after groomer.sh."
|
||||||
${SYNC}
|
${SYNC}
|
||||||
|
|
||||||
|
cp "${GROOM_LOG} ${SRC}/groomer_log.txt"
|
||||||
|
cp "${GROOM_LOG} ${DST}/groomer_log.txt"
|
||||||
|
|
||||||
# Cleanup source
|
# Cleanup source
|
||||||
cp ${GROOM_LOG} ${SRC}/groomer_log.txt
|
|
||||||
pumount ${SRC}
|
pumount ${SRC}
|
||||||
|
|
||||||
# Cleanup destination
|
# Cleanup destination
|
||||||
cp ${GROOM_LOG} ${LOGS}/groomer_log.txt
|
|
||||||
rm -rf ${TEMP}
|
rm -rf ${TEMP}
|
||||||
rm -rf ${ZIPTEMP}
|
rm -rf ${ZIPTEMP}
|
||||||
pumount ${DST}
|
pumount ${DST}
|
||||||
|
@ -31,19 +33,17 @@ trap clean EXIT TERM INT
|
||||||
# De we have a source device
|
# De we have a source device
|
||||||
if [ ! -b ${DEV_SRC} ]; then
|
if [ ! -b ${DEV_SRC} ]; then
|
||||||
echo "GROOMER: Source device (${DEV_SRC}) does not exist."
|
echo "GROOMER: Source device (${DEV_SRC}) does not exist."
|
||||||
exit
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Find the partition names on the source device
|
# Find the partition names on the source device
|
||||||
DEV_PARTITIONS=`ls "${DEV_SRC}"* | grep "${DEV_SRC}[1-9][0-6]*" || true`
|
DEV_PARTITIONS=`ls "${DEV_SRC}"* | grep "${DEV_SRC}[1-9][0-6]*" || true`
|
||||||
if [ -z "${DEV_PARTITIONS}" ]; then
|
if [ -z "${DEV_PARTITIONS}" ]; then
|
||||||
echo "GROOMER: ${DEV_SRC} does not have any partitions."
|
echo "GROOMER: ${DEV_SRC} does not have any partitions."
|
||||||
exit
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Do we have a destination device
|
# 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."
|
echo "GROOMER: Destination device (/dev/${DEV_DST}) does not exist."
|
||||||
exit
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# mount and prepare destination device
|
# 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 ?
|
# uid= only works on a vfat FS. What should wedo if we get an ext* FS ?
|
||||||
${PMOUNT} -w ${DEV_DST} ${DST}
|
${PMOUNT} -w ${DEV_DST} ${DST}
|
||||||
if [ ${?} -ne 0 ]; then
|
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
|
exit
|
||||||
else
|
else
|
||||||
echo "GROOMER: Target USB device (/dev/${DEV_DST}) mounted at /media/${DST}"
|
echo "GROOMER: Target USB device (/dev/${DEV_DST}) mounted at ${DST}"
|
||||||
rm -rf "/media/${DST}/FROM_PARTITION_"*
|
|
||||||
|
# rm -rf "/media/${DST}/FROM_PARTITION_"*
|
||||||
|
|
||||||
# prepare temp dirs and make sure it's empty
|
# prepare temp dirs and make sure it's empty
|
||||||
mkdir -p "${TEMP}"
|
# mkdir -p "${TEMP}"
|
||||||
mkdir -p "${ZIPTEMP}"
|
# mkdir -p "${ZIPTEMP}"
|
||||||
mkdir -p "${LOGS}"
|
# mkdir -p "${LOGS}"
|
||||||
|
|
||||||
rm -rf "${TEMP}/"*
|
# rm -rf "${TEMP}/"*
|
||||||
rm -rf "${ZIPTEMP}/"*
|
# rm -rf "${ZIPTEMP}/"*
|
||||||
rm -rf "${LOGS}/"*
|
# rm -rf "${LOGS}/"*
|
||||||
fi
|
fi
|
||||||
|
${PMOUNT} -w ${DEV_SRCONE} ${SRC}
|
||||||
|
|
||||||
sleep 30
|
sleep 30
|
||||||
|
|
||||||
|
@ -76,41 +78,41 @@ sleep 30
|
||||||
# Find the FS types
|
# Find the FS types
|
||||||
# lsblk -n -o name,fstype,mountpoint,label,uuid -r
|
# lsblk -n -o name,fstype,mountpoint,label,uuid -r
|
||||||
|
|
||||||
PARTCOUNT=1
|
# PARTCOUNT=1
|
||||||
for partition in ${DEV_PARTITIONS}
|
# for partition in ${DEV_PARTITIONS}
|
||||||
do
|
# do
|
||||||
# Processing a partition
|
# # Processing a partition
|
||||||
echo "GROOMER: Processing partition ${partition}"
|
# echo "GROOMER: Processing partition ${partition}"
|
||||||
if [ `${MOUNT} | grep -c ${SRC}` -ne 0 ]; then
|
# if [ `${MOUNT} | grep -c ${SRC}` -ne 0 ]; then
|
||||||
${PUMOUNT} ${SRC}
|
# ${PUMOUNT} ${SRC}
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
${PMOUNT} -w ${partition} ${SRC}
|
# ${PMOUNT} -w ${partition} ${SRC}
|
||||||
ls "/media/${SRC}" | grep -i autorun.inf | xargs -I {} mv "/media/${SRC}"/{} "/media/${SRC}"/DANGEROUS_{}_DANGEROUS || true
|
# ls "/media/${SRC}" | grep -i autorun.inf | xargs -I {} mv "/media/${SRC}"/{} "/media/${SRC}"/DANGEROUS_{}_DANGEROUS || true
|
||||||
${PUMOUNT} ${SRC}
|
# ${PUMOUNT} ${SRC}
|
||||||
${PMOUNT} -r ${partition} ${SRC}
|
# ${PMOUNT} -r ${partition} ${SRC}
|
||||||
if [ ${?} -ne 0 ]; then
|
# if [ ${?} -ne 0 ]; then
|
||||||
echo "GROOMER: Unable to mount ${partition} on /media/${SRC}"
|
# echo "GROOMER: Unable to mount ${partition} on /media/${SRC}"
|
||||||
else
|
# else
|
||||||
echo "GROOMER: ${partition} mounted at /media/${SRC}"
|
# echo "GROOMER: ${partition} mounted at /media/${SRC}"
|
||||||
|
|
||||||
# Print the filenames on the current partition in a logfile
|
# # Print the filenames on the current partition in a logfile
|
||||||
find "/media/${SRC}" -fls "${LOGS}/Content_partition_${PARTCOUNT}.txt"
|
# find "/media/${SRC}" -fls "${LOGS}/Content_partition_${PARTCOUNT}.txt"
|
||||||
|
|
||||||
# create a directory on ${DST} named PARTION_$PARTCOUNT
|
# # create a directory on ${DST} named PARTION_$PARTCOUNT
|
||||||
target_dir="/media/${DST}/FROM_PARTITION_${PARTCOUNT}"
|
# target_dir="/media/${DST}/FROM_PARTITION_${PARTCOUNT}"
|
||||||
echo "GROOMER: Copying to ${target_dir}"
|
# echo "GROOMER: Copying to ${target_dir}"
|
||||||
mkdir -p "${target_dir}"
|
# mkdir -p "${target_dir}"
|
||||||
LOGFILE="${LOGS}/processing.txt"
|
# LOGFILE="${LOGS}/processing.txt"
|
||||||
|
|
||||||
echo "GROOMER: ==== 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
|
# filecheck.py --source /media/${SRC} --destination ${target_dir} || true
|
||||||
echo "GROOMER: ==== Done with /media/${SRC} to ${target_dir}. ====" >> ${LOGFILE}
|
# echo "GROOMER: ==== Done with /media/${SRC} to ${target_dir}. ====" >> ${LOGFILE}
|
||||||
|
|
||||||
ls -lR "${target_dir}"
|
# ls -lR "${target_dir}"
|
||||||
fi
|
# fi
|
||||||
let PARTCOUNT=`expr $PARTCOUNT + 1`
|
# let PARTCOUNT=`expr $PARTCOUNT + 1`
|
||||||
done
|
# done
|
||||||
|
|
||||||
# The cleanup is automatically done in the function clean called when
|
# The cleanup is automatically done in the function clean called when
|
||||||
# the program quits
|
# the program quits
|
||||||
|
|
|
@ -13,14 +13,8 @@ fi
|
||||||
clean(){
|
clean(){
|
||||||
echo "GROOMER: cleaning up after init.sh."
|
echo "GROOMER: cleaning up after init.sh."
|
||||||
${SYNC}
|
${SYNC}
|
||||||
kill -9 $(cat /tmp/music.pid)
|
|
||||||
rm -f /tmp/music.pid
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trap clean EXIT TERM INT
|
trap clean EXIT TERM INT
|
||||||
|
|
||||||
./music.sh &
|
su ${USERNAME} -c ./groomer.sh
|
||||||
echo $! > /tmp/music.pid
|
|
||||||
echo "GROOMER: music started."
|
|
||||||
|
|
||||||
su ${USERNAME} -c ./groomer.sh | tee ${GROOM_LOG}
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
set -e
|
set -e
|
||||||
set -x
|
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/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/groomer.sh /mnt/rpi/opt/groomer/groomer.sh
|
||||||
|
|
Loading…
Reference in New Issue