split configs into two systems...
This commit is contained in:
59
workstation/scripts/nextcloud-cronjob.sh
Executable file
59
workstation/scripts/nextcloud-cronjob.sh
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/run/current-system/sw/bin/bash
|
||||
|
||||
# Cron tasks
|
||||
if type /run/current-system/sw/bin/nextcloud-occ 2>/dev/null; then
|
||||
/run/current-system/sw/bin/nextcloud-occ preview:pre-generate
|
||||
/run/current-system/sw/bin/nextcloud-occ face:background_job -t 900
|
||||
fi
|
||||
|
||||
# Sync GDL stuff
|
||||
root=/mnt/disk2/scrapping
|
||||
|
||||
cd $root || exit
|
||||
set -- Aqp Ghekre
|
||||
for user in "$@"; do
|
||||
originDir=$root/$user
|
||||
destDir=/mnt/disk1/nextcloud/$user/files/Requested
|
||||
destDirDup=/mnt/disk1/nextcloud/$user/files/RequestedDupePlzCheckNDel
|
||||
if [ ! -d "$destDir" ]; then
|
||||
echo "$destDir does not exist, creating..."
|
||||
mkdir -p "$destDir"
|
||||
fi
|
||||
cd "$originDir" || exit
|
||||
find . -type f | while read -r file; do
|
||||
destination=$destDir/"$(echo "$file" | sed "s/^\.\///")"
|
||||
destinationDup=$destDirDup/"$(echo "$file" | sed "s/^\.\///")"
|
||||
|
||||
if [ ! -f "$destination" ]; then
|
||||
echo "Safe to move $(basename "$file")"
|
||||
if [ ! -d "$(dirname "$destination")" ]; then
|
||||
echo "Creating parent directory..."
|
||||
mkdir -p "$(dirname "$destination")"
|
||||
fi
|
||||
mv -n "$file" "$destination"
|
||||
else
|
||||
echo "Duplicated encountered $(basename "$file")"
|
||||
if [ ! -d "$(dirname "$destinationDup")" ]; then
|
||||
echo "Creating parent directory..."
|
||||
mkdir -p "$(dirname "$destinationDup")"
|
||||
fi
|
||||
mv -n "$file" "$destinationDup"
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
find ./ -mindepth 1 -type d -empty -delete
|
||||
|
||||
chown 990:990 -R "$destDir"
|
||||
find "$destDir" -type d -exec chmod -R 755 {} \;
|
||||
find "$destDir" -type f -exec chmod -R 644 {} \;
|
||||
|
||||
if [ -d "$destDirDup" ]; then
|
||||
chown 990:990 -R "$destDirDup"
|
||||
find "$destDirDup" -type d -exec chmod -R 755 {} \;
|
||||
find "$destDirDup" -type f -exec chmod -R 644 {} \;
|
||||
fi
|
||||
if type /run/current-system/sw/bin/nextcloud-occ 2>/dev/null; then
|
||||
/run/current-system/sw/bin/nextcloud-occ files:scan --all
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user