You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.3 KiB
56 lines
1.3 KiB
#!/bin/bash
|
|
|
|
DATA_DEVICE_UUID="C6CE6C2BCE6C1649"
|
|
MOUNT_PATH="/mnt/extern"
|
|
DATA="${MOUNT_PATH}/timelapse"
|
|
CLIENT="timelapse@192.168.111.2"
|
|
CLIENT_FOLDER="/timelapse"
|
|
|
|
if [[ "${1}" =~ [0-9]{2} ]]
|
|
then
|
|
WEEK=${1}
|
|
else
|
|
WEEK=`date --date="last monday" +%V`
|
|
fi
|
|
current_week=`date +'%V'`
|
|
current_week_diff=$((${current_week}-${WEEK}))
|
|
DATE_WEEK=`date --date="last monday - ${current_week_diff} weeks" +%Y%m%d`
|
|
DATE_START=`date --date="${DATE_WEEK}" +%s`
|
|
DATE_STOP=$(($DATE_START+7*86400))
|
|
|
|
mountpoint -q ${MOUNT_PATH}
|
|
if [ ${?} != 0 ]
|
|
then
|
|
sudo mount --uuid ${DATA_DEVICE_UUID} -o uid=1000,gid=1000,umask=0022 ${MOUNT_PATH} || echo "Cannot mount data device with UUID ${DATA_DEVICE_UUID}!"; exit 1
|
|
fi
|
|
|
|
if [ ! -e "${DATA}" ]
|
|
then
|
|
mkdir -p ${DATA}
|
|
fi
|
|
|
|
if [ ! -e "${DATA}/video" ]
|
|
then
|
|
mkdir -p "${DATA}/video"
|
|
fi
|
|
|
|
# sort files
|
|
rm -rf "${DATA}/weekly"
|
|
mkdir -p "${DATA}/weekly"
|
|
weekly_counter=0
|
|
for i in `find ${DATA}/data/ -name "${DATE}*.jpg"`
|
|
do
|
|
seconds_unixtime=`echo "${i}" | sed 's/^.\+_\([0-9]\+\).*/\1/'`
|
|
if [ "${seconds_unixtime}" -ge "${DATE_START}" ] && [ "${seconds_unixtime}" -lt "${DATE_STOP}" ]
|
|
then
|
|
weekly_counter=$((weekly_counter + 1))
|
|
if [ ${weekly_counter} -ge 7 ]
|
|
then
|
|
if [ ! -e "${DATA}/weekly/`basename ${i}`" ]
|
|
then
|
|
ln ${i} "${DATA}/weekly"
|
|
fi
|
|
weekly_counter=0
|
|
fi
|
|
fi
|
|
done
|
|
|