Compare commits

...

5 commits

Author SHA1 Message Date
mwiegand
f72ee7c85b remove obsolete metadatum 2022-07-07 15:46:15 +02:00
mwiegand
5eac0e8c85 home.server swapfile 2022-07-07 15:46:02 +02:00
mwiegand
fbee9a32df bundle systemd-swap improvements 2022-07-07 15:45:28 +02:00
mwiegand
1bde29bb17 fix pkg name 2022-07-07 15:35:10 +02:00
mwiegand
d10f2b1eb3 picsort: use File Modification Date as alternative 2022-07-07 15:35:01 +02:00
4 changed files with 55 additions and 32 deletions

View file

@ -1,7 +1,9 @@
#!/bin/bash
USER="$1"
SOURCEPATH="/var/lib/nextcloud/$1/files/$2"
REL_SOURCE_PATH="/$1/files/$2"
ABS_SOURCE_PATH="/var/lib/nextcloud/$1/files/$2"
REL_DEST_PATH="/$1/files/$3"
ABS_DEST_PATH="/var/lib/nextcloud/$1/files/$3"
@ -11,52 +13,63 @@ ABS_UNSORTABLE_PATH="/var/lib/nextcloud/$1/files/$4"
echo "STARTING..."
chown -R www-data:www-data "$SOURCEPATH"
chmod -R 770 "$SOURCEPATH"
chown -R www-data:www-data "$ABS_SOURCE_PATH"
chmod -R 770 "$ABS_SOURCE_PATH"
SCAN="FALSE"
IFS=$'\n'
for f in `find "$SOURCEPATH" -iname *.PNG -o -iname *.JPG -o -iname *.HEIC -o -iname *.CR2 -o -iname *.CR3 -o -iname *.MP4 -o -iname *.MOV`; do
for f in `find "$ABS_SOURCE_PATH" -iname *.PNG -o -iname *.JPG -o -iname *.JPEG -o -iname *.HEIC -o -iname *.CR2 -o -iname *.CR3 -o -iname *.MP4 -o -iname *.MOV`; do
SCAN="TRUE"
echo "PROCESSING: $f"
DATE=`exiftool "$f" | grep -m 1 "Create Date"`
if ! echo "$DATE" | grep "Create Date" >/dev/null
EXIF=`exiftool "$f"`
if grep -q '^Create Date' <<< $EXIF
then
RELPATH=$(realpath --relative-to="$SOURCEPATH" "$f")
DATETIME=`grep -m 1 "^Create Date" <<< $EXIF | cut -d: -f2- | xargs`
elif grep -q '^File Modification Date' <<< $EXIF
then
DATETIME=`grep -m 1 '^File Modification Date' <<< $EXIF | cut -d: -f2- | xargs`
else
RELPATH=$(realpath --relative-to="$ABS_SOURCE_PATH" "$f")
DIRNAME=$(dirname "$ABS_UNSORTABLE_PATH/$RELPATH")
echo "UNSORTABLE: $f"
mkdir -p "$DIRNAME"
mv "$f" "$DIRNAME"
else
YEAR=`echo $DATE | cut -d':' -f2 | cut -c 2-`
MONTH=`echo $DATE | cut -d':' -f3`
DAY=`echo $DATE | cut -d':' -f4 | cut -d' ' -f1`
HOUR=`echo $DATE | cut -d':' -f4 | cut -d' ' -f2`
MINUTE=`echo $DATE | cut -d':' -f5`
SECOND=`echo $DATE | cut -d':' -f6`
SECOND=`echo $SECOND | cut -d'+' -f1` # remove timezone
HASH=`sha256sum "$f" | xxd -r -p | base64 | head -c 3 | tr '/+' '_-'`
EXT=`echo "${f##*.}" | tr '[:upper:]' '[:lower:]'`
if [[ "$EXT" = "cr2" ]] || [[ "$EXT" = "cr3" ]]
then
RAW="raw/"
else
RAW=""
fi
FILE="$ABS_DEST_PATH/$YEAR-$MONTH/$RAW$YEAR$MONTH$DAY"-"$HOUR$MINUTE$SECOND"_"$HASH"."$EXT"
echo "DESTINATION: $FILE"
mkdir -p "$(dirname "$FILE")"
mv -v "$f" "$FILE"
continue
fi
DATE=`cut -d' ' -f1 <<< $DATETIME`
TIME=`cut -d' ' -f2 <<< $DATETIME | cut -d'+' -f1`
YEAR=`cut -d':' -f1 <<< $DATE`
MONTH=`cut -d':' -f2 <<< $DATE`
DAY=`cut -d':' -f3 <<< $DATE`
HOUR=`cut -d':' -f1 <<< $TIME`
MINUTE=`cut -d':' -f2 <<< $TIME`
SECOND=`cut -d':' -f3 <<< $TIME`
HASH=`sha256sum "$f" | xxd -r -p | base64 | head -c 3 | tr '/+' '_-'`
EXT=`echo "${f##*.}" | tr '[:upper:]' '[:lower:]'`
if [[ "$EXT" = "cr2" ]] || [[ "$EXT" = "cr3" ]]
then
RAW="raw/"
else
RAW=""
fi
FILE="$ABS_DEST_PATH/$YEAR-$MONTH/$RAW$YEAR$MONTH$DAY"-"$HOUR$MINUTE$SECOND"_"$HASH"."$EXT"
echo "DESTINATION: $FILE"
mkdir -p "$(dirname "$FILE")"
mv -v "$f" "$FILE"
done
if [ "$SCAN" == "TRUE" ]; then
echo "SCANNING..."
# find "$SOURCEPATH/"* -type d -empty -delete >> /var/echo/nc-picsort.echo # nextcloud app bug when deleting folders
# find "$ABS_SOURCE_PATH/"* -type d -empty -delete >> /var/echo/nc-picsort.echo # nextcloud app bug when deleting folders
chown -R www-data:www-data "$ABS_DEST_PATH"
chown -R www-data:www-data "$ABS_UNSORTABLE_PATH"
chmod -R 770 "$ABS_DEST_PATH"
chmod -R 770 "$ABS_UNSORTABLE_PATH"
sudo -u www-data php /opt/nextcloud/occ files:scan --path "$REL_SOURCE_PATH"
sudo -u www-data php /opt/nextcloud/occ files:scan --path "$REL_UNSORTABLE_PATH"
sudo -u www-data php /opt/nextcloud/occ files:scan --path "$REL_DEST_PATH"
sudo -u www-data php /opt/nextcloud/occ preview:pre-generate

View file

@ -4,7 +4,7 @@ from shlex import quote as q
defaults = {
'apt': {
'packages': {
'exiftool': {},
'libimage-exiftool-perl': {},
},
},
}

View file

@ -4,14 +4,23 @@ assert isinstance(size, int)
actions = {
'stop_swap': {
'command': f'systemctl stop swapfile.swap',
'unless': f'rm /swapfile',
'unless': f'! systemctl is-active swapfile.swap',
'triggered': True,
},
'remove_swapfile': {
'command': f'rm /swapfile',
'unless': f'! test -e /swapfile',
'triggered': True,
'needs': {
'action:stop_swap',
},
},
'create_swapfile': {
'command': f'dd if=/dev/zero of=/swapfile bs={size} count=1',
'unless': f'stat -c %s /swapfile | grep ^{size}$',
'preceded_by': {
'action:stop_swap',
'action:remove_swapfile',
},
'triggers': {
'action:initialize_swapfile',

View file

@ -25,6 +25,7 @@
'smartctl',
'steam-chat-logger',
'steam-chat-viewer',
'systemd-swap',
'raspberrymatic-cert',
'tasmota-charge',
'wireguard',
@ -83,7 +84,6 @@
'nextcloud': {
'hostname': 'cloud.sublimity.de',
'version': '24.0.2',
'instance_id': 'oci6dw1woodz',
},
'nextcloud-picsort': {
'ckn': {
@ -107,6 +107,7 @@
'steam-chat-viewer': {
'hostname': 'steam-chats.ckn.li',
},
'systemd-swap': 4*10**9,
'tasmota-charge': {
'phone': {
'ip': '10.0.0.175',
@ -154,7 +155,7 @@
'/dev/disk/by-id/nvme-SAMSUNG_MZVL22T0HBLB-00B00_S677NF0RA01551-part3',
],
},
},
},
'datasets': {
'ssd/nextcloud-appdata': {
'mountpoint': '/var/lib/nextcloud/appdata_oci6dw1woodz',