Newer
Older
admin-tools / owncloud-preview
Paul Staroch on 4 Aug 799 bytes added description
#!/bin/bash

# https://apps.nextcloud.com/apps/previewgenerator
#
# When adding a large number of image files to Nextcloud, one run
# of 'php occ preview:pre-generate' may take long time.
# If the script is invoked by cron another time in the meantime,
# it fails with an error message.
# This script invokes 'php occ preview:pre-generate' only if
# it is not already running in order to avoid this script
# failing with an error.

cd /var/www/cloud

rm -f /tmp/owncloud-preview-check
ps aux > /tmp/owncloud-preview-check
running=`grep -c 'php occ preview:pre-generate' /tmp/owncloud-preview-check`
rm -f /tmp/owncloud-preview-check

if [ "$running" -ne "0" ]; then
	exit
fi

fail=0
/usr/bin/ionice -c3 php occ preview:pre-generate || fail=1

if [ "$fail" -eq "1" ]; then
	echo Fail
fi

exit $fail