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.
timelapse/bin/timelapse_monthly.sh

49 lines
951 B

#!/bin/bash
DATA_DEVICE_UUID="C6CE6C2BCE6C1649"
MOUNT_PATH="/mnt/extern"
DATA="${MOUNT_PATH}/timelapse"
CLIENT="timelapse@192.168.111.2"
CLIENT_FOLDER="/timelapse"
set -x
if [[ "${1}" =~ [01]*[0-9] ]]
then
MONTH=${1}
else
MONTH=`date --date="1 month ago" +%m`
fi
YEAR=`date --date="1 month ago" +%Y`
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
mkdir -p "${DATA}/monthly"
monthly_counter=0
for i in `find ${DATA}/data/ -name "${YEAR}${MONTH}*.jpg"`
do
monthly_counter=$((monthly_counter + 1))
if [ ${monthly_counter} -ge 30 ]
then
if [ ! -e "${DATA}/monthly/`basename ${i}`" ]
then
ln ${i} "${DATA}/monthly"
fi
monthly_counter=0
fi
done