/Designs/Measuring_instruments/RMDS01B/SW/Bolidozor/SpectrumLab/sync.sh
3,10 → 3,10
[[ $# -ne 1 ]] && echo "Usage: ./sync.sh /path/to/folder" && exit 1
 
# Redirect stdout ( > ) into a named pipe ( >() ) running "tee"
exec > >(tee "$1"/logfile)
#exec > >(tee "$1"/logfile)
 
# Also redirect stderr
exec 2>&1
#exec 2>&1
 
# 9 min delay between resync
FREQUENCY=540
44,7 → 44,7
info "sorting $1"
"$TIDYUP" $1
if [ "$?" -ne 0 ]; then
error "sorting failed, please send logfile.txt to toxygen1@gmail.com"
error "sorting failed, please send logfile.txt"
return 1
fi
return 0
62,38 → 62,8
fi
}
 
# Check if we can connect, otherwise terminate
sshtest || exit 1
 
# Change working directory
cd $1
 
# first sort
tidyup $1 || error "Sort failed, please analyze logfile.txt ."
# first sync
info "Doing complete sync"
syncdir . -a
 
if [ -f "$1"/LAST ]
then
read LAST < "$1"/LAST
else
LAST="."
fi
 
if [ -f "$1"/capture/LAST ]
then
read LAST_HOUR < "$1"/capture/LAST
else
LAST_HOUR="."
fi
 
 
# Periodically tidy up and do incremental sync
while :
do
# start timer
function main() {
# start timer
start_time=`date +%s`
OLD="$LAST"
137,13 → 107,45
ELAPSED=`expr $end_time - $start_time`
info "execution time was $ELAPSED s"
date
}
 
# Check if we can connect, otherwise terminate
sshtest || exit 1
 
# Change working directory
cd $1
 
# first sort
tidyup $1 || error "Sorted, please analyze logfile.txt ."
# first sync
info "Doing complete sync"
syncdir . -a
 
if [ -f "$1"/LAST ]
then
read LAST < "$1"/LAST
else
LAST="."
fi
 
if [ -f "$1"/capture/LAST ]
then
read LAST_HOUR < "$1"/capture/LAST
else
LAST_HOUR="."
fi
 
 
# Periodically tidy up and do incremental sync
while :
do
main $1 2>&1 | tee "$1"/logfile
 
# save only tail from logfile
tail -n 1000 "$1"/logfile > "$1"/logfile.txt
rm "$1"/logfile
syncdir . --dirs --delete > /dev/null 2>&1
exec > >(tee "$1"/logfile)
exec 2>&1
 
# wait for a next syncing period
sleep $FREQUENCY
/Designs/Measuring_instruments/RMDS01B/SW/Bolidozor/SpectrumLab/upload.sh
4,7 → 4,6
#
# this script should not be called manually
 
echo "$1 ; $2 ; $3"
echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 
[[ "$#" < 1 ]] && echo "Please provide directory to upload" && exit 1