diff --git a/.gitignore b/.gitignore index db6be12..ba5d670 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,4 @@ Config/Hyperling.com/files/* # Ignore things like Config/Hyperling.com-Stage/ *-Stage +Stage-* diff --git a/Config/Nextcloud/cron.sh b/Config/Nextcloud/cron.sh index 1f4e717..6e5d239 100755 --- a/Config/Nextcloud/cron.sh +++ b/Config/Nextcloud/cron.sh @@ -4,19 +4,64 @@ # This should be added to root's crontab with the full path, such as: # */5 * * * * /opt/Docker/Config/Nextcloud/cron.ksh -# Check if a job is already going. +DIR="$(dirname -- "${BASH_SOURCE[0]}")" PROG="$(basename -- "${BASH_SOURCE[0]}")" + +# Check if a job is already going. RUNNING=`ps -ef | grep $PROG | grep -v grep | grep -v $$ | grep -v "sh -c" | wc -l` if (( $RUNNING > 0 )); then exit $RUNNING fi -# 2023-08-25 From crontab. -sh -c "docker exec -u www-data nc-app php cron.php --define apc.enable_cli=1" +# Usage function for when -h or bad parameters are passed. +function usage() { + cat <<- EOF + Script to help with scheduling Nextcloud's cron requirements. + Usage: $PROG [-h|-v] + -h ) Display the usage and help text. + | --help + -v) Pass a verbose request to cron.php. + | --verbose + EOF + exit $1 +} -# 2023-08-25 From fixes.sh, keep ownership correct and apps up to date. -sh -c "docker exec -it nc-app chown -Rc www-data:www-data ." +# Check for any parameters. +verbose="" +case "$1" in + "") ;; + "-h"|"--help") + usage 0 + ;; + "-v"|"--verbose") + verbose="-v" + ;; + *) + echo -e "ERROR: Unknown parameter '$1'. Exiting.\n" + usage 1 + ;; +esac + +# Keep ownership correct and apps up to date. Also exists in fixes.sh. +sh -c "docker exec -i nc-app chown -Rc www-data:www-data ." # No longer update apps in advance of NC updates, allow the upgrade process to do it. #sh -c "docker exec -itu www-data nc-app ./occ app:update --all" +# Prepare the variables being passed to the execution command. +if [[ -f $DIR/.env ]]; then + source $DIR/.env +else + PHP_MEMORY_LIMIT=256M +fi + +# Main part of what would go in the crontab. +sh -c " + docker exec nc-app \ + sudo -u www-data \ + php \ + -d apc.enable_cli=1 \ + -d memory_limit=$PHP_MEMORY_LIMIT \ + -f cron.php $verbose \ +" + exit 0 diff --git a/Config/Nextcloud/fixes.sh b/Config/Nextcloud/fixes.sh index 27f9c5b..270ab56 100755 --- a/Config/Nextcloud/fixes.sh +++ b/Config/Nextcloud/fixes.sh @@ -69,7 +69,7 @@ docker exec -itu www-data nc-app ./occ files:scan-app-data echo -e "\n`date` - Theme Update" docker exec -itu www-data nc-app ./occ maintenance:theme:update echo -e "\n`date` - Repair" -docker exec -itu www-data nc-app ./occ maintenance:repair +docker exec -itu www-data nc-app ./occ maintenance:repair --include-expensive # May also be useful but do not have much experience with them. echo -e "\n`date` - Clean Versions"