Fixed garbage collector.

master
Holger Wirtz 5 years ago
parent ff7dd0c253
commit 1853ca5d72
  1. 9
      bin/timelapse_garbage_collector.sh
  2. 12
      bin/timelapse_yearly.sh
  3. 40
      bin/timelapse_yearly_by_day.sh

@ -7,8 +7,17 @@ CLIENT="timelapse@192.168.111.2"
CLIENT_FOLDER="/timelapse"
mkdir -p "${DATA}/trash"
#secs_last_day_of_last_month=`date -d "$(date +%Y-%m-01) -1 day" +%s`
secs_last_day_of_last_month=`date -d "$(date +%Y-%m-01)" +%s`
for i in `find ${DATA}/data/ -name "*.jpg"`
do
file_secs=`echo ${i} | cut -d"_" -f2 | cut -d"." -f1`
if [ ${file_secs} -gt ${secs_last_day_of_last_month} ]
then
continue
fi
NUM_HARDLINKS=`stat --format="%h" ${i}`
if [ ${NUM_HARDLINKS} -lt 2 ]
then

@ -6,12 +6,12 @@ DATA="${MOUNT_PATH}/timelapse"
CLIENT="timelapse@192.168.111.2"
CLIENT_FOLDER="/timelapse"
if [[ "${1}" =~ [0-9]{4} ]]
then
YEAR=${1}
else
YEAR=`date --date="1 year ago" +%Y`
fi
#if [[ "${1}" =~ [0-9]{4} ]]
#then
# YEAR=${1}
#else
# YEAR=`date --date="1 year ago" +%Y`
#fi
mountpoint -q ${MOUNT_PATH}
if [ ${?} != 0 ]

@ -0,0 +1,40 @@
#!/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]{4} ]]
then
YEAR=${1}
else
YEAR=`date --date="1 year ago" +%Y`
fi
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}/yearly_by_day"
for i in `find ${DATA}/data/ -name "*-12000*.jpg"`
do
if [ ! -e "${DATA}/yearly_by_day/`basename ${i}`" ]
then
ln ${i} "${DATA}/yearly_by_day"
fi
done
Loading…
Cancel
Save