From 2e7efbc6eb532397e610109b1f7a12dae0ec648c Mon Sep 17 00:00:00 2001 From: Hyperling Date: Sat, 4 Jan 2025 10:05:23 -0700 Subject: [PATCH 01/10] Allow the stage keyword to be at the beginning too. --- .gitignore | 1 + 1 file changed, 1 insertion(+) 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-* -- 2.49.0 From f8d4c4654ed97c9529f84af8a5d9108c6c7dcf62 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Fri, 28 Mar 2025 17:03:23 -0700 Subject: [PATCH 02/10] Add extra flag to enable doing things like migrating MIME types. May increase the amount of time by quite a bit on large systems, but mine is small. :) --- Config/Nextcloud/fixes.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" -- 2.49.0 From 6611665770a428336cb75bb6d92571a66317acb7 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Fri, 28 Mar 2025 17:15:41 -0700 Subject: [PATCH 03/10] Add TODO for getting `cron.php` working properly. --- Config/Nextcloud/cron.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Config/Nextcloud/cron.sh b/Config/Nextcloud/cron.sh index 1f4e717..88f94f6 100755 --- a/Config/Nextcloud/cron.sh +++ b/Config/Nextcloud/cron.sh @@ -4,6 +4,13 @@ # This should be added to root's crontab with the full path, such as: # */5 * * * * /opt/Docker/Config/Nextcloud/cron.ksh +# TODO / TBD +# - Install cron -y on nc-app. +# - Ensure */5 * * * * /var/www/html/cron.php is an entry for www-data. +# - Ensure service cron is started and running. +# - Remove the entry for this file under root on the Docker server. +# - Test that everything works after an update and reboot of both NC + Docker. + # Check if a job is already going. PROG="$(basename -- "${BASH_SOURCE[0]}")" RUNNING=`ps -ef | grep $PROG | grep -v grep | grep -v $$ | grep -v "sh -c" | wc -l` -- 2.49.0 From 93be7897901505bf34c265a411e6244933d95d0d Mon Sep 17 00:00:00 2001 From: Hyperling Date: Mon, 16 Jun 2025 12:19:01 -0600 Subject: [PATCH 04/10] Fix the "the input device is not a TTY" cron log message. --- Config/Nextcloud/cron.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Config/Nextcloud/cron.sh b/Config/Nextcloud/cron.sh index 88f94f6..877360c 100755 --- a/Config/Nextcloud/cron.sh +++ b/Config/Nextcloud/cron.sh @@ -22,7 +22,7 @@ fi sh -c "docker exec -u www-data nc-app php cron.php --define apc.enable_cli=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 ." +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" -- 2.49.0 From cf1e23e91c4ce3b5c46c7540af0954517d4ef085 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Mon, 16 Jun 2025 12:53:43 -0600 Subject: [PATCH 05/10] Call on www-data using sudo within the container, gives better output. --- Config/Nextcloud/cron.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Config/Nextcloud/cron.sh b/Config/Nextcloud/cron.sh index 877360c..5626359 100755 --- a/Config/Nextcloud/cron.sh +++ b/Config/Nextcloud/cron.sh @@ -19,7 +19,7 @@ if (( $RUNNING > 0 )); then fi # 2023-08-25 From crontab. -sh -c "docker exec -u www-data nc-app php cron.php --define apc.enable_cli=1" +sh -c "docker exec nc-app sudo -u www-data php cron.php --define apc.enable_cli=1" # 2023-08-25 From fixes.sh, keep ownership correct and apps up to date. sh -c "docker exec -i nc-app chown -Rc www-data:www-data ." -- 2.49.0 From 0e761c5112f99508fb2d12d256617c8cd65a0ccf Mon Sep 17 00:00:00 2001 From: Hyperling Date: Mon, 16 Jun 2025 13:18:40 -0600 Subject: [PATCH 06/10] Add memory limit setting to php command. --- Config/Nextcloud/cron.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Config/Nextcloud/cron.sh b/Config/Nextcloud/cron.sh index 5626359..a9963ac 100755 --- a/Config/Nextcloud/cron.sh +++ b/Config/Nextcloud/cron.sh @@ -12,6 +12,7 @@ # - Test that everything works after an update and reboot of both NC + Docker. # Check if a job is already going. +DIR="$(dirname -- "${BASH_SOURCE[0]}")" PROG="$(basename -- "${BASH_SOURCE[0]}")" RUNNING=`ps -ef | grep $PROG | grep -v grep | grep -v $$ | grep -v "sh -c" | wc -l` if (( $RUNNING > 0 )); then @@ -19,7 +20,15 @@ if (( $RUNNING > 0 )); then fi # 2023-08-25 From crontab. -sh -c "docker exec nc-app sudo -u www-data php cron.php --define apc.enable_cli=1" +source $DIR/.env +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 \ +" # 2023-08-25 From fixes.sh, keep ownership correct and apps up to date. sh -c "docker exec -i nc-app chown -Rc www-data:www-data ." -- 2.49.0 From a3ce3a7ee166ef22b183eb98055e3f7b97ba003d Mon Sep 17 00:00:00 2001 From: Hyperling Date: Mon, 16 Jun 2025 14:01:25 -0600 Subject: [PATCH 07/10] Add usage and verbose output option for what the cron file is getting accomplished. --- Config/Nextcloud/cron.sh | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/Config/Nextcloud/cron.sh b/Config/Nextcloud/cron.sh index a9963ac..8672ca0 100755 --- a/Config/Nextcloud/cron.sh +++ b/Config/Nextcloud/cron.sh @@ -19,15 +19,39 @@ if (( $RUNNING > 0 )); then exit $RUNNING fi +verbose="" +case "$1" in + "-h") + cat <<- EOF + Script to help with scheduling Nextcloud's cron requirements. + Usage: $PROG [-h|-v] + -h) Display the usage and help text. + -v) Pass a verbose request to cron.php. + EOF + exit 0 + ;; + "-v") + verbose="-v" + ;; + *) + echo "ERROR: Unknown parameter '$1', exiting." + $DIR/$PROG -h + ;; +esac + # 2023-08-25 From crontab. -source $DIR/.env +if [[ -f $DIR/.env ]]; then + source $DIR/.env +else + PHP_MEMORY_LIMIT=256M +fi 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 \ + -f cron.php $verbose \ " # 2023-08-25 From fixes.sh, keep ownership correct and apps up to date. -- 2.49.0 From 4ca8a8ae0204a0e3570e10179bb064e458ad2f40 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Mon, 16 Jun 2025 14:23:57 -0600 Subject: [PATCH 08/10] Update comments, rearrange file, fix case statement and handle empty parameter correctly. --- Config/Nextcloud/cron.sh | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/Config/Nextcloud/cron.sh b/Config/Nextcloud/cron.sh index 8672ca0..22ae29d 100755 --- a/Config/Nextcloud/cron.sh +++ b/Config/Nextcloud/cron.sh @@ -19,32 +19,44 @@ if (( $RUNNING > 0 )); then exit $RUNNING fi +function usage() { + cat <<- EOF + Script to help with scheduling Nextcloud's cron requirements. + Usage: $PROG [-h|-v] + -h) Display the usage and help text. + -v) Pass a verbose request to cron.php. + EOF + exit $1 +} + verbose="" case "$1" in + "") ;; "-h") - cat <<- EOF - Script to help with scheduling Nextcloud's cron requirements. - Usage: $PROG [-h|-v] - -h) Display the usage and help text. - -v) Pass a verbose request to cron.php. - EOF - exit 0 + usage 0 ;; "-v") verbose="-v" ;; *) - echo "ERROR: Unknown parameter '$1', exiting." - $DIR/$PROG -h + echo -e "ERROR: Unknown parameter '$1'. Exiting.\n" + usage 1 ;; esac -# 2023-08-25 From crontab. +# 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 \ @@ -54,9 +66,4 @@ sh -c " -f cron.php $verbose \ " -# 2023-08-25 From fixes.sh, keep ownership correct and apps up to date. -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" - exit 0 -- 2.49.0 From 4469754097b2abd3985cbc45de4a94c446b15dc7 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Mon, 16 Jun 2025 14:24:38 -0600 Subject: [PATCH 09/10] Remove TODOs, going to keep cron at the Docker server level, container packages too volatile. --- Config/Nextcloud/cron.sh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Config/Nextcloud/cron.sh b/Config/Nextcloud/cron.sh index 22ae29d..1a40354 100755 --- a/Config/Nextcloud/cron.sh +++ b/Config/Nextcloud/cron.sh @@ -4,13 +4,6 @@ # This should be added to root's crontab with the full path, such as: # */5 * * * * /opt/Docker/Config/Nextcloud/cron.ksh -# TODO / TBD -# - Install cron -y on nc-app. -# - Ensure */5 * * * * /var/www/html/cron.php is an entry for www-data. -# - Ensure service cron is started and running. -# - Remove the entry for this file under root on the Docker server. -# - Test that everything works after an update and reboot of both NC + Docker. - # Check if a job is already going. DIR="$(dirname -- "${BASH_SOURCE[0]}")" PROG="$(basename -- "${BASH_SOURCE[0]}")" -- 2.49.0 From 494d0c04bdce53c91efb25bd4da3ba23975cb09e Mon Sep 17 00:00:00 2001 From: Hyperling Date: Mon, 16 Jun 2025 14:28:04 -0600 Subject: [PATCH 10/10] Allow long-form parameters. --- Config/Nextcloud/cron.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Config/Nextcloud/cron.sh b/Config/Nextcloud/cron.sh index 1a40354..6e5d239 100755 --- a/Config/Nextcloud/cron.sh +++ b/Config/Nextcloud/cron.sh @@ -4,31 +4,36 @@ # 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 +# 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. + -h ) Display the usage and help text. + | --help -v) Pass a verbose request to cron.php. + | --verbose EOF exit $1 } +# Check for any parameters. verbose="" case "$1" in "") ;; - "-h") + "-h"|"--help") usage 0 ;; - "-v") + "-v"|"--verbose") verbose="-v" ;; *) -- 2.49.0