From 2c94c420d8c02cfadd74304d34969018b3bd742d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Sun, 8 Jan 2023 22:42:58 +0100 Subject: [PATCH 01/54] nc-snapshot-auto.sh: Ad quotes to allow datadirectory paths with spaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- bin/ncp/BACKUPS/nc-snapshot-auto.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ncp/BACKUPS/nc-snapshot-auto.sh b/bin/ncp/BACKUPS/nc-snapshot-auto.sh index a0ccef221..e1a4fa97d 100644 --- a/bin/ncp/BACKUPS/nc-snapshot-auto.sh +++ b/bin/ncp/BACKUPS/nc-snapshot-auto.sh @@ -29,7 +29,7 @@ configure() source /usr/local/etc/library.sh -DATADIR=\$(get_nc_config_value datadirectory) || { +DATADIR="\$(get_nc_config_value datadirectory)" || { echo -e "Error reading data directory. Is NextCloud running and configured?"; exit 1; } From a09ddbe3083696f76cb3c1663046fda2fa8975c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Mon, 9 Jan 2023 11:04:35 +0100 Subject: [PATCH 02/54] 020nextcloud: Fix NC logfile path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- build/docker/nextcloud/020nextcloud | 2 +- build/docker/nextcloudpi/000ncp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/docker/nextcloud/020nextcloud b/build/docker/nextcloud/020nextcloud index edfe4b1d4..c25aa7f94 100755 --- a/build/docker/nextcloud/020nextcloud +++ b/build/docker/nextcloud/020nextcloud @@ -79,6 +79,6 @@ bash /usr/local/bin/nextcloud-domain.sh echo "Nextcloud version $(nc_version). NextCloudPi version $(cat /usr/local/etc/ncp-version)" # Display NC logs in the docker logs -tail -f -n0 /data/nextcloud/data/nextcloud.log & +tail -f -n0 "$(get_nc_config_value logfile)" & exit 0 diff --git a/build/docker/nextcloudpi/000ncp b/build/docker/nextcloudpi/000ncp index 0bd6b8c3a..efd3daa5c 100755 --- a/build/docker/nextcloudpi/000ncp +++ b/build/docker/nextcloudpi/000ncp @@ -28,6 +28,6 @@ install_template "php/pool.d.www.conf.sh" "/etc/php/${PHPVER}/fpm/pool.d/www.con install_template "ncp-metrics.cfg.sh" "/usr/local/etc/ncp-metrics.cfg" touch /var/log/ncp.log -{ tail -f -n0 /data/ncdata/data/nextcloud.log || tail -f -n0 /data/nextcloud/data/nextcloud.log; } & +tail -f -n0 "$(get_nc_config_value logfile)" & exit 0 From ba4bb1d951f866954eb5ffe620aa0e752418afe9 Mon Sep 17 00:00:00 2001 From: Tobias K <6317548+theCalcaholic@users.noreply.github.com> Date: Sat, 7 Jan 2023 20:01:59 +0100 Subject: [PATCH 03/54] Add support for Nextcloud 25.0.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com> Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- README.md | 2 +- etc/ncp-config.d/nc-nextcloud.cfg | 2 +- etc/ncp.cfg | 2 +- ncp-app/appinfo/info.xml | 2 +- ncp-previewgenerator/ncp-previewgenerator-nc21/appinfo/info.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 06a139690..f316f723c 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Find the full documentation at [docs.nextcloudpi.com](http://docs.nextcloudpi.co ## Features * Debian/Raspbian 11 Bullseye - * Nextcloud 24.0.8 + * Nextcloud 25.0.2 * Apache, with HTTP2 enabled * PHP 8.1 * MariaDB 10 diff --git a/etc/ncp-config.d/nc-nextcloud.cfg b/etc/ncp-config.d/nc-nextcloud.cfg index 38e9c782c..0fcfd7d42 100644 --- a/etc/ncp-config.d/nc-nextcloud.cfg +++ b/etc/ncp-config.d/nc-nextcloud.cfg @@ -9,7 +9,7 @@ { "id": "VER", "name": "Version", - "value": "24.0.8" + "value": "25.0.2" }, { "id": "MAXFILESIZE", diff --git a/etc/ncp.cfg b/etc/ncp.cfg index 8d60b13a6..95fa59d50 100644 --- a/etc/ncp.cfg +++ b/etc/ncp.cfg @@ -1,5 +1,5 @@ { - "nextcloud_version": "24.0.8", + "nextcloud_version": "25.0.2", "php_version": "8.1", "release": "bullseye" } diff --git a/ncp-app/appinfo/info.xml b/ncp-app/appinfo/info.xml index 07b535633..40f8cc514 100644 --- a/ncp-app/appinfo/info.xml +++ b/ncp-app/appinfo/info.xml @@ -12,7 +12,7 @@ tools https://github.com/nextcloud/nextcloudpi/issues - + diff --git a/ncp-previewgenerator/ncp-previewgenerator-nc21/appinfo/info.xml b/ncp-previewgenerator/ncp-previewgenerator-nc21/appinfo/info.xml index 5dcb80c40..183f1dbd4 100644 --- a/ncp-previewgenerator/ncp-previewgenerator-nc21/appinfo/info.xml +++ b/ncp-previewgenerator/ncp-previewgenerator-nc21/appinfo/info.xml @@ -25,7 +25,7 @@ The first time you install this app, before using a cron job, you properly want - + From 127c9bdfb121129a2cf6ac4e3fa8c3d798938bca Mon Sep 17 00:00:00 2001 From: Tobias K <6317548+theCalcaholic@users.noreply.github.com> Date: Tue, 10 Jan 2023 10:22:34 +0100 Subject: [PATCH 04/54] build-{docker,lxd}: Also run on PRs against release branches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com> Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/build-docker.yml | 1 + .github/workflows/build-lxd.yml | 5 +++-- .github/workflows/lxd-trigger.yml | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 6936d5ad7..7e8c6de18 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -22,6 +22,7 @@ on: branches: - master - devel + - release/* jobs: build: diff --git a/.github/workflows/build-lxd.yml b/.github/workflows/build-lxd.yml index f911093b3..5bcbeff57 100644 --- a/.github/workflows/build-lxd.yml +++ b/.github/workflows/build-lxd.yml @@ -15,8 +15,9 @@ on: - "**" pull_request: branches: - - "master" - - "devel" + - master + - devel + - release/* jobs: build-current: diff --git a/.github/workflows/lxd-trigger.yml b/.github/workflows/lxd-trigger.yml index 5c8a2a9ad..45527394f 100644 --- a/.github/workflows/lxd-trigger.yml +++ b/.github/workflows/lxd-trigger.yml @@ -5,6 +5,7 @@ on: branches: - master - devel + - release/* push: branches: - devel From 74200976ad4582d8e68894f593f61057c79206da Mon Sep 17 00:00:00 2001 From: Tobias K <6317548+theCalcaholic@users.noreply.github.com> Date: Tue, 10 Jan 2023 10:39:47 +0100 Subject: [PATCH 05/54] build-docker.yml: Only allow tags as previous version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com> Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/build-docker.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 7e8c6de18..cf145063c 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -88,16 +88,14 @@ jobs: shell: bash run: | set -ex - if [[ -n "${{ github.base_ref }}" ]] - then - version="${{ github.base_ref }}" - elif [[ "${{ env.VERSION }}" == "refs/heads/devel" ]] + if [[ "${{ env.VERSION }}" == "refs/heads/devel" ]] then version="latest" else + git checkout "${{ github.base_ref }}" if [[ "${{ github.ref_type }}" != "tag" ]] || ! git describe --tags > /dev/null then - git fetch -fu --tags origin ${{ env.VERSION }}:${{ env.VERSION }} + git fetch -fu --tags origin ${{ github.base_ref }}:${{ github.base_ref }} fi version="$(git describe --tags || true)" [[ "$version" =~ .*-.*-.* ]] || { From bc0abc6c48f4ae0bef177b4b651e08f85fc01436 Mon Sep 17 00:00:00 2001 From: "Victor-ray, S" <12261439+ZendaiOwl@users.noreply.github.com> Date: Wed, 11 Jan 2023 00:15:29 +0100 Subject: [PATCH 06/54] ncp-diag, web-ui: Integrate new port check backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com> Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- bin/ncp-diag | 128 +++++++++++++++++++++------------------ bin/ncp-report | 4 +- bin/ncp-suggestions | 4 +- ncp-web/wizard/index.php | 14 ++--- 4 files changed, 81 insertions(+), 69 deletions(-) diff --git a/bin/ncp-diag b/bin/ncp-diag index 8241ed572..dc89c8fae 100644 --- a/bin/ncp-diag +++ b/bin/ncp-diag @@ -1,6 +1,5 @@ #!/bin/bash - -# NextCloudPi diagnostics report +# NextcloudPi diagnostics report # # Copyleft 2017 by Ignacio Nunez Hernanz # GPL licensed (see end of file) * Use at your own risk! @@ -10,13 +9,13 @@ # # More at https://ownyourbits.com # - +# shellcheck disable=SC1091 source /usr/local/etc/library.sh # Distro, NCP version and tag -echo "NextCloudPi version|$( cat /usr/local/etc/ncp-version )" -[[ -f /usr/local/etc/ncp-baseimage ]] && echo "NextCloudPi image|$( cat /usr/local/etc/ncp-baseimage )" -echo "OS|$(cat /etc/issue | sed 's| \\n \\l||'). $(uname -r) ($(uname -m))" +echo "NextcloudPi version|$( cat /usr/local/etc/ncp-version )" +[[ -f /usr/local/etc/ncp-baseimage ]] && echo "NextcloudPi image|$( cat /usr/local/etc/ncp-baseimage )" +echo "OS|$(sed 's| \\n \\l||' /etc/issue). $(uname -r) ($(uname -m))" # Data DATADIR="$( grep datadirectory /var/www/nextcloud/config/config.php | @@ -31,7 +30,7 @@ echo "USB devices|$USBDEVS" echo "datadir|$DATADIR$DIRINFO" [[ "$DIRINFO" == "" ]] && { echo "data in SD|$( [[ $( stat -fc%d / ) == $( stat -fc%d "$DATADIR" ) ]] && echo yes || echo no )" - echo "data filesystem|$( stat -fc%T $DATADIR )" + echo "data filesystem|$( stat -fc%T "$DATADIR" )" echo "data disk usage|$( df -h "$DATADIR" | tail -1 | awk '{ print $3"/"$2 }')" } echo "rootfs usage|$( df -h / | tail -1 | awk '{ print $3"/"$2 }')" @@ -66,63 +65,76 @@ echo "Internet check|$( ping -W 2 -w 1 -q github.com &>/dev/null && echo ok || e function is_port_open() { - local port_url tmp_file token ipv4_portcheck_args ipv6_portcheck_args - tmp_file=$(mktemp) - trap 'rm -rf ${tmp_file}' EXIT ERR SIGINT SIGQUIT SIGABRT SIGTERM SIGHUP - - local port="${1?}" - local publicIPv4="${2}" - local publicIPv6="${3}" - - readonly port_url="https://portchecker.co" - - if [[ -z "$publicIPv4" ]] && [[ -z "$publicIPv6" ]] + # The URL leads to an application I've deployed for NCP on https://fly.io using a Docker container I made. + # The image for the container is available on Docker Hub (zendai/checkport:sanic) if you wish to deploy one yourself. + # The code for the Sanic server and Docker image is available at: https://github.com/ZendaiOwl/Build/tree/master/Docker/Python/Sanic/checkport + # I only have a free tier with limited outbound data per month, 100GB p/month. + # If we go over 100GB outbound data in a month, I will start being charged for the data going over that limit. + # I used a low level Python socket library & fortunately each request only consumes aprox. ~ 60-74 bytes p/second. + # Meaning 100GB should be plenty, it should be enough to handle a little less + # than 450 request p/second a month, unless my calculations are wrong. + # Thank you :pray: from Victor-ray, S. https://github.com/ZendaiOwl + local -r PORTURL="https://checkport.zendai.net.eu.org/check" + local TYPE="${1?}" IPType + # Checks both port 80 & 443 for IPv4/IPv6 and returns the result or [N/A] [N/A] + if ! [[ "$TYPE" =~ ^(0|4|6)$ ]] then - echo -n "Error - IPv4 & IPv6: [N/A] Couldn't get public IP." - return 1 - fi - - token=$(wget -T2 -t1 -qO- --keep-session-cookies --save-cookies "${tmp_file}" "${port_url}" | grep -oP "_csrf\" value=\"\K.*\"" ) - readonly ipv4_portcheck_args=(-T2 -t1 -qO- --load-cookies "${tmp_file}" "${port_url}/check" --post-data "target_ip=${publicIPv4}&port=${port}&_csrf=${token::-1}") - readonly ipv6_portcheck_args=(-T2 -t1 -qO- --load-cookies "${tmp_file}" "${port_url}/check" --post-data "target_ip=${publicIPv6}&port=${port}&_csrf=${token::-1}") - - [[ -n "${token}" ]] || { - echo -n "Error - Couldn't obtain a token for port check" + echo "Invalid type: $TYPE" 1>&2 return 1 - } - - local ipv4_port_access=False - local ipv6_port_access=False - [[ -n "$publicIPv4" ]] && \ - grep -q 'open' <(wget "${ipv4_portcheck_args[@]}") && \ - ipv4_port_access=True - [[ -n "$publicIPv6" ]] && \ - grep -q 'open' <(wget "${ipv6_portcheck_args[@]}") && \ - ipv6_port_access=True - - local result="" - if [[ "${ipv4_port_access}" == True ]] || [[ "${ipv6_port_access}" == True ]] + elif [[ "$TYPE" == 0 ]] then - result="open (" + # Public IPv4/6 is not available + echo -e "[N/A]\n[N/A]" else - result="closed" + IPType="--ipv6" + [[ "$TYPE" -eq 6 ]] || IPType="--ipv4" + curl --silent --max-time 4 "$IPType" "$PORTURL" | jq -r '."80",."443"' fi - - [[ "${ipv4_port_access}" == True ]] && result="${result}ipv4)" - - [[ "${ipv6_port_access}" == True ]] && result="${result/)/ \& }ipv6)" - - echo -n "$result" - } +publicIPv4=$(curl --silent --max-time 4 --ipv4 "https://ipv4.icanhazip.com" 2>/dev/null) || unset publicIPv4 +echo "Public IPv4|${publicIPv4:-"not found"}" +publicIPv6=$(curl --silent --max-time 4 --ipv6 "https://ipv6.icanhazip.com" 2>/dev/null) || unset publicIPv6 +echo "Public IPv6|${publicIPv6:-"not found"}" + +# Reads each line as an array index element to input into IPv4PORTS array +if [[ -n "$publicIPv4" ]] +then + mapfile -t IPv4PORTS < <(is_port_open 4) +else + mapfile -t IPv4PORTS < <(is_port_open 0) +fi -publicIPv4=$(curl -s -m4 -4 "https://icanhazip.com" 2>/dev/null) || unset publicIPv4 -echo "public IPv4|${publicIPv4:-"not found"}" -publicIPv6=$(curl -s -m4 -6 "https://icanhazip.com" 2>/dev/null) || unset publicIPv6 -echo "public IPv6|${publicIPv6:-"not found"}" +# Reads each line as an array index element to input into IPv6PORTS array +if [[ -n "$publicIPv6" ]] +then + mapfile -t IPv6PORTS < <(is_port_open 6) +else + mapfile -t IPv6PORTS < <(is_port_open 0) +fi + +# Checks if Port 80 is open on IPv4 or IPv6 +if [[ "${IPv4PORTS[0]}" == "open" ]] || [[ "${IPv6PORTS[0]}" == "open" ]] +then + PORT80="open" +elif [[ "${IPv4PORTS[0]}" == "[N/A]" ]] && [[ "${IPv6PORTS[0]}" == "[N/A]" ]] +then + PORT80="[N/A]" +else + PORT80="closed" +fi +# Checks if Port 443 is open on IPv4 or IPv6 +if [[ "${IPv4PORTS[1]}" == "open" ]] || [[ "${IPv6PORTS[1]}" == "open" ]] +then + PORT443="open" +elif [[ "${IPv4PORTS[1]}" == "[N/A]" ]] && [[ "${IPv6PORTS[1]}" == "[N/A]" ]] +then + PORT443="[N/A]" +else + PORT443="closed" +fi -echo "Port check 80|$( is_port_open 80 "$publicIPv4" "$publicIPv6" )" -echo "Port check 443|$( is_port_open 443 "$publicIPv4" "$publicIPv6" )" +echo "Port 80|$PORT80" +echo "Port 443|$PORT443" # LAN IFACE=$( ip r | grep "default via" | awk '{ print $5 }' | head -1 ) @@ -130,14 +142,14 @@ GW=$( ip r | grep "default via" | awk '{ print $3 }' | head -1 ) IP="$(get_ip)" echo "IP|$IP" -echo "gateway|$GW" +echo "Gateway|$GW" echo "Interface|$IFACE" # Certificates CERTS="$( grep "SSLCertificateFile */etc/letsencrypt/live/" /etc/apache2/sites-available/nextcloud.conf \ | sed 's|.*SSLCertificateFile */etc/letsencrypt/live/||;s|/fullchain.pem||' )" [[ "$CERTS" == "" ]] && CERTS=none -echo "certificates|$CERTS" +echo "Certificates|$CERTS" RESOLV="$( ping -c1 -w1 "$CERTS" 2>/dev/null | head -1 | grep -oP '\d{1,3}(.\d{1,3}){3}' )" echo "NAT loopback|$( [[ "$RESOLV" == "$IP" ]] && echo yes || echo no )" diff --git a/bin/ncp-report b/bin/ncp-report index 7ca5af9c1..c27389037 100755 --- a/bin/ncp-report +++ b/bin/ncp-report @@ -38,8 +38,8 @@ echo "<--! Paste this in GitHub report -->" ## -open_summary "NextCloudPi diagnostics" -bash /usr/local/bin/ncp-diag | sed -r 's=(IP|certificates|gateway).*=\1|***REMOVED SENSITIVE VALUE***=g' | column -t -s'|' +open_summary "NextcloudPi diagnostics" +bash /usr/local/bin/ncp-diag | sed -r 's=(IP|Certificates|Gateway|Public IPv4|Public IPv6).*=\1|***REMOVED SENSITIVE VALUE***=g' | column -t -s'|' close_summary ## diff --git a/bin/ncp-suggestions b/bin/ncp-suggestions index 39f2cedac..bc314867e 100644 --- a/bin/ncp-suggestions +++ b/bin/ncp-suggestions @@ -23,10 +23,10 @@ is_active_app dnsmasq && \ grep -q "NAT loopback|no" <<<"$OUT" && \ echo -e "\nYou should enable dnsmasq to use your domain inside home" -grep -q "certificates|none" <<<"$OUT" && \ +grep -q "Certificates|none" <<<"$OUT" && \ echo -e "\nYou should run Lets Encrypt for trusted encrypted access" -grep -q "port check .*|closed" <<<"$OUT" && \ +grep -q "Port .*|closed" <<<"$OUT" && \ echo -e "\nYou should open your ports for Lets Encrypt and external access" grep -q "USB devices|none" <<<"$OUT" || { diff --git a/ncp-web/wizard/index.php b/ncp-web/wizard/index.php index 87d6fcc04..2cf673f14 100644 --- a/ncp-web/wizard/index.php +++ b/ncp-web/wizard/index.php @@ -1,6 +1,6 @@ GPL licensed (see end of file) * Use at your own risk! @@ -27,7 +27,7 @@ - NextCloudPi Wizard + NextcloudPi Wizard @@ -57,7 +57,7 @@
-

Welcome to NextCloudPi

+

Welcome to NextcloudPi

This wizard will help you configure your personal cloud.

@@ -81,7 +81,7 @@

- If you want to prepare the USB drive to be used with NextCloudPi hit Format USB. Skip if already formated as ext4 or BTRFS. + If you want to prepare the USB drive to be used with NextcloudPi hit Format USB. Skip if already formated as ext4 or BTRFS.
Attention! This will format your USB drive as BTRFS and will destroy any current data.

@@ -111,7 +111,7 @@

Port forwarding

To access from the outside, your need to forward ports 80 and 443 to your RPi IP address
- You can have NextCloudPi try to do this automatically for you
+ You can have NextcloudPi try to do this automatically for you
To do it manually yourself, you must access your router interface, usually at http://192.168.1.1

@@ -200,7 +200,7 @@
-

NextCloudPi is ready!

+

NextcloudPi is ready!

From c23abe7e0582665a9c8c8d49cf166d86de0f8c59 Mon Sep 17 00:00:00 2001 From: "Victor-ray, S" <12261439+ZendaiOwl@users.noreply.github.com> Date: Wed, 11 Jan 2023 18:51:36 +0100 Subject: [PATCH 07/54] =?UTF-8?q?=E0=BF=93=E2=9D=AF=20Added=20array=20decl?= =?UTF-8?q?arations=20so=20mapfile=20works=20properly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Victor-ray, S <12261439+ZendaiOwl@users.noreply.github.com> Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com> Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- bin/ncp-diag | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/ncp-diag b/bin/ncp-diag index dc89c8fae..755a1316f 100644 --- a/bin/ncp-diag +++ b/bin/ncp-diag @@ -79,6 +79,8 @@ function is_port_open() # Checks both port 80 & 443 for IPv4/IPv6 and returns the result or [N/A] [N/A] if ! [[ "$TYPE" =~ ^(0|4|6)$ ]] then + # As this echo is redirected to STDERR it will not be + # asssigned in the arrays of the if-statement below this function echo "Invalid type: $TYPE" 1>&2 return 1 elif [[ "$TYPE" == 0 ]] @@ -96,7 +98,11 @@ echo "Public IPv4|${publicIPv4:-"not found"}" publicIPv6=$(curl --silent --max-time 4 --ipv6 "https://ipv6.icanhazip.com" 2>/dev/null) || unset publicIPv6 echo "Public IPv6|${publicIPv6:-"not found"}" -# Reads each line as an array index element to input into IPv4PORTS array +# Declares the array variables for mapfile to work +declare -a IPv4PORTS +declare -a IPv6PORTS + +# Mapfile reads lines from standard input into an indexed array variable if [[ -n "$publicIPv4" ]] then mapfile -t IPv4PORTS < <(is_port_open 4) @@ -104,7 +110,6 @@ else mapfile -t IPv4PORTS < <(is_port_open 0) fi -# Reads each line as an array index element to input into IPv6PORTS array if [[ -n "$publicIPv6" ]] then mapfile -t IPv6PORTS < <(is_port_open 6) From 9afbf0b5b50de49c919700652dd9f5f1e3b4ff9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Thu, 12 Jan 2023 02:12:11 +0100 Subject: [PATCH 08/54] Implement clear-php-opcache.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com> Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- bin/ncp/TOOLS/clear-php-opcache.sh | 38 ++++++++++++++++++++++++++ etc/ncp-config.d/clear-php-opcache.cfg | 9 ++++++ 2 files changed, 47 insertions(+) create mode 100644 bin/ncp/TOOLS/clear-php-opcache.sh create mode 100644 etc/ncp-config.d/clear-php-opcache.cfg diff --git a/bin/ncp/TOOLS/clear-php-opcache.sh b/bin/ncp/TOOLS/clear-php-opcache.sh new file mode 100644 index 000000000..57a5a5e6d --- /dev/null +++ b/bin/ncp/TOOLS/clear-php-opcache.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Fix permissions of the data files, in case they were copied externally +# +# Copyleft 2017 by Ignacio Nunez Hernanz +# GPL licensed (see end of file) * Use at your own risk! +# +# More at: https://ownyourbits.com +# + + +configure() +{ + echo "Stopping php..." + service "php${PHPVER}-fpm" stop + clear_opcache + echo "Starting php..." + service "php${PHPVER}-fpm" start +} + +install() { :; } + +# License +# +# This script is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This script is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this script; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place, Suite 330, +# Boston, MA 02111-1307 USA diff --git a/etc/ncp-config.d/clear-php-opcache.cfg b/etc/ncp-config.d/clear-php-opcache.cfg new file mode 100644 index 000000000..0e3bdec81 --- /dev/null +++ b/etc/ncp-config.d/clear-php-opcache.cfg @@ -0,0 +1,9 @@ +{ + "id": "clear-php-opcache", + "name": "clear-php-opcache", + "title": "Clear PHP opcache", + "description": "Clears the PHP opcache directory. This can help with some crashes in PHP.", + "info": "", + "infotitle": "", + "params": [] +} From 04cf27148cb3c762030724007fdc547220a4f813 Mon Sep 17 00:00:00 2001 From: Tobias K <6317548+theCalcaholic@users.noreply.github.com> Date: Thu, 12 Jan 2023 02:23:20 +0100 Subject: [PATCH 09/54] Clear php opcache on ncp update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com> Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- bin/ncp-update-nc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/ncp-update-nc b/bin/ncp-update-nc index 7d1930276..d46a9b74e 100755 --- a/bin/ncp-update-nc +++ b/bin/ncp-update-nc @@ -292,6 +292,10 @@ then fi +# Clear PHP opcache +service "php${PHPVER}-fpm" stop +clear_opcache +service "php${PHPVER}-fpm" start # refresh completions ncc _completion -g --shell-type bash -p ncc | sed 's|/var/www/nextcloud/occ|ncc|g' > /usr/share/bash-completion/completions/ncp From f763e79f76bd7a1d731a7377f0107e291edc7452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Fri, 13 Jan 2023 00:53:58 +0100 Subject: [PATCH 10/54] build-docker.yml: Include nextcloud update in update test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/build-docker.yml | 88 +++++++++++++++++++++++++++- bin/ncp-update-nc | 2 +- build/docker/debian-ncp/run-parts.sh | 2 +- build/docker/nextcloud/020nextcloud | 3 +- build/docker/nextcloudpi/000ncp | 2 +- 5 files changed, 91 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index cf145063c..792c7c18a 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -58,7 +58,7 @@ jobs: ./build/build-docker.sh "${ARCH?}" docker tag "ownyourbits/nextcloudpi-${ARCH?}:latest" "thecalcaholic/ncp-internal-${ARCH?}:${{ github.run_id }}" testing_image="ownyourbits/nextcloudpi-${ARCH?}:latest" - [[ "${ARCH?}" == "arm64" ]] && testing_image="ownyourbits/ncp-qemu-fix-${ARCH?}:latest" + [[ "${ARCH?}" == "x86" ]] || testing_image="ownyourbits/ncp-qemu-fix-${ARCH?}:latest" docker tag "${testing_image}" "thecalcaholic/ncp-internal-${ARCH?}:${{ github.run_id }}-testing" docker push "thecalcaholic/ncp-internal-${ARCH?}:${{ github.run_id }}" docker push "thecalcaholic/ncp-internal-${ARCH?}:${{ github.run_id }}-testing" @@ -186,7 +186,60 @@ jobs: - name: Start new container run: | docker stop nextcloudpi - docker run -d -v ncdata:/data --rm -p 8443:443 -p 4443:4443 --name nextcloudpi thecalcaholic/ncp-internal-${ARCH?}:${{ github.run_id }}-testing localhost + docker run -d -v ncdata:/data --rm -p 8443:443 -p 4443:4443 -e NOBACKUP=true --name nextcloudpi thecalcaholic/ncp-internal-${ARCH?}:${{ github.run_id }}-testing localhost + - name: Wait for container startup + run: | + set -e + docker logs nextcloudpi |& awk "{ print \"${LOG_DCKR} \" \$0 }" + echo -e "${LOG_DCKR} ==========" + docker logs -f nextcloudpi |& awk "{ print \"${LOG_DCKR} \" \$0 }" & + + attempt=0 + for attempt in {1..30} + do + echo -e "${LOG_CICD} Waiting for container startup (attempt $attempt/30)..." + redis_pw="$(docker exec nextcloudpi bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"password'")" + redis_socket="$(docker exec nextcloudpi bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"host'")" + if docker logs nextcloudpi 2> /dev/null | grep '^Init done' > /dev/null \ + && [[ "$(docker exec nextcloudpi ncc maintenance:mode)" =~ .*disabled.* ]] \ + && docker exec nextcloudpi ncc status \ + && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" set redisready yes \ + && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" get redisready + then + echo -e "${LOG_CICD} Startup successful" + break + elif [[ "$attempt" -ge 30 ]] + then + echo -e "${LOG_CICD} Timeout reached." + exit 1 + fi + + attempt=$((attempt + 1)) + sleep 5 + done + - name: Update Nextcloud + run: | + set -e + docker logs nextcloudpi |& awk "{ print \"${LOG_DCKR} \" \$0 }" + echo -e "${LOG_DCKR} ==========" + docker logs -f nextcloudpi |& awk "{ print \"${LOG_DCKR} \" \$0 }" & + + current_nc_version="$(docker exec nextcloudpi ncc status | grep "version:" | awk '{ print $3 }')" + latest_nc_version="$(docker exec nextcloudpi cat /usr/local/etc/ncp.cfg | jq -r '.nextcloud_version')" + + if [[ "$current_nc_version" == "$latest_nc_version".* ]] + then + echo -e "${LOG_CICD} Nextcloud is up to date - skipping NC update test." + else + docker exec nextcloudpi bash -c "DBG=x ncp-update-nc ${latest_nc_version?}" |& awk "{ print \"${LOG_DCKR} \" \$0 }" + [[ ${PIPESTATUS[0]} -eq 0 ]] || { + echo -e "${LOG_CICD} Nextcloud Update failed" + echo -e "${LOG_CICD} Creating error report..." + docker exec nextcloudpi bash /usr/local/bin/ncp-report > error-report.txt + docker exec nextcloudpi bash /usr/local/bin/ncp-diag |& awk "{ print \"${LOG_DIAG} \" \$0 }" + exit 1 + } + fi - name: Integration Tests working-directory: ./tests run: | @@ -213,6 +266,8 @@ jobs: done [[ "$success" == "true" ]] || { echo -e "${LOG_CICD} System test failed in all attempts!" + echo -e "${LOG_CICD} Creating error report..." + docker exec nextcloudpi bash /usr/local/bin/ncp-report > error-report.txt exit 1 } echo -e "${LOG_CICD} System test successful" @@ -284,7 +339,36 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} - name: Setup Selenium run: pip install selenium + - name: Wait for container startup + run: | + set -e + docker logs nextcloudpi |& awk "{ print \"${LOG_DCKR} \" \$0 }" + echo -e "${LOG_DCKR} ==========" + docker logs -f nextcloudpi |& awk "{ print \"${LOG_DCKR} \" \$0 }" & + + attempt=0 + for attempt in {1..30} + do + echo -e "${LOG_CICD} Waiting for container startup (attempt $attempt/30)..." + redis_pw="$(docker exec nextcloudpi bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"password'")" + redis_socket="$(docker exec nextcloudpi bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"host'")" + if docker logs nextcloudpi 2> /dev/null | grep '^Init done' > /dev/null \ + && [[ "$(docker exec nextcloudpi ncc maintenance:mode)" =~ .*disabled.* ]] \ + && docker exec nextcloudpi ncc status \ + && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" set redisready yes \ + && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" get redisready + then + echo -e "${LOG_CICD} Startup successful" + break + elif [[ "$attempt" -ge 30 ]] + then + echo -e "${LOG_CICD} Timeout reached." + exit 1 + fi + attempt=$((attempt + 1)) + sleep 5 + done - name: Integration Tests working-directory: ./tests run: | diff --git a/bin/ncp-update-nc b/bin/ncp-update-nc index d46a9b74e..c9f6ca0fa 100755 --- a/bin/ncp-update-nc +++ b/bin/ncp-update-nc @@ -30,7 +30,7 @@ source /usr/local/etc/library.sh [[ -f /.docker-image ]] && BASEDIR=/data || BASEDIR=/var/www cd "$BASEDIR" DATADIR="$( get_nc_config_value datadirectory )" -ncc status &>/dev/null || { echo "Nextcloud is currently down"; exit 1; } +ncc status &>/dev/null || { [[ "$DBG" == x ]] && ncc status; echo "Nextcloud is currently down"; exit 1; } [[ -d /var/www/nextcloud-old ]] && { echo "Nextcloud backup directory found. Interrupted or already running installation?"; exit 1; } [[ -d /var/www/nextcloud ]] || { echo "Nextcloud directory not found" ; exit 1; } [[ -d "$DATADIR" ]] || { echo "Nextcloud data directory not found" ; exit 1; } diff --git a/build/docker/debian-ncp/run-parts.sh b/build/docker/debian-ncp/run-parts.sh index 6b552eedb..db5a9f434 100755 --- a/build/docker/debian-ncp/run-parts.sh +++ b/build/docker/debian-ncp/run-parts.sh @@ -62,7 +62,7 @@ for file in $( ls -1v /etc/services-enabled.d | grep -v ^000.* ); do done -if [[ -z "$NOBACKUP" ]] || [[ "$NOBACKUP" != "true" ]] && ! a2query -s ncp-activation -q +if [[ "$NOBACKUP" != "true" ]] && ! a2query -s ncp-activation -q then BKPDIR=/data/docker-startup-backups WITH_DATA=no diff --git a/build/docker/nextcloud/020nextcloud b/build/docker/nextcloud/020nextcloud index c25aa7f94..3a4400a4c 100755 --- a/build/docker/nextcloud/020nextcloud +++ b/build/docker/nextcloud/020nextcloud @@ -79,6 +79,7 @@ bash /usr/local/bin/nextcloud-domain.sh echo "Nextcloud version $(nc_version). NextCloudPi version $(cat /usr/local/etc/ncp-version)" # Display NC logs in the docker logs -tail -f -n0 "$(get_nc_config_value logfile)" & +LOG_FILE="$(get_nc_config_value logfile 2> /dev/null || true)" +tail -f -n0 "${LOG_FILE:-$( get_nc_config_value datadirectory )/nextcloud.log}" & exit 0 diff --git a/build/docker/nextcloudpi/000ncp b/build/docker/nextcloudpi/000ncp index efd3daa5c..6f215a5db 100755 --- a/build/docker/nextcloudpi/000ncp +++ b/build/docker/nextcloudpi/000ncp @@ -28,6 +28,6 @@ install_template "php/pool.d.www.conf.sh" "/etc/php/${PHPVER}/fpm/pool.d/www.con install_template "ncp-metrics.cfg.sh" "/usr/local/etc/ncp-metrics.cfg" touch /var/log/ncp.log -tail -f -n0 "$(get_nc_config_value logfile)" & +tail -f -n0 "/var/log/ncp.log" & exit 0 From 52f6454e233f9844701d7674ded949bbca87e325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Fri, 13 Jan 2023 13:36:17 +0100 Subject: [PATCH 11/54] build-SD-armbian.sh: Update to latest raspios version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- build/build-SD-armbian.sh | 2 +- build/build-SD-rpi.sh | 2 +- build/buildlib.sh | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/build/build-SD-armbian.sh b/build/build-SD-armbian.sh index 1a955c56e..f77695a4a 100755 --- a/build/build-SD-armbian.sh +++ b/build/build-SD-armbian.sh @@ -71,7 +71,7 @@ mkdir -p armbian/userpatches sed -e '/docker.*run/s/-it//' armbian/config/templates/config-docker.conf > armbian/userpatches/config-docker.conf docker pull "ghcr.io/armbian/build:$(cut -d"." -f1-2 < armbian/VERSION)-$(dpkg --print-architecture)" \ || docker pull "ghcr.io/armbian/build:latest-$(dpkg --print-architecture)" -armbian/compile.sh docker ncp +sudo armbian/compile.sh docker ncp rm "$CONF" # pack image diff --git a/build/build-SD-rpi.sh b/build/build-SD-rpi.sh index b7a2d0f19..d35e44d99 100755 --- a/build/build-SD-rpi.sh +++ b/build/build-SD-rpi.sh @@ -13,7 +13,7 @@ source build/buildlib.sh echo -e "\e[1m\n[ Build NCP Raspberry Pi ]\e[0m" -URL="https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2022-01-28/2022-01-28-raspios-bullseye-arm64-lite.zip" +URL="https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2022-09-26/2022-09-22-raspios-bullseye-arm64-lite.img.xz" SIZE=4G # Raspbian image size #CLEAN=0 # Pass this envvar to skip cleaning download cache IMG="${IMG:-NextCloudPi_RPi_$( date "+%m-%d-%y" ).img}" diff --git a/build/buildlib.sh b/build/buildlib.sh index 147d08b40..71aeb5762 100644 --- a/build/buildlib.sh +++ b/build/buildlib.sh @@ -279,7 +279,7 @@ function download_raspbian() local URL=$1 local IMGFILE=$2 local IMG_CACHE=cache/raspios_lite.img - local ZIP_CACHE=cache/raspios_lite.zip + local ZIP_CACHE=cache/raspios_lite.xz echo -e "\n\e[1m[ Download RaspiOS ]\e[0m" mkdir -p cache @@ -294,8 +294,7 @@ function download_raspbian() wget "$URL" -nv -O "$ZIP_CACHE" || return 1 } - unzip -o "$ZIP_CACHE" && \ - mv *-raspios-*.img $IMG_CACHE && \ + unxz -k -c "$ZIP_CACHE" > "$IMG_CACHE" && \ cp -v --reflink=auto $IMG_CACHE "$IMGFILE" } From 9e95cbb8c193419b2a3a386f4433bb5216051975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Fri, 13 Jan 2023 13:36:45 +0100 Subject: [PATCH 12/54] build-{docker,sd-images}.yml: Improve CICD robustness and output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/build-docker.yml | 49 ++++++++++-- .github/workflows/build-sd-images.yml | 109 ++++++++++++++++++-------- 2 files changed, 117 insertions(+), 41 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 792c7c18a..1d995133d 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -92,10 +92,12 @@ jobs: then version="latest" else - git checkout "${{ github.base_ref }}" + ref="${{ github.base_ref }}" + [[ -n "$ref" ]] || ref="${{ github.ref }}" + git checkout "$ref" if [[ "${{ github.ref_type }}" != "tag" ]] || ! git describe --tags > /dev/null then - git fetch -fu --tags origin ${{ github.base_ref }}:${{ github.base_ref }} + git fetch -fu --tags origin "${ref}:${ref}" fi version="$(git describe --tags || true)" [[ "$version" =~ .*-.*-.* ]] || { @@ -148,6 +150,37 @@ jobs: - name: Setup Selenium run: pip install selenium + - name: Wait for container startup + run: | + set -e + docker logs nextcloudpi |& awk "{ print \"${LOG_DCKR} \" \$0 }" + echo -e "${LOG_DCKR} ==========" + docker logs -f nextcloudpi |& awk "{ print \"${LOG_DCKR} \" \$0 }" & + + attempt=0 + for attempt in {1..30} + do + echo -e "${LOG_CICD} Waiting for container startup (attempt $attempt/30)..." + redis_pw="$(docker exec nextcloudpi bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"password'")" + redis_socket="$(docker exec nextcloudpi bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"host'")" + if docker logs nextcloudpi 2> /dev/null | grep '^Init done' > /dev/null \ + && [[ "$(docker exec nextcloudpi ncc maintenance:mode)" =~ .*disabled.* ]] \ + && docker exec nextcloudpi ncc status \ + && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" set redisready yes \ + && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" get redisready + then + echo -e "${LOG_CICD} Startup successful" + break + elif [[ "$attempt" -ge 30 ]] + then + echo -e "${LOG_CICD} Timeout reached." + exit 1 + fi + + attempt=$((attempt + 1)) + sleep 5 + done + - name: Activate container working-directory: ./tests run: | @@ -161,7 +194,7 @@ jobs: success=false for attempt in {1..5} do - echo ":: Activation Tests (attempt $attempt/5) ::" + echo -e "${LOG_CICD} == Activation Tests (attempt $attempt/5) ==" "${cmd[@]}" |& awk "{ print \"${LOG_TEST} \" \$0 }" [[ ${PIPESTATUS[0]} -eq 0 ]] || { tail -n 20 geckodriver.log |& awk "{ print \"${LOG_DIAG} \" \$0 }" || true @@ -254,7 +287,7 @@ jobs: success=false for attempt in {1..5} do - echo ":: System Tests (attempt $attempt/5) ::" + echo -e "${LOG_CICD} == System Tests (attempt $attempt/5) ==" python system_tests.py --no-ping --non-interactive |& awk "{ print \"${LOG_TEST} \" \$0 }" [[ ${PIPESTATUS[0]} -eq 0 ]] || { echo -e "${LOG_CICD} System test (attempt $attempt) failed!" @@ -275,7 +308,7 @@ jobs: success=false for attempt in {1..3} do - echo ":: Nextcloud Tests (attempt $attempt/5) ::" + echo -e "${LOG_CICD} == Nextcloud Tests (attempt $attempt/5) ==" python nextcloud_tests.py --no-gui localhost 8443 4443 |& awk "{ print \"${LOG_TEST} \" \$0 }" [[ ${PIPESTATUS[0]} -eq 0 ]] || { tail -n 20 geckodriver.log |& awk "{ print \"${LOG_DIAG} \" \$0 }" || true @@ -382,7 +415,7 @@ jobs: success=false for attempt in {1..5} do - echo ":: Activation Tests (attempt $attempt/5) ::" + echo -e "${LOG_CICD} == Activation Tests (attempt $attempt/5) ==" "${cmd[@]}" |& awk "{ print \"${LOG_TEST} \" \$0 }" [[ ${PIPESTATUS[0]} -eq 0 ]] || { tail -n 20 geckodriver.log >&2 |& awk "{ print \"${LOG_DIAG} \" \$0 }" || true @@ -403,7 +436,7 @@ jobs: success=false for attempt in {1..5} do - echo ":: System Tests (attempt $attempt/5) ::" + echo -e "${LOG_CICD} == System Tests (attempt $attempt/5) ==" python system_tests.py --no-ping --non-interactive |& awk "{ print \"${LOG_TEST} \" \$0 }" [[ ${PIPESTATUS[0]} -eq 0 ]] || { echo -e "${LOG_CICD} System test (attempt $attempt) failed!" @@ -422,7 +455,7 @@ jobs: success=false for attempt in {1..5} do - echo ":: Nextcloud Tests (attempt $attempt/5) ::" + echo -e "${LOG_CICD} == Nextcloud Tests (attempt $attempt/5) ==" python nextcloud_tests.py --no-gui localhost 8443 4443 |& awk "{ print \"${LOG_TEST} \" \$0 }" [[ ${PIPESTATUS[0]} -eq 0 ]] || { tail -n 20 geckodriver.log >&2 |& awk "{ print \"${LOG_DIAG} \" \$0 }" || true diff --git a/.github/workflows/build-sd-images.yml b/.github/workflows/build-sd-images.yml index 5fdd37fdc..578a65e3e 100644 --- a/.github/workflows/build-sd-images.yml +++ b/.github/workflows/build-sd-images.yml @@ -26,6 +26,11 @@ jobs: runs-on: ubuntu-latest env: VERSION: "${{ inputs.git_ref }}" + LOG_GUEST: "\\033[1;34mGUEST::\\033[0m" + LOG_NCP: "\\033[1;36m~NCP::\\033[0m" + LOG_CICD: "\\033[1;35mCICD::\\033[0m" + LOG_TEST: "\\033[1;33mTEST::\\033[0m" + LOG_DIAG: "\\033[1;31mDIAG::\\033[0m" defaults: run: shell: bash @@ -75,7 +80,7 @@ jobs: id: build-armbian-2nd run: | set -ex - echo "Cleanup armbian build leftovers..." + echo -e "${LOG_CICD} Cleanup armbian build leftovers..." sudo rm -rf armbian/ tmp/ output/ export LIB_TAG=master @@ -100,7 +105,7 @@ jobs: id: build-rpi run: | set -ex - echo "Protected? ${{ github.ref_protected }}" + echo -e "${LOG_CICD} Protected? ${{ github.ref_protected }}" export IMG="NextCloudPi_${{ inputs.board_name }}_${VERSION//\//_}.img" [[ "${{ github.ref_protected }}" == true ]] || export DBG=x wget -q https://github.com/multiarch/qemu-user-static/releases/latest/download/qemu-aarch64-static -O ./qemu-aarch64-static @@ -111,9 +116,9 @@ jobs: for i in {1..10} do sudo losetup | grep "${IMG}" || break; - [[ "$i" -lt 10 ]] || { echo "Timeout while waiting for image to unmount"; exit 1; } + [[ "$i" -lt 10 ]] || { echo -e "${LOG_CICD} Timeout while waiting for image to unmount"; exit 1; } sleep 6 - echo "Retrying ($i out of 10)" + echo -e "${LOG_CICD} Retrying ($i out of 10)" done echo "artifact_file=${IMG}" >> $GITHUB_OUTPUT @@ -132,6 +137,11 @@ jobs: VERSION: "${{ inputs.git_ref }}" ARTIFACT_ID: ${{ needs.build.outputs.artifact_name }} ARTIFACT_FILE: ${{ needs.build.outputs.artifact_file }} + LOG_GUEST: "\\033[1;34mGUEST::\\033[0m" + LOG_NCP: "\\033[1;36m~NCP::\\033[0m" + LOG_CICD: "\\033[1;35mCICD::\\033[0m" + LOG_TEST: "\\033[1;33mTEST::\\033[0m" + LOG_DIAG: "\\033[1;31mDIAG::\\033[0m" defaults: run: shell: bash @@ -176,42 +186,73 @@ jobs: - name: Test image id: test run: | - set -ex + set -e trap 'sudo machinectl terminate ncp' EXIT - sudo systemd-nspawn --boot -D ./raspbian_root/ -M ncp --hostname=nextcloudpi |& awk '{ print "CONTAINER::" $0 }' & + sudo systemd-nspawn --boot -D ./raspbian_root/ -M ncp --hostname=nextcloudpi |& awk "{ print \"${LOG_GUEST} \" \$0 }" & sleep 60 + CONTAINER_CMD=(sudo systemd-run --machine=ncp -P --wait) + success=false for attempt in {1..30} do - echo ":: Wait for container to startup (attempt $attempt/30) ::" - ip="$(sudo systemd-run --machine=ncp -P --wait bash -c '. /usr/local/etc/library.sh > /dev/null; get_ip')" + echo -e "${LOG_CICD} == Wait until container network is available (attempt $attempt/30) ==" + ip="$("${CONTAINER_CMD[@]}" bash -c '. /usr/local/etc/library.sh > /dev/null; get_ip')" [[ -n "$ip" ]] && curl -k "https://$ip/activate" > /dev/null || { sleep 6; continue; } success=true break done - sudo systemd-run --machine=ncp -P --wait bash -c 'cat /var/log/ncp.log' |& awk '{ print "NCP::" $0 }' - sudo systemd-run --machine=ncp -P --wait bash -c 'tail -n 0 -f /var/log/ncp.log' |& awk '{ print "NCP::" $0 }' & + cat ./raspbian_root/var/log/ncp.log |& awk "{ print \"${LOG_NCP} \" \$0 }" + tail -n 0 -f ./raspbian_root/var/log/ncp.log |& awk "{ print \"${LOG_NCP} \" \$0 }" & [[ "$success" == "true" ]] || { - echo "Could not reach container. Aborting..." + echo -e "${LOG_CICD} Could not reach container. Aborting..." exit 1 } + + attempt=0 + success=false + for attempt in {1..100} + do + echo -e "${LOG_CICD} Waiting for container startup (attempt $attempt/100)..." + redis_pw="$("${CONTAINER_CMD[@]}" bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"password'")" + redis_socket="$("${CONTAINER_CMD[@]}" bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"host'")" + if [[ "$("${CONTAINER_CMD[@]}" ncc maintenance:mode)" =~ .*disabled.* ]] \ + && "${CONTAINER_CMD[@]}" ncc status \ + && "${CONTAINER_CMD[@]}" redis-cli -s "$redis_socket" -a "$redis_pw" set redisready yes \ + && "${CONTAINER_CMD[@]}" redis-cli -s "$redis_socket" -a "$redis_pw" get redisready + then + echo -e "${LOG_CICD} Startup successful" + success=true + break + fi + + attempt=$((attempt + 1)) + sleep 5 + done + + [[ "$success" == "true" ]] || { + echo -e "${LOG_CICD} Timeout reached." + exit 1 + } + + set -x success=false for attempt in {1..5} do - echo ":: Activation Tests (attempt $attempt/5) ::" - python tests/activation_tests.py -t 300 --no-gui "$ip" 443 4443 || { - echo "Activation test failed!" - echo "Geckodriver logs:" - tail -n 20 geckodriver.log >&2 || true + echo -e "${LOG_CICD} == Activation Tests (attempt $attempt/5) ==" + python tests/activation_tests.py -t 300 --no-gui "$ip" 443 4443 |& awk "{ print \"${LOG_TEST} \" \$0 }" + [[ ${PIPESTATUS[0]} -eq 0 ]] || { + echo -e "${LOG_CICD} Activation test failed!" + echo -e "${LOG_DIAG} Geckodriver logs:" + tail -n 20 geckodriver.log >&2 |& awk "{ print \"${LOG_DIAG} \" \$0 }" echo "================" - echo "mysql: " - sudo systemd-run --wait -P --machine=ncp bash /usr/local/bin/ncp-diag - sudo systemd-run --wait -P --machine=ncp systemctl status mysql + echo -e "${LOG_DIAG} mysql: " + sudo systemd-run --wait -P --machine=ncp bash /usr/local/bin/ncp-diag |& awk "{ print \"${LOG_DIAG} \" \$0 }" + sudo systemd-run --wait -P --machine=ncp systemctl status mysql |& awk "{ print \"${LOG_DIAG} \" \$0 }" sleep 12 continue } @@ -219,16 +260,17 @@ jobs: break done [[ "$success" == "true" ]] || { - echo "Activation test failed in all attempts!" + echo -e "${LOG_CICD} Activation test failed in all attempts!" exit 1 } success=false for attempt in {1..5} do - echo ":: System Tests (attempt $attempt/5) ::" - sudo python tests/system_tests.py --non-interactive || { - echo "System test failed!" + echo -e "${LOG_CICD} == System Tests (attempt $attempt/5) ==" + sudo python tests/system_tests.py --non-interactive |& awk "{ print \"${LOG_TEST} \" \$0 }" + [[ ${PIPESTATUS[0]} -eq 0 ]] || { + echo -e "${LOG_CICD} System test failed!" sleep 12 continue } @@ -236,21 +278,22 @@ jobs: break done [[ "$success" == "true" ]] || { - echo "System test failed in all attempts!" + echo -e "${LOG_CICD} System test failed in all attempts!" exit 1 } success=false for attempt in {1..5} do - echo ":: Nextcloud Tests (attempt $attempt/5) ::" - python tests/nextcloud_tests.py --no-gui "$ip" 443 4443 || { - echo "Nextcloud test failed!" - echo "Geckodriver logs:" - tail -n 20 geckodriver.log >&2 || true - echo "================" - echo "ncp.log: " - sudo systemd-run --wait -P --machine=ncp ncp /bin/bash -c "tail -n20 /var/log/ncp.log" || true + echo -e "${LOG_CICD} == Nextcloud Tests (attempt $attempt/5) ==" + python tests/nextcloud_tests.py --no-gui "$ip" 443 4443 |& awk "{ print \"${LOG_TEST} \" \$0 }" + [[ ${PIPESTATUS[0]} -eq 0 ]] || { + echo -e "${LOG_CICD} Nextcloud test failed!" + echo -e "{$LOG_DIAG} Geckodriver logs:" + tail -n 20 geckodriver.log >&2 |& awk "{ print \"${LOG_DIAG} \" \$0 }" || true + echo -e "${LOG_CICD} ================" + echo -e "${LOG_DIAG} ncp.log: " + sudo systemd-run --wait -P --machine=ncp ncp /bin/bash -c "tail -n20 /var/log/ncp.log" |& awk "{ print \"${LOG_DIAG} \" \$0 }" || true sleep 12 continue } @@ -259,6 +302,6 @@ jobs: done [[ "$success" == "true" ]] || { - echo "Nextcloud test failed in all attempts!" + echo -e "${LOG_CICD} Nextcloud test failed in all attempts!" exit 1 } From b65bcff218350109c6f059b36be285b7636593eb Mon Sep 17 00:00:00 2001 From: "Victor-ray, S" <12261439+ZendaiOwl@users.noreply.github.com> Date: Fri, 13 Jan 2023 19:02:01 +0100 Subject: [PATCH 13/54] =?UTF-8?q?=E0=BF=93=E2=9D=AF=20Removed=20the=20extr?= =?UTF-8?q?a=20forward=20slash=20in=20the=20config=20directory=20variable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Victor-ray, S <12261439+ZendaiOwl@users.noreply.github.com> Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update.sh b/update.sh index 970d3a391..ee514d977 100755 --- a/update.sh +++ b/update.sh @@ -22,7 +22,7 @@ then [[ "$ALLOW_UPDATE_SCRIPT" == "1" ]] || exit 1 fi -CONFDIR=/usr/local/etc/ncp-config.d/ +CONFDIR=/usr/local/etc/ncp-config.d UPDATESDIR=updates # don't make sense in a docker container From 1934fd2de6495d115b7766681394d7492effe157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Sat, 14 Jan 2023 01:40:06 +0100 Subject: [PATCH 14/54] build-sd-images.yml: Fix permissions when accessing container logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/build-sd-images.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-sd-images.yml b/.github/workflows/build-sd-images.yml index 578a65e3e..2b37b60e4 100644 --- a/.github/workflows/build-sd-images.yml +++ b/.github/workflows/build-sd-images.yml @@ -204,8 +204,8 @@ jobs: success=true break done - cat ./raspbian_root/var/log/ncp.log |& awk "{ print \"${LOG_NCP} \" \$0 }" - tail -n 0 -f ./raspbian_root/var/log/ncp.log |& awk "{ print \"${LOG_NCP} \" \$0 }" & + sudo cat ./raspbian_root/var/log/ncp.log |& awk "{ print \"${LOG_NCP} \" \$0 }" + sudo tail -n 0 -f ./raspbian_root/var/log/ncp.log |& awk "{ print \"${LOG_NCP} \" \$0 }" & [[ "$success" == "true" ]] || { echo -e "${LOG_CICD} Could not reach container. Aborting..." From 3298b95aa96dc81dfe32ae93c8424cf1afa5c210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Sat, 14 Jan 2023 02:43:45 +0100 Subject: [PATCH 15/54] ncp-update-nc, 1.51.0.sh: Remove deprecated package php-json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- bin/ncp-update-nc | 4 ++-- updates/1.51.0.sh | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 updates/1.51.0.sh diff --git a/bin/ncp-update-nc b/bin/ncp-update-nc index c9f6ca0fa..aa515f1bb 100755 --- a/bin/ncp-update-nc +++ b/bin/ncp-update-nc @@ -228,9 +228,9 @@ then export DEBIAN_FRONTEND=noninteractive PHPVER_OLD="$PHPVER" PHPVER_NEW="8.1" - PHP_PACKAGES_OLD=(php-{common,igbinary,redis} "php${PHPVER_OLD}" \ + PHP_PACKAGES_OLD=(php-{common,igbinary,redis,json} "php${PHPVER_OLD}" \ "php${PHPVER_OLD}"-{curl,gd,fpm,cli,opcache,mbstring,xml,zip,fileinfo,ldap,intl,bz2,json,common,readline,mysql,bcmath,gmp}) - PHP_PACKAGES_NEW=("php${PHPVER_NEW}" php-json \ + PHP_PACKAGES_NEW=("php${PHPVER_NEW}" \ "php${PHPVER_NEW}"-{curl,gd,fpm,cli,opcache,mbstring,xml,zip,fileinfo,ldap,intl,bz2,mysql,bcmath,gmp,redis,common}) php_restore() { diff --git a/updates/1.51.0.sh b/updates/1.51.0.sh new file mode 100644 index 000000000..df137295a --- /dev/null +++ b/updates/1.51.0.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +apt-get remove -y php-json || true From b631366020e635b86fb43978ec9b9af760a36418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Wed, 18 Jan 2023 00:54:44 +0100 Subject: [PATCH 16/54] build-docker.yml: Improve detecting of successful container startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/build-docker.yml | 21 +++++++++++++++------ .github/workflows/build-sd-images.yml | 3 ++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 1d995133d..29f0cb4ef 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -158,13 +158,16 @@ jobs: docker logs -f nextcloudpi |& awk "{ print \"${LOG_DCKR} \" \$0 }" & attempt=0 + stage=0 for attempt in {1..30} do echo -e "${LOG_CICD} Waiting for container startup (attempt $attempt/30)..." redis_pw="$(docker exec nextcloudpi bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"password'")" redis_socket="$(docker exec nextcloudpi bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"host'")" - if docker logs nextcloudpi 2> /dev/null | grep '^Init done' > /dev/null \ - && [[ "$(docker exec nextcloudpi ncc maintenance:mode)" =~ .*disabled.* ]] \ + if [[ "$stage" == "0" ]] && docker logs nextcloudpi 2> /dev/null | grep '^Init done' > /dev/null + then + stage=1 + elif [[ "$(docker exec nextcloudpi ncc maintenance:mode)" =~ .*disabled.* ]] \ && docker exec nextcloudpi ncc status \ && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" set redisready yes \ && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" get redisready @@ -228,13 +231,16 @@ jobs: docker logs -f nextcloudpi |& awk "{ print \"${LOG_DCKR} \" \$0 }" & attempt=0 + stage=0 for attempt in {1..30} do echo -e "${LOG_CICD} Waiting for container startup (attempt $attempt/30)..." redis_pw="$(docker exec nextcloudpi bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"password'")" redis_socket="$(docker exec nextcloudpi bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"host'")" - if docker logs nextcloudpi 2> /dev/null | grep '^Init done' > /dev/null \ - && [[ "$(docker exec nextcloudpi ncc maintenance:mode)" =~ .*disabled.* ]] \ + if [[ "$stage" == "0" ]] && docker logs nextcloudpi 2> /dev/null | grep '^Init done' > /dev/null + then + stage=1 + elif [[ "$(docker exec nextcloudpi ncc maintenance:mode)" =~ .*disabled.* ]] \ && docker exec nextcloudpi ncc status \ && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" set redisready yes \ && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" get redisready @@ -380,13 +386,16 @@ jobs: docker logs -f nextcloudpi |& awk "{ print \"${LOG_DCKR} \" \$0 }" & attempt=0 + stage=0 for attempt in {1..30} do echo -e "${LOG_CICD} Waiting for container startup (attempt $attempt/30)..." redis_pw="$(docker exec nextcloudpi bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"password'")" redis_socket="$(docker exec nextcloudpi bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"host'")" - if docker logs nextcloudpi 2> /dev/null | grep '^Init done' > /dev/null \ - && [[ "$(docker exec nextcloudpi ncc maintenance:mode)" =~ .*disabled.* ]] \ + if [[ "$stage" == "0" ]] && docker logs nextcloudpi 2> /dev/null | grep '^Init done' > /dev/null + then + stage=1 + elif [[ "$(docker exec nextcloudpi ncc maintenance:mode)" =~ .*disabled.* ]] \ && docker exec nextcloudpi ncc status \ && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" set redisready yes \ && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" get redisready diff --git a/.github/workflows/build-sd-images.yml b/.github/workflows/build-sd-images.yml index 2b37b60e4..4891058d3 100644 --- a/.github/workflows/build-sd-images.yml +++ b/.github/workflows/build-sd-images.yml @@ -217,6 +217,7 @@ jobs: for attempt in {1..100} do echo -e "${LOG_CICD} Waiting for container startup (attempt $attempt/100)..." + set -x redis_pw="$("${CONTAINER_CMD[@]}" bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"password'")" redis_socket="$("${CONTAINER_CMD[@]}" bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"host'")" if [[ "$("${CONTAINER_CMD[@]}" ncc maintenance:mode)" =~ .*disabled.* ]] \ @@ -228,7 +229,7 @@ jobs: success=true break fi - + set +x attempt=$((attempt + 1)) sleep 5 done From 4f2d61546cbf464a5a8871f3361ed08aa98dd691 Mon Sep 17 00:00:00 2001 From: "Victor-ray, S" <12261439+ZendaiOwl@users.noreply.github.com> Date: Sat, 14 Jan 2023 17:13:43 +0100 Subject: [PATCH 17/54] =?UTF-8?q?=E0=BF=93=E2=9D=AF=20Update=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Victor-ray, S <12261439+ZendaiOwl@users.noreply.github.com> Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- README.md | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index f316f723c..1c221029e 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,6 @@ Find the full documentation at [docs.nextcloudpi.com](http://docs.nextcloudpi.co * Security audits with Lynis and Debsecan * ZRAM * SMART hard drive health monitoring - * Prometheus metrics monitoring Extras can be activated and configured using the web interface at HTTPS port 4443 @@ -92,31 +91,51 @@ sudo ncp-config ## Run in docker ``` -docker run -d -p 4443:4443 -p 443:443 -p 80:80 -v ncdata:/data --name nextcloudpi ownyourbits/nextcloudpi $DOMAIN +docker run --detach \ + --publish 4443:4443 \ + --publish 443:443 \ + --publish 80:80 \ + --volume ncdata:/data \ + --name nextcloudpi \ + ownyourbits/nextcloudpi $DOMAIN ``` +`$DOMAIN` can also be the IP-address of the host device. + ## Run in LXD ``` -lxc import NextcloudPi_LXD_09-29-21.tar.bz -lxc start ncp +lxc image import "NextcloudPi_LXD_vX.XX.X.tar.gz" --alias "nextcloudpi" # Imports the image, replace the X's with version number +lxc launch "nextcloudpi" ncp # Launches a container from the image +lxc start ncp # Starts the container you've launched from the imported image ``` ## How to build -Install: +Packages -- `git` -- `docker` +- `apt-utils` +- `apt-transport-https` - `build-essential` -- `qemu` -- `qemu-user-static` +- `binfmt-support` +- `binutils` +- `bzip2` +- `ca-certificates` - `chroot` +- `cron` +- `curl` +- `dialog` +- `lsb-release` - `jq` +- `git` - `psmisc` - `procps` - -and all the usual building tools. +- `wget` +- `whiptail` +- `qemu` +- `qemu-user-static` +- `docker` _(If you're building a Docker image)_ +- `lxd` _(If you're building an LXD/LXC container image)_ ``` git clone https://github.com/nextcloud/nextcloudpi.git From 1c5bc66401eb90c5e17100b32bca9e608e5f23e8 Mon Sep 17 00:00:00 2001 From: "Victor-ray, S" <12261439+ZendaiOwl@users.noreply.github.com> Date: Mon, 16 Jan 2023 15:18:50 +0100 Subject: [PATCH 18/54] =?UTF-8?q?=E0=BF=93=E2=9D=AF=20Updated=20the=20READ?= =?UTF-8?q?ME?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Victor-ray, S <12261439+ZendaiOwl@users.noreply.github.com> Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- README.md | 175 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 153 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 1c221029e..afa22ae29 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,40 @@ English | [Traditional Chinese 繁體中文](i18n/README-zh_TW.md) | [Simplified Chinese 简体中文](i18n/README-zh_CN.md) -# NextcloudPi [![chatroom icon](https://patrolavia.github.io/telegram-badge/chat.png)](https://t.me/NextcloudPi) [![forums icon](https://img.shields.io/badge/help-forums-blue.svg)](https://help.nextcloud.com/c/support/appliances-docker-snappy-vm) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=N8PJHSEQF4G7Y&lc=US&item_name=Own%20Your%20Bits&item_number=NextcloudPi&no_note=1&no_shipping=1¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted) [![blog](https://img.shields.io/badge/follow-blog-orange.svg)](https://ownyourbits.com) +_(The translated README pages are not updated at this time)_ -![NCP Logo](https://github.com/nextcloud/nextcloudpi/blob/master/ncp-app/img/app.svg) +# NextcloudPi -This is the build code for [NextcloudPi](https://nextcloudpi.com). +[![telegram chatroom icon][telegram-badge]][chat-telegram] [![Matrix chatroom icon][matrix-badge]][chat-matrix] [![Docker icon][docker-badge]][ncp-docker-hub] [![Nextcloud icon][nc-badge]][nc-github] -NextcloudPi is a ready to use image for Virtual Machines, Raspberry Pi, Odroid HC1, rock64 and other boards [(⇒Downloads)](https://github.com/nextcloud/nextcloudpi/releases). +[![Forum icon][forum-badge]][nc-forum-support] -This code also generates the NextcloudPi [docker image](https://hub.docker.com/r/ownyourbits/nextcloudpi), LXD and VM, and includes an installer for any Debian based system. +

+ NCP Logo +

-Find the full documentation at [docs.nextcloudpi.com](http://docs.nextcloudpi.com) +This is the build code for [NextcloudPi][ncp-website]. + +NextcloudPi is a ready to use image for Virtual Machines, Raspberry Pi, Odroid HC1, rock64 and other boards [(⇒Downloads)][ncp-releases]. + +This code also generates the NextcloudPi [docker image][ncp-docker-hub], LXD and VM, and includes an installer for any Debian based system. + +Find the full documentation at [docs.nextcloudpi.com][ncp-docs-website] --- -[![VM Integration Tests](https://github.com/nextcloud/nextcloudpi/workflows/VM%20Integration%20Tests/badge.svg)](https://github.com/nextcloud/nextcloudpi/actions/workflows/vm-tests.yml) +[![VM Integration Tests][vm-integration-tests-badge]][vm-tests] -[![Docker Integration Tests](https://github.com/nextcloud/nextcloudpi/actions/workflows/build-docker.yml/badge.svg)](https://github.com/nextcloud/nextcloudpi/actions/workflows/build-docker.yml) +[![Docker Integration Tests][docker-integrations-tests-badge]][docker-tests] --- ## Features - * Debian/Raspbian 11 Bullseye - * Nextcloud 25.0.2 + * Raspberry Pi OS/Debian 11 _(Bullseye)_ + * Nextcloud * Apache, with HTTP2 enabled * PHP 8.1 - * MariaDB 10 + * MariaDB * Redis memory cache * ncp-config TUI for easy setup ( RAM logs, USB drive and more ) * Automatic redirection to HTTPS @@ -77,7 +85,7 @@ Find the full documentation at [docs.nextcloudpi.com](http://docs.nextcloudpi.co Extras can be activated and configured using the web interface at HTTPS port 4443 -![ncp-web](https://user-images.githubusercontent.com/21343324/136853829-f4e99ec0-6307-431f-b4c7-21b2330cae7f.png) +![ncp-web][ncp-web-image] Or from the command line using @@ -85,7 +93,7 @@ Or from the command line using sudo ncp-config ``` -![NCP-config](https://help.nextcloud.com/uploads/default/original/3X/b/3/b3d157022a32296ab54428b14b5df02104a91f18.png) +![NCP-config][ncp-config-image] ## Run in docker @@ -100,16 +108,52 @@ docker run --detach \ ownyourbits/nextcloudpi $DOMAIN ``` -`$DOMAIN` can also be the IP-address of the host device. +`$DOMAIN` can also be the IP-address of the host device if you're accessing it via IP-address in your local home network. + +Can also be run with the `--init` flag for zombie process reaping + +``` +docker run --detach \ + --init \ + --publish 4443:4443 \ + --publish 443:443 \ + --publish 80:80 \ + --volume ncdata:/data \ + --name nextcloudpi \ + ownyourbits/nextcloudpi $DOMAIN +``` + +It takes a moment to start completely, check with `docker logs nextcloudpi` until it says `Init done` ## Run in LXD ``` -lxc image import "NextcloudPi_LXD_vX.XX.X.tar.gz" --alias "nextcloudpi" # Imports the image, replace the X's with version number -lxc launch "nextcloudpi" ncp # Launches a container from the image -lxc start ncp # Starts the container you've launched from the imported image +# Imports the LXC image, replace the X's with version number +lxc image import "NextcloudPi_LXD_vX.XX.X.tar.gz" --alias "nextcloudpi" + +# Launches a container from the image +lxc launch "nextcloudpi" ncp + +# Starts the container you've launched from the imported image +lxc start ncp ``` +## Run in Proxmox + +Use the [install script][ncp-proxmox-install-script-v5] from [tteck][tteck-profile] to install the LXC container on your Proxmox instance + +He has multiple helper scripts available for Proxmox on his [website][website-helper-scripts], do go have a look if you're using Proxmox. :+1: + +Installation: `bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/nextcloudpi-v5.sh)"` + +Default Settings: `2GB RAM - 8GB Storage - 2vCPU` + +_(Check his [website][website-helper-scripts] if this has changed and we haven't had the time to update it here yet, it's located under: Media - Photo > NextcloudPi LXC)_ + +Thenk you [tteck][tteck-profile] :heart: for making the helper script & letting us use this for Proxmox installations :pray: + +You can find his GitHub repository with his helper scripts [here][gh-helper-scripts-repo]. + ## How to build Packages @@ -137,6 +181,8 @@ Packages - `docker` _(If you're building a Docker image)_ - `lxd` _(If you're building an LXD/LXC container image)_ +### Raspberry Pi img + ``` git clone https://github.com/nextcloud/nextcloudpi.git cd nextcloudpi @@ -149,7 +195,7 @@ cd nextcloudpi ./build-SD-armbian.sh odroidxu4 # supported board code name ``` -In order to generate the Docker images, you'll also need to change the username, repo and tags to match your credentials at Docker Hub. +In order to build the Docker images, you'll also need to change the username, repo and tags in the script to match your credentials at Docker Hub. ``` git clone https://github.com/nextcloud/nextcloudpi.git @@ -175,12 +221,97 @@ _Note: this assumes a clean Debian install, and there is no rollback method_ # curl -sSL https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/install.sh | bash ``` -## Downloads +## Downloads & Links + +[Website][ncp-website] -https://nextcloudpi.com +[Docker Hub][ncp-docker-hub] -https://hub.docker.com/r/ownyourbits/nextcloudpi +[Nextcloud Forum][nc-forum] + +[Nextcloud Forum Support][nc-forum-support] + +_(Use the Forum for Support questions please, there's a NCP tag available, it will bridge your post to the Matrix and Telegram chats)_ ## Contact -You can find us in the [forums](https://help.nextcloud.com/c/support/appliances-docker-snappy-vm) and a [Telegram group](https://t.me/NextcloudPi) +You can find us on the [Forum][nc-forum], [Telegram][chat-telegram] or [Matrix][chat-matrix] + + + +[ncp-website]: https://nextcloudpi.com + +[ncp-docs-website]: http://docs.nextcloudpi.com + +[ncp-docker-hub]: https://hub.docker.com/r/ownyourbits/nextcloudpi + +[ncp-releases]: https://github.com/nextcloud/nextcloudpi/releases + +[nc-github]: https://github.com/nextcloud + + + +[nc-forum]: https://help.nextcloud.com/ + +[nc-forum-support]: https://help.nextcloud.com/c/support/appliances-docker-snappy-vm + + + +[chat-matrix]: https://matrix.to/#/#nextcloudpi:matrix.org + +[chat-telegram]: https://t.me/NextcloudPi + + + +[vm-tests]: https://github.com/nextcloud/nextcloudpi/actions/workflows/vm-tests.yml + +[docker-tests]: https://github.com/nextcloud/nextcloudpi/actions/workflows/build-docker.yml + + + +[vm-integration-tests-badge]: https://github.com/nextcloud/nextcloudpi/workflows/VM%20Integration%20Tests/badge.svg + +[docker-integrations-tests-badge]: https://github.com/nextcloud/nextcloudpi/actions/workflows/build-docker.yml/badge.svg + + + +[docker-badge]: https://img.shields.io/badge/Docker-2CA5E0?style=for-the-badge&logo=docker&logoColor=white + +[telegram-badge]: https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white + +[matrix-badge]: https://img.shields.io/badge/matrix-000000?style=for-the-badge&logo=Matrix&logoColor=white + +[forum-badge]: https://img.shields.io/badge/help-forums-blue.svg + +[nc-badge]: https://img.shields.io/badge/Nextcloud-0082C9?style=for-the-badge&logo=Nextcloud&logoColor=white + + + +[tteck-profile]: https://github.com/tteck + +[gh-helper-scripts-repo]: https://github.com/tteck/Proxmox + +[website-helper-scripts]: https://tteck.github.io/Proxmox/ + +[ncp-proxmox-install-script-v5]: https://github.com/tteck/Proxmox/blob/main/install/nextcloudpi-v5-install.sh + + + +[ncp-web-image]: https://user-images.githubusercontent.com/21343324/136853829-f4e99ec0-6307-431f-b4c7-21b2330cae7f.png + +[ncp-config-image]: https://help.nextcloud.com/uploads/default/original/3X/b/3/b3d157022a32296ab54428b14b5df02104a91f18.png From 2e6c8d5da477deb91570123dfc0950fe3febb00a Mon Sep 17 00:00:00 2001 From: "Victor-ray, S" <12261439+ZendaiOwl@users.noreply.github.com> Date: Mon, 16 Jan 2023 15:19:23 +0100 Subject: [PATCH 19/54] =?UTF-8?q?=E0=BF=93=E2=9D=AF=20Updated=20the=20READ?= =?UTF-8?q?ME?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Victor-ray, S <12261439+ZendaiOwl@users.noreply.github.com> Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index afa22ae29..866d3e762 100644 --- a/README.md +++ b/README.md @@ -285,9 +285,6 @@ You can find us on the [Forum][nc-forum], [Telegram][chat-telegram] or [Matrix][ [gh-badge]: https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white - -[]: - --> [docker-badge]: https://img.shields.io/badge/Docker-2CA5E0?style=for-the-badge&logo=docker&logoColor=white From f80c3a680fc370aebe4803b0b3897d41d66cf2ab Mon Sep 17 00:00:00 2001 From: "Victor-ray, S" <12261439+ZendaiOwl@users.noreply.github.com> Date: Mon, 16 Jan 2023 17:37:54 +0100 Subject: [PATCH 20/54] =?UTF-8?q?=E0=BF=93=E2=9D=AF=20Updated=20the=20READ?= =?UTF-8?q?ME=20a=20little=20bit=20more?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Victor-ray, S <12261439+ZendaiOwl@users.noreply.github.com> Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- README.md | 67 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 866d3e762..302615f8e 100644 --- a/README.md +++ b/README.md @@ -4,27 +4,32 @@ _(The translated README pages are not updated at this time)_ # NextcloudPi -[![telegram chatroom icon][telegram-badge]][chat-telegram] [![Matrix chatroom icon][matrix-badge]][chat-matrix] [![Docker icon][docker-badge]][ncp-docker-hub] [![Nextcloud icon][nc-badge]][nc-github] +[![Telegram icon][telegram-badge]][chat-telegram] [![Matrix icon][matrix-badge]][chat-matrix] [![Docker icon][docker-badge]][ncp-docker-hub] [![Nextcloud icon][nc-badge]][nc-github] [![Forum icon][forum-badge]][nc-forum-support]

- NCP Logo + NextcloudPi logo

-This is the build code for [NextcloudPi][ncp-website]. +This is the build code for the [NextcloudPi][ncp-website] open-source community project. -NextcloudPi is a ready to use image for Virtual Machines, Raspberry Pi, Odroid HC1, rock64 and other boards [(⇒Downloads)][ncp-releases]. +NextcloudPi is a ready to use image for Virtual Machines, Raspberry Pi, Odroid HC1, Rock64 and other boards. ([⇒ Downloads][ncp-releases]) -This code also generates the NextcloudPi [docker image][ncp-docker-hub], LXD and VM, and includes an installer for any Debian based system. +This code also generates the NextcloudPi [docker image][ncp-docker-hub], LXD container & VM, there is an install script for the latest stable Debian based system as well. -Find the full documentation at [docs.nextcloudpi.com][ncp-docs-website] +Find the documentation at [docs.nextcloudpi.com][ncp-docs-website], the documentation is all written by volunteers, + +Please to reach out in the [Matrix][chat-matrix-wiki] or [Telegram][chat-telegram-wiki] Wiki group chats if you want to help out to keep them up-to-date and we'll add you to the [Wiki Group][nc-forum-wiki-group] on the [forum][nc-forum]. --- -[![VM Integration Tests][vm-integration-tests-badge]][vm-tests] +[![VM Tests][vm-tests-badge]][vm-tests] -[![Docker Integration Tests][docker-integrations-tests-badge]][docker-tests] +[![Docker Tests][docker-tests-badge]][docker-tests] --- @@ -123,7 +128,7 @@ docker run --detach \ ownyourbits/nextcloudpi $DOMAIN ``` -It takes a moment to start completely, check with `docker logs nextcloudpi` until it says `Init done` +It takes a moment to start completely, you can check this with `docker logs nextcloudpi` until it says `Init done`. ## Run in LXD @@ -181,7 +186,7 @@ Packages - `docker` _(If you're building a Docker image)_ - `lxd` _(If you're building an LXD/LXC container image)_ -### Raspberry Pi img +### Raspberry Pi IMG ``` git clone https://github.com/nextcloud/nextcloudpi.git @@ -195,7 +200,7 @@ cd nextcloudpi ./build-SD-armbian.sh odroidxu4 # supported board code name ``` -In order to build the Docker images, you'll also need to change the username, repo and tags in the script to match your credentials at Docker Hub. +In order to build & push the Docker image to your repository, you'll also need to change the username, repo and tags in the script to match your credentials at Docker Hub. ``` git clone https://github.com/nextcloud/nextcloudpi.git @@ -255,12 +260,18 @@ You can find us on the [Forum][nc-forum], [Telegram][chat-telegram] or [Matrix][ [nc-forum-support]: https://help.nextcloud.com/c/support/appliances-docker-snappy-vm +[nc-forum-wiki-group]: https://help.nextcloud.com/g/NCP_Wiki_Team/members + [chat-matrix]: https://matrix.to/#/#nextcloudpi:matrix.org +[chat-matrix-wiki]: https://matrix.to/#/#NCP_Wiki_Team:matrix.org + [chat-telegram]: https://t.me/NextcloudPi +[chat-telegram-wiki]: https://t.me/NCP_Wiki_Team + [vm-tests]: https://github.com/nextcloud/nextcloudpi/actions/workflows/vm-tests.yml @@ -269,23 +280,9 @@ You can find us on the [Forum][nc-forum], [Telegram][chat-telegram] or [Matrix][ -[vm-integration-tests-badge]: https://github.com/nextcloud/nextcloudpi/workflows/VM%20Integration%20Tests/badge.svg - -[docker-integrations-tests-badge]: https://github.com/nextcloud/nextcloudpi/actions/workflows/build-docker.yml/badge.svg - - +[docker-tests-badge]: https://github.com/nextcloud/nextcloudpi/actions/workflows/build-docker.yml/badge.svg [docker-badge]: https://img.shields.io/badge/Docker-2CA5E0?style=for-the-badge&logo=docker&logoColor=white @@ -297,7 +294,7 @@ You can find us on the [Forum][nc-forum], [Telegram][chat-telegram] or [Matrix][ [nc-badge]: https://img.shields.io/badge/Nextcloud-0082C9?style=for-the-badge&logo=Nextcloud&logoColor=white - + [tteck-profile]: https://github.com/tteck @@ -312,3 +309,17 @@ You can find us on the [Forum][nc-forum], [Telegram][chat-telegram] or [Matrix][ [ncp-web-image]: https://user-images.githubusercontent.com/21343324/136853829-f4e99ec0-6307-431f-b4c7-21b2330cae7f.png [ncp-config-image]: https://help.nextcloud.com/uploads/default/original/3X/b/3/b3d157022a32296ab54428b14b5df02104a91f18.png + + From 09508fa1e78c86aa03e892c539adf5c7adb73c14 Mon Sep 17 00:00:00 2001 From: "Victor-ray, S" <12261439+ZendaiOwl@users.noreply.github.com> Date: Mon, 16 Jan 2023 17:46:47 +0100 Subject: [PATCH 21/54] =?UTF-8?q?=E0=BF=93=E2=9D=AF=20Added=20a=20badge=20?= =?UTF-8?q?for=20the=20devel=20branch=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Victor-ray, S <12261439+ZendaiOwl@users.noreply.github.com> Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 302615f8e..830044d42 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,18 @@ Please to reach out in the [Matrix][chat-matrix-wiki] or [Telegram][chat-telegra --- +`master` + [![VM Tests][vm-tests-badge]][vm-tests] [![Docker Tests][docker-tests-badge]][docker-tests] +`devel` + +[![VM Tests][gh-vm-tests-badge-devel]][vm-tests] + +[![Docker Tests][gh-docker-tests-badge-devel]][docker-tests] + --- ## Features @@ -280,6 +288,14 @@ You can find us on the [Forum][nc-forum], [Telegram][chat-telegram] or [Matrix][ +[gh-vm-tests-badge]: https://github.com/nextcloud/nextcloudpi/actions/workflows/vm-tests.yml/badge.svg + +[gh-docker-tests-badge]: https://github.com/nextcloud/nextcloudpi/actions/workflows/build-docker.yml/badge.svg + +[gh-vm-tests-badge-devel]: https://github.com/nextcloud/nextcloudpi/actions/workflows/vm-tests.yml/badge.svg?branch=devel + +[gh-docker-tests-badge-devel]: https://github.com/nextcloud/nextcloudpi/actions/workflows/build-docker.yml/badge.svg?branch=devel + [vm-tests-badge]: https://github.com/nextcloud/nextcloudpi/workflows/VM%20Integration%20Tests/badge.svg [docker-tests-badge]: https://github.com/nextcloud/nextcloudpi/actions/workflows/build-docker.yml/badge.svg From b21a2cd630f9e57b639d2555783e4431f4d6df38 Mon Sep 17 00:00:00 2001 From: "Victor-ray, S" <12261439+ZendaiOwl@users.noreply.github.com> Date: Mon, 16 Jan 2023 17:49:38 +0100 Subject: [PATCH 22/54] =?UTF-8?q?=E0=BF=93=E2=9D=AF=20Fixed=20a=20typo=20I?= =?UTF-8?q?=20had=20missed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Victor-ray, S <12261439+ZendaiOwl@users.noreply.github.com> Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 830044d42..57ac09e11 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ This code also generates the NextcloudPi [docker image][ncp-docker-hub], LXD con Find the documentation at [docs.nextcloudpi.com][ncp-docs-website], the documentation is all written by volunteers, -Please to reach out in the [Matrix][chat-matrix-wiki] or [Telegram][chat-telegram-wiki] Wiki group chats if you want to help out to keep them up-to-date and we'll add you to the [Wiki Group][nc-forum-wiki-group] on the [forum][nc-forum]. +Please reach out in the [Matrix][chat-matrix-wiki] or [Telegram][chat-telegram-wiki] Wiki group chats if you want to help out to keep them up-to-date and we'll add you to the [Wiki Group][nc-forum-wiki-group] on the [forum][nc-forum]. --- From a873d615f6efe2e607c06b9ad13e20b80773d283 Mon Sep 17 00:00:00 2001 From: "Victor-ray, S" <12261439+ZendaiOwl@users.noreply.github.com> Date: Mon, 16 Jan 2023 18:11:09 +0100 Subject: [PATCH 23/54] =?UTF-8?q?=E0=BF=93=E2=9D=AF=20Added=20an=20example?= =?UTF-8?q?=20of=20running=20the=20install=20script=20with=20sudo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Victor-ray, S <12261439+ZendaiOwl@users.noreply.github.com> Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 57ac09e11..b11629453 100644 --- a/README.md +++ b/README.md @@ -230,14 +230,24 @@ _Note: this assumes a clean Debian install, and there is no rollback method_ ### Curl install scripts +This is executed as `root` as indicated by the `#` + ``` # curl -sSL https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/install.sh | bash ``` -## Downloads & Links +If you're not `root` you can run it with `sudo` like so + +``` +curl -sSL https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/install.sh | sudo bash +``` + +## Links [Website][ncp-website] +[Downloads][ncp-releases] + [Docker Hub][ncp-docker-hub] [Nextcloud Forum][nc-forum] From b10868f313a8fe890e323bd0885de24bad417ef0 Mon Sep 17 00:00:00 2001 From: "Victor-ray, S" <12261439+ZendaiOwl@users.noreply.github.com> Date: Tue, 17 Jan 2023 23:02:59 +0100 Subject: [PATCH 24/54] =?UTF-8?q?=E0=BF=93=E2=9D=AF=20Fixed=20a=20comma=20?= =?UTF-8?q?(,)=20that=20should've=20been=20a=20period=20(.)=20and=20docker?= =?UTF-8?q?=20to=20Docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Victor-ray, S <12261439+ZendaiOwl@users.noreply.github.com> Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b11629453..af00e6293 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,9 @@ This is the build code for the [NextcloudPi][ncp-website] open-source community NextcloudPi is a ready to use image for Virtual Machines, Raspberry Pi, Odroid HC1, Rock64 and other boards. ([⇒ Downloads][ncp-releases]) -This code also generates the NextcloudPi [docker image][ncp-docker-hub], LXD container & VM, there is an install script for the latest stable Debian based system as well. +This code also generates the NextcloudPi [Docker image][ncp-docker-hub], LXD container & VM, there is an install script for the latest stable Debian based system as well. -Find the documentation at [docs.nextcloudpi.com][ncp-docs-website], the documentation is all written by volunteers, +Find the documentation at [docs.nextcloudpi.com][ncp-docs-website], the documentation is all written by volunteers. Please reach out in the [Matrix][chat-matrix-wiki] or [Telegram][chat-telegram-wiki] Wiki group chats if you want to help out to keep them up-to-date and we'll add you to the [Wiki Group][nc-forum-wiki-group] on the [forum][nc-forum]. From ab67e98647558d93aa2a50a302f8cbedbcea6305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Wed, 18 Jan 2023 01:35:49 +0100 Subject: [PATCH 25/54] build-sd-images.yml: Improve debug output for container status check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit build-docker.yml: Wait for container update to complete Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/build-docker.yml | 30 +++++++++++++++++++++++++++ .github/workflows/build-sd-images.yml | 24 +++++++++++++-------- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 29f0cb4ef..1b86b65e1 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -279,6 +279,36 @@ jobs: exit 1 } fi + - name: Wait for update completion + run: | + set -e + docker logs nextcloudpi |& awk "{ print \"${LOG_DCKR} \" \$0 }" + echo -e "${LOG_DCKR} ==========" + docker logs -f nextcloudpi |& awk "{ print \"${LOG_DCKR} \" \$0 }" & + + attempt=0 + for attempt in {1..30} + do + echo -e "${LOG_CICD} Waiting for container startup (attempt $attempt/30)..." + redis_pw="$(docker exec nextcloudpi bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"password'")" + redis_socket="$(docker exec nextcloudpi bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"host'")" + if [[ "$(docker exec nextcloudpi ncc maintenance:mode)" =~ .*disabled.* ]] \ + && docker exec nextcloudpi ncc status \ + && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" set redisready yes \ + && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" get redisready + then + echo -e "${LOG_CICD} Startup successful" + break + elif [[ "$attempt" -ge 30 ]] + then + echo -e "${LOG_CICD} Timeout reached." + exit 1 + fi + + attempt=$((attempt + 1)) + sleep 5 + done + - name: Integration Tests working-directory: ./tests run: | diff --git a/.github/workflows/build-sd-images.yml b/.github/workflows/build-sd-images.yml index 4891058d3..4faa87bd6 100644 --- a/.github/workflows/build-sd-images.yml +++ b/.github/workflows/build-sd-images.yml @@ -188,6 +188,13 @@ jobs: run: | set -e + log_err() { + rc="${1?}" + msg="${2?}" + echo -e "${LOG_DIAG} $msg" >&2 + return $rc + } + trap 'sudo machinectl terminate ncp' EXIT sudo systemd-nspawn --boot -D ./raspbian_root/ -M ncp --hostname=nextcloudpi |& awk "{ print \"${LOG_GUEST} \" \$0 }" & @@ -200,7 +207,7 @@ jobs: do echo -e "${LOG_CICD} == Wait until container network is available (attempt $attempt/30) ==" ip="$("${CONTAINER_CMD[@]}" bash -c '. /usr/local/etc/library.sh > /dev/null; get_ip')" - [[ -n "$ip" ]] && curl -k "https://$ip/activate" > /dev/null || { sleep 6; continue; } + [[ -n "$ip" ]] && curl -k "https://$ip/activate/" > /dev/null || { sleep 6; continue; } success=true break done @@ -217,19 +224,18 @@ jobs: for attempt in {1..100} do echo -e "${LOG_CICD} Waiting for container startup (attempt $attempt/100)..." - set -x - redis_pw="$("${CONTAINER_CMD[@]}" bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"password'")" - redis_socket="$("${CONTAINER_CMD[@]}" bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"host'")" - if [[ "$("${CONTAINER_CMD[@]}" ncc maintenance:mode)" =~ .*disabled.* ]] \ - && "${CONTAINER_CMD[@]}" ncc status \ - && "${CONTAINER_CMD[@]}" redis-cli -s "$redis_socket" -a "$redis_pw" set redisready yes \ - && "${CONTAINER_CMD[@]}" redis-cli -s "$redis_socket" -a "$redis_pw" get redisready + redis_pw="$("${CONTAINER_CMD[@]}" bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"password'")" \ + && redis_socket="$("${CONTAINER_CMD[@]}" bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"host'")" \ + || log_err $? "Error retrieving redis credentials" + if { [[ "$("${CONTAINER_CMD[@]}" ncc maintenance:mode)" =~ .*disabled.* ]] || log_err $? "Maintenance mode is enabled or could not be retrieved"; } \ + && { "${CONTAINER_CMD[@]}" ncc status || log_err $? "ncc status check failed"; } \ + && { "${CONTAINER_CMD[@]}" redis-cli -s "$redis_socket" -a "$redis_pw" set redisready yes || log_err $? "Failed to set redis variable"; } \ + && { "${CONTAINER_CMD[@]}" redis-cli -s "$redis_socket" -a "$redis_pw" get redisready || log_err $? "Failed to read redis variable"; } then echo -e "${LOG_CICD} Startup successful" success=true break fi - set +x attempt=$((attempt + 1)) sleep 5 done From 92698aa0281c3b643419a48e7e08bba293aea6d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Wed, 18 Jan 2023 02:00:07 +0100 Subject: [PATCH 26/54] build-sd-images.yml: Increase number of retries when waiting for container startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/build-docker.yml | 2 +- .github/workflows/build-sd-images.yml | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 1b86b65e1..1e40ea2a2 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -289,7 +289,7 @@ jobs: attempt=0 for attempt in {1..30} do - echo -e "${LOG_CICD} Waiting for container startup (attempt $attempt/30)..." + echo -e "${LOG_CICD} Waiting for update completion (attempt $attempt/30)..." redis_pw="$(docker exec nextcloudpi bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"password'")" redis_socket="$(docker exec nextcloudpi bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"host'")" if [[ "$(docker exec nextcloudpi ncc maintenance:mode)" =~ .*disabled.* ]] \ diff --git a/.github/workflows/build-sd-images.yml b/.github/workflows/build-sd-images.yml index 4faa87bd6..1bdc24b14 100644 --- a/.github/workflows/build-sd-images.yml +++ b/.github/workflows/build-sd-images.yml @@ -221,7 +221,7 @@ jobs: attempt=0 success=false - for attempt in {1..100} + for attempt in {1..1000} do echo -e "${LOG_CICD} Waiting for container startup (attempt $attempt/100)..." redis_pw="$("${CONTAINER_CMD[@]}" bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"password'")" \ @@ -242,6 +242,11 @@ jobs: [[ "$success" == "true" ]] || { echo -e "${LOG_CICD} Timeout reached." + "${CONTAINER_CMD[@]}" systemctl status mysql |& awk "{ print \"${LOG_DIAG} \" \$0 }" + "${CONTAINER_CMD[@]}" systemctl status redis |& awk "{ print \"${LOG_DIAG} \" \$0 }" + "${CONTAINER_CMD[@]}" systemctl status 'php*-fpm' |& awk "{ print \"${LOG_DIAG} \" \$0 }" + "${CONTAINER_CMD[@]}" systemctl status apache2 |& awk "{ print \"${LOG_DIAG} \" \$0 }" + "${CONTAINER_CMD[@]}" ncp-diag |& awk "{ print \"${LOG_DIAG} \" \$0 }" exit 1 } From f09ccf26ce8904efdcba6644b05da75f5ab1838d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Wed, 18 Jan 2023 02:47:57 +0100 Subject: [PATCH 27/54] library.sh: Have notify_admin notify *all* admins, not just the first MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.51.0.sh: clear opcache after removing php-json, notify users if php8.2 packages need to be removed Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- etc/library.sh | 9 ++++++--- updates/1.51.0.sh | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/etc/library.sh b/etc/library.sh index 46d5265db..4eab4c201 100644 --- a/etc/library.sh +++ b/etc/library.sh @@ -543,9 +543,12 @@ function notify_admin() { local header="$1" local msg="$2" - local admin=$(mysql -u root nextcloud -Nse "select uid from oc_group_user where gid='admin' limit 1;") - [[ "${admin}" == "" ]] && { echo "admin user not found" >&2; return 0; } - ncc notification:generate "${admin}" "${header}" -l "${msg}" || true + local admins=$(mysql -u root nextcloud -Nse "select uid from oc_group_user where gid='admin';") + [[ "${admins}" == "" ]] && { echo "admin user not found" >&2; return 0; } + while read -r admin + do + ncc notification:generate "${admin}" "${header}" -l "${msg}" || true + done <<<"$admins" } function save_maintenance_mode() diff --git a/updates/1.51.0.sh b/updates/1.51.0.sh index df137295a..2a1bdf51e 100644 --- a/updates/1.51.0.sh +++ b/updates/1.51.0.sh @@ -1,3 +1,18 @@ #!/bin/bash -apt-get remove -y php-json || true +set -e + +source /usr/local/etc/library.sh + +dpkg -l | grep -e '^ii' | grep -e 'php-json' > /dev/null && { + apt-get remove -y php-json + run_app "clear-php-opcache" +} + +dpkg -l | grep -e '^ii' | grep -e 'php8.2' > /dev/null && { + msg="PHP 8.2 packages have been detected on your ncp instance, which could cause issues. If you didn't install them on purpose, please remove them with the following command: sudo apt remove php8.2-*" + echo -e "$msg" + notify_admin "NextcloudPi" "$msg" +} + +exit 0 From 8a824db61cd468338fe95b76373f942e54d430f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Wed, 18 Jan 2023 03:42:11 +0100 Subject: [PATCH 28/54] ncp-update-nc: Ensure recovery directory exists before attempting restore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ncp-update-nc: Clear opcache *before* running ncc commands - build-sd-images: Don't abort pipeline when failing to retrieve redis credentials Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/build-sd-images.yml | 4 ++-- bin/ncp-update-nc | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-sd-images.yml b/.github/workflows/build-sd-images.yml index 1bdc24b14..0496083d2 100644 --- a/.github/workflows/build-sd-images.yml +++ b/.github/workflows/build-sd-images.yml @@ -223,10 +223,10 @@ jobs: success=false for attempt in {1..1000} do - echo -e "${LOG_CICD} Waiting for container startup (attempt $attempt/100)..." + echo -e "${LOG_CICD} Waiting for container startup (attempt $attempt/1000)..." redis_pw="$("${CONTAINER_CMD[@]}" bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"password'")" \ && redis_socket="$("${CONTAINER_CMD[@]}" bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"host'")" \ - || log_err $? "Error retrieving redis credentials" + || log_err $? "Error retrieving redis credentials" || true if { [[ "$("${CONTAINER_CMD[@]}" ncc maintenance:mode)" =~ .*disabled.* ]] || log_err $? "Maintenance mode is enabled or could not be retrieved"; } \ && { "${CONTAINER_CMD[@]}" ncc status || log_err $? "ncc status check failed"; } \ && { "${CONTAINER_CMD[@]}" redis-cli -s "$redis_socket" -a "$redis_pw" set redisready yes || log_err $? "Failed to set redis variable"; } \ diff --git a/bin/ncp-update-nc b/bin/ncp-update-nc index aa515f1bb..ddd1ac2ee 100755 --- a/bin/ncp-update-nc +++ b/bin/ncp-update-nc @@ -110,6 +110,7 @@ BKP_="$( ls -1t "$BKPDIR"/nextcloud-bkp_*.tar.gz 2>/dev/null | head -1 )" [[ -f "$BKP_" ]] || { set +eE; echo "Error backing up"; false || cleanup; } [[ $RET -ne 0 ]] && { rm -f "$BKP_"; set +eE; echo "Error backing up"; false || cleanup; } BKP="$( dirname "$BKP_" )/$( basename "$BKP_" .tar.gz )-${CURRENT}.tar.gz" +echo "Storing backup at '$BKP'..." mv "$BKP_" "$BKP" # simple restore if anything fails from here @@ -165,6 +166,7 @@ rollback() { rm -rf /var/www/nextcloud.tar.bz2 "$BASEDIR"/nextcloud-old echo "Rolling back to backup $BKP..." local TMPDATA + mkdir -p "$BASEDIR/recovery/" TMPDATA="$( mktemp -d "$BASEDIR/recovery/ncp-data.XXXXXX" )" || { echo "Failed to create temp dir" >&2; exit 1; } [[ "$DATADIR" == "$BASEDIR/nextcloud/data" ]] && mv -T "$DATADIR" "$TMPDATA" ncp-restore "$BKP" || { echo "Rollback failed! Data left at $TMPDATA"; exit 1; } @@ -182,6 +184,11 @@ chown -R www-data:www-data nextcloud find nextcloud/ -type d -exec chmod 750 {} \; find nextcloud/ -type f -exec chmod 640 {} \; +# Clear PHP opcache +service "php${PHPVER}-fpm" stop +clear_opcache +service "php${PHPVER}-fpm" start + # upgrade #################### echo "Upgrade..." @@ -292,11 +299,6 @@ then fi -# Clear PHP opcache -service "php${PHPVER}-fpm" stop -clear_opcache -service "php${PHPVER}-fpm" start - # refresh completions ncc _completion -g --shell-type bash -p ncc | sed 's|/var/www/nextcloud/occ|ncc|g' > /usr/share/bash-completion/completions/ncp From 7a9a2ea3010b229330050d655aea984caf49ebcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Wed, 18 Jan 2023 03:47:05 +0100 Subject: [PATCH 29/54] build-sd-images.yml: Remove '-e' shell option for the test step MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/build-sd-images.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-sd-images.yml b/.github/workflows/build-sd-images.yml index 0496083d2..608a6fb6e 100644 --- a/.github/workflows/build-sd-images.yml +++ b/.github/workflows/build-sd-images.yml @@ -186,7 +186,6 @@ jobs: - name: Test image id: test run: | - set -e log_err() { rc="${1?}" From 07fd406030fd267fe53655b5e38b820398994af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Wed, 18 Jan 2023 04:20:32 +0100 Subject: [PATCH 30/54] opcache.ini.sh: Ensure opcache temp dir exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- etc/ncp-templates/php/opcache.ini.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/etc/ncp-templates/php/opcache.ini.sh b/etc/ncp-templates/php/opcache.ini.sh index 53a5c0de0..653930e38 100644 --- a/etc/ncp-templates/php/opcache.ini.sh +++ b/etc/ncp-templates/php/opcache.ini.sh @@ -9,7 +9,7 @@ if [[ "$1" == "--defaults" ]] || ! [[ -f "${BINDIR}/CONFIG/nc-datadir.sh" ]] && then echo "INFO: Restoring template to default settings" >&2 - TMP_DIR="/tmp" + TMP_DIR="/tmp/.opcache" elif is_docker then DATADIR="/data-ro/ncdata/data" @@ -19,6 +19,8 @@ else TMP_DIR="$(source "${BINDIR}/CONFIG/nc-datadir.sh"; tmpl_opcache_dir)" fi +mkdir -p "$TMP_DIR" + cat < Date: Wed, 18 Jan 2023 05:00:30 +0100 Subject: [PATCH 31/54] opcache.ini.sh: include potential fix for opcache jit segfaults MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- etc/ncp-templates/php/opcache.ini.sh | 1 + updates/1.51.0.sh | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/etc/ncp-templates/php/opcache.ini.sh b/etc/ncp-templates/php/opcache.ini.sh index 653930e38..77121c049 100644 --- a/etc/ncp-templates/php/opcache.ini.sh +++ b/etc/ncp-templates/php/opcache.ini.sh @@ -32,4 +32,5 @@ opcache.memory_consumption=128 opcache.save_comments=1 opcache.revalidate_freq=1 opcache.file_cache=${TMP_DIR}; +opcache.jit=function; EOF diff --git a/updates/1.51.0.sh b/updates/1.51.0.sh index 2a1bdf51e..165919af8 100644 --- a/updates/1.51.0.sh +++ b/updates/1.51.0.sh @@ -6,9 +6,12 @@ source /usr/local/etc/library.sh dpkg -l | grep -e '^ii' | grep -e 'php-json' > /dev/null && { apt-get remove -y php-json - run_app "clear-php-opcache" } +echo "Updating opcache configuration..." +install_template "php/opcache.ini.sh" "/etc/php/${PHPVER}/mods-available/opcache.ini" +run_app "clear-php-opcache" + dpkg -l | grep -e '^ii' | grep -e 'php8.2' > /dev/null && { msg="PHP 8.2 packages have been detected on your ncp instance, which could cause issues. If you didn't install them on purpose, please remove them with the following command: sudo apt remove php8.2-*" echo -e "$msg" From bdf7c118411b771687295dfbd56401ff31d0fc03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Wed, 18 Jan 2023 05:13:08 +0100 Subject: [PATCH 32/54] build-docker.yml: Allow 10 attempts for activation tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/build-docker.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 1e40ea2a2..3ee60ecd0 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -195,13 +195,13 @@ jobs: [[ "${ARCH?}" == "x86" ]] || { sleep 60; cmd+=(--timeout 300); } success=false - for attempt in {1..5} + for attempt in {1..10} do - echo -e "${LOG_CICD} == Activation Tests (attempt $attempt/5) ==" + echo -e "${LOG_CICD} == Activation Tests (attempt $attempt/10) ==" "${cmd[@]}" |& awk "{ print \"${LOG_TEST} \" \$0 }" [[ ${PIPESTATUS[0]} -eq 0 ]] || { tail -n 20 geckodriver.log |& awk "{ print \"${LOG_DIAG} \" \$0 }" || true - echo -e "${LOG_CICD} Activation test (attempt $attempt/5) failed!" + echo -e "${LOG_CICD} Activation test (attempt $attempt/10) failed!" docker exec nextcloudpi bash /usr/local/bin/ncp-diag |& awk "{ print \"${LOG_DIAG} \" \$0 }" || true cat /proc/sys/fs/binfmt_misc/qemu-aarch64 |& awk "{ print \"${LOG_DIAG} (qemu-aarch64) \" \$0 }" || true cat /proc/sys/fs/binfmt_misc/qemu-arm |& awk "{ print \"${LOG_DIAG} (qemu-arm) \" \$0 }" || true @@ -452,13 +452,13 @@ jobs: [[ "${ARCH?}" == "x86" ]] || { sleep 60; cmd+=(--timeout 300); } success=false - for attempt in {1..5} + for attempt in {1..10} do - echo -e "${LOG_CICD} == Activation Tests (attempt $attempt/5) ==" + echo -e "${LOG_CICD} == Activation Tests (attempt $attempt/10) ==" "${cmd[@]}" |& awk "{ print \"${LOG_TEST} \" \$0 }" [[ ${PIPESTATUS[0]} -eq 0 ]] || { tail -n 20 geckodriver.log >&2 |& awk "{ print \"${LOG_DIAG} \" \$0 }" || true - echo -e "${LOG_CICD} Activation test (attempt $attempt/3) failed!" + echo -e "${LOG_CICD} Activation test (attempt $attempt/10) failed!" docker exec nextcloudpi bash /usr/local/bin/ncp-diag |& awk "{ print \"${LOG_DIAG} \" \$0 }" || true sleep 12 continue From 8cfc779dd558eaaa4dfd6192a130764d9ca575d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Wed, 18 Jan 2023 05:28:02 +0100 Subject: [PATCH 33/54] build-docker.yml: Increase attempts for container startup check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/build-docker.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 3ee60ecd0..ed5c4bb39 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -232,7 +232,7 @@ jobs: attempt=0 stage=0 - for attempt in {1..30} + for attempt in {1..200} do echo -e "${LOG_CICD} Waiting for container startup (attempt $attempt/30)..." redis_pw="$(docker exec nextcloudpi bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"password'")" @@ -243,7 +243,8 @@ jobs: elif [[ "$(docker exec nextcloudpi ncc maintenance:mode)" =~ .*disabled.* ]] \ && docker exec nextcloudpi ncc status \ && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" set redisready yes \ - && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" get redisready + && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" get redisready \ + && curl -k https://localhost:8443/activate/ then echo -e "${LOG_CICD} Startup successful" break @@ -256,6 +257,9 @@ jobs: attempt=$((attempt + 1)) sleep 5 done + + echo "Wait one more minute..." + sleep 60 - name: Update Nextcloud run: | set -e @@ -417,7 +421,7 @@ jobs: attempt=0 stage=0 - for attempt in {1..30} + for attempt in {1..200} do echo -e "${LOG_CICD} Waiting for container startup (attempt $attempt/30)..." redis_pw="$(docker exec nextcloudpi bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"password'")" @@ -428,7 +432,8 @@ jobs: elif [[ "$(docker exec nextcloudpi ncc maintenance:mode)" =~ .*disabled.* ]] \ && docker exec nextcloudpi ncc status \ && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" set redisready yes \ - && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" get redisready + && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" get redisready \ + && curl -k https://localhost:8443/activate/ then echo -e "${LOG_CICD} Startup successful" break From 6fad75e586fbaaf1fc1a0c8ae949a51581493ed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Wed, 18 Jan 2023 05:37:08 +0100 Subject: [PATCH 34/54] build-sd-images.yml: Disable container shutdown on exit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/build-sd-images.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-sd-images.yml b/.github/workflows/build-sd-images.yml index 608a6fb6e..e844408c0 100644 --- a/.github/workflows/build-sd-images.yml +++ b/.github/workflows/build-sd-images.yml @@ -194,8 +194,6 @@ jobs: return $rc } - trap 'sudo machinectl terminate ncp' EXIT - sudo systemd-nspawn --boot -D ./raspbian_root/ -M ncp --hostname=nextcloudpi |& awk "{ print \"${LOG_GUEST} \" \$0 }" & sleep 60 @@ -262,7 +260,7 @@ jobs: tail -n 20 geckodriver.log >&2 |& awk "{ print \"${LOG_DIAG} \" \$0 }" echo "================" echo -e "${LOG_DIAG} mysql: " - sudo systemd-run --wait -P --machine=ncp bash /usr/local/bin/ncp-diag |& awk "{ print \"${LOG_DIAG} \" \$0 }" + sudo systemd-run --wait -P --machine=ncp bash /usr/local/bin/ncp-diag |& awk "{ print \"${LOG_DIAG} \" \$0 }" || true sudo systemd-run --wait -P --machine=ncp systemctl status mysql |& awk "{ print \"${LOG_DIAG} \" \$0 }" sleep 12 continue @@ -312,6 +310,8 @@ jobs: break done + sudo machinectl terminate ncp + [[ "$success" == "true" ]] || { echo -e "${LOG_CICD} Nextcloud test failed in all attempts!" exit 1 From 262e4b1591311839e224cc97f7b997766f1485fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Wed, 18 Jan 2023 21:31:36 +0100 Subject: [PATCH 35/54] library.sh: Increase retries for setting up notify_push to 5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/build-docker.yml | 16 ++++++++++------ .github/workflows/build-sd-images.yml | 20 ++++++++++---------- etc/library.sh | 6 +++--- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index ed5c4bb39..50a93c9e2 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -159,30 +159,34 @@ jobs: attempt=0 stage=0 + success=false for attempt in {1..30} do echo -e "${LOG_CICD} Waiting for container startup (attempt $attempt/30)..." redis_pw="$(docker exec nextcloudpi bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"password'")" redis_socket="$(docker exec nextcloudpi bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"host'")" - if [[ "$stage" == "0" ]] && docker logs nextcloudpi 2> /dev/null | grep '^Init done' > /dev/null + if [[ "$stage" == "0" ]] && docker logs nextcloudpi 2> /dev/null | grep '^Init done' then stage=1 elif [[ "$(docker exec nextcloudpi ncc maintenance:mode)" =~ .*disabled.* ]] \ && docker exec nextcloudpi ncc status \ && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" set redisready yes \ - && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" get redisready + && docker exec nextcloudpi redis-cli -s "$redis_socket" -a "$redis_pw" get redisready \ + && curl -k https://localhost:8443/activate/ > /dev/null then + success=true echo -e "${LOG_CICD} Startup successful" break - elif [[ "$attempt" -ge 30 ]] - then - echo -e "${LOG_CICD} Timeout reached." - exit 1 fi attempt=$((attempt + 1)) sleep 5 done + + [[ "$success" == "true" ]] || { + echo -e "${LOG_CICD} Timeout reached." + exit 1 + } - name: Activate container working-directory: ./tests diff --git a/.github/workflows/build-sd-images.yml b/.github/workflows/build-sd-images.yml index e844408c0..3e93cac18 100644 --- a/.github/workflows/build-sd-images.yml +++ b/.github/workflows/build-sd-images.yml @@ -218,9 +218,9 @@ jobs: attempt=0 success=false - for attempt in {1..1000} + for attempt in {1..150} do - echo -e "${LOG_CICD} Waiting for container startup (attempt $attempt/1000)..." + echo -e "${LOG_CICD} Waiting for container startup (attempt $attempt/150)..." redis_pw="$("${CONTAINER_CMD[@]}" bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"password'")" \ && redis_socket="$("${CONTAINER_CMD[@]}" bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"host'")" \ || log_err $? "Error retrieving redis credentials" || true @@ -239,11 +239,11 @@ jobs: [[ "$success" == "true" ]] || { echo -e "${LOG_CICD} Timeout reached." - "${CONTAINER_CMD[@]}" systemctl status mysql |& awk "{ print \"${LOG_DIAG} \" \$0 }" - "${CONTAINER_CMD[@]}" systemctl status redis |& awk "{ print \"${LOG_DIAG} \" \$0 }" - "${CONTAINER_CMD[@]}" systemctl status 'php*-fpm' |& awk "{ print \"${LOG_DIAG} \" \$0 }" - "${CONTAINER_CMD[@]}" systemctl status apache2 |& awk "{ print \"${LOG_DIAG} \" \$0 }" - "${CONTAINER_CMD[@]}" ncp-diag |& awk "{ print \"${LOG_DIAG} \" \$0 }" + "${CONTAINER_CMD[@]}" -q systemctl status mysql |& awk "{ print \"${LOG_DIAG} \" \$0 }" + "${CONTAINER_CMD[@]}" -q systemctl status redis |& awk "{ print \"${LOG_DIAG} \" \$0 }" + "${CONTAINER_CMD[@]}" -q systemctl status 'php*-fpm' |& awk "{ print \"${LOG_DIAG} \" \$0 }" + "${CONTAINER_CMD[@]}" -q systemctl status apache2 |& awk "{ print \"${LOG_DIAG} \" \$0 }" + "${CONTAINER_CMD[@]}" -q ncp-diag |& awk "{ print \"${LOG_DIAG} \" \$0 }" exit 1 } @@ -260,8 +260,8 @@ jobs: tail -n 20 geckodriver.log >&2 |& awk "{ print \"${LOG_DIAG} \" \$0 }" echo "================" echo -e "${LOG_DIAG} mysql: " - sudo systemd-run --wait -P --machine=ncp bash /usr/local/bin/ncp-diag |& awk "{ print \"${LOG_DIAG} \" \$0 }" || true - sudo systemd-run --wait -P --machine=ncp systemctl status mysql |& awk "{ print \"${LOG_DIAG} \" \$0 }" + "${CONTAINER_CMD[@]}" -q ncp-diag |& awk "{ print \"${LOG_DIAG} \" \$0 }" || true + "${CONTAINER_CMD[@]}" -q systemctl status mysql |& awk "{ print \"${LOG_DIAG} \" \$0 }" sleep 12 continue } @@ -302,7 +302,7 @@ jobs: tail -n 20 geckodriver.log >&2 |& awk "{ print \"${LOG_DIAG} \" \$0 }" || true echo -e "${LOG_CICD} ================" echo -e "${LOG_DIAG} ncp.log: " - sudo systemd-run --wait -P --machine=ncp ncp /bin/bash -c "tail -n20 /var/log/ncp.log" |& awk "{ print \"${LOG_DIAG} \" \$0 }" || true + "${CONTAINER_CMD[@]}" -q ncp /bin/bash -c "tail -n20 /var/log/ncp.log" |& awk "{ print \"${LOG_DIAG} \" \$0 }" || true sleep 12 continue } diff --git a/etc/library.sh b/etc/library.sh index 4eab4c201..ed90dab01 100644 --- a/etc/library.sh +++ b/etc/library.sh @@ -159,11 +159,11 @@ function set-nc-domain() ncc config:system:set trusted_proxies 13 --value="${domain}" ncc config:system:set trusted_proxies 14 --value="$(dig +short "${domain}")" sleep 5 # this seems to be required in the VM for some reason. We get `http2 error: protocol error` after ncp-upgrade-nc - for try in {1..3} + for try in {1..5} do - echo "Setup notify_push (attempt ${try}/3)" + echo "Setup notify_push (attempt ${try}/5)" ncc notify_push:setup "${url}/push" - sleep 5 + sleep 10 done fi } From 56e1ff45ee6ea57e8f9cd4a0c434b21084faef50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Wed, 18 Jan 2023 22:58:28 +0100 Subject: [PATCH 36/54] opcache.ini.sh: Increase interned_strings_buffer as recommended by NC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- bin/ncp-dist-upgrade | 4 +++- etc/ncp-templates/php/opcache.ini.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/ncp-dist-upgrade b/bin/ncp-dist-upgrade index 3ccc84588..fe6897bd3 100755 --- a/bin/ncp-dist-upgrade +++ b/bin/ncp-dist-upgrade @@ -125,7 +125,9 @@ is_active_app unattended-upgrades && run_app unattended-upgrades || true # mark as successful mv "${new_cfg}" "${old_cfg}" install_template "php/opcache.ini.sh" "/etc/php/${php_ver_new}/mods-available/opcache.ini" --defaults -service "php${php_ver_new}-fpm" restart +service "php${php_ver_new}-fpm" stop +clear_opcache +service "php${php_ver_new}-fpm" start source /usr/local/etc/library.sh # refresh NCPCFG RELEASE PHPVER run_app nc-limits diff --git a/etc/ncp-templates/php/opcache.ini.sh b/etc/ncp-templates/php/opcache.ini.sh index 77121c049..aa482af34 100644 --- a/etc/ncp-templates/php/opcache.ini.sh +++ b/etc/ncp-templates/php/opcache.ini.sh @@ -26,7 +26,7 @@ zend_extension=opcache.so opcache.enable=1 opcache.enable_cli=1 opcache.fast_shutdown=1 -opcache.interned_strings_buffer=8 +opcache.interned_strings_buffer=12 opcache.max_accelerated_files=10000 opcache.memory_consumption=128 opcache.save_comments=1 From 41a7b6b3736462d6cb7eabc085a18b42db261412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Fri, 20 Jan 2023 01:10:05 +0100 Subject: [PATCH 37/54] 010lamp: clear opcache on container startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Dockerfile: Set apache configuration environment variables - library.sh: Only retry setting up notify_push on failure Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- build/docker/Dockerfile | 8 +++++++- build/docker/lamp/010lamp | 1 + etc/library.sh | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index 2d7a6795f..939c08419 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -28,6 +28,12 @@ LABEL maintainer="Ignacio Núñez Hernanz " SHELL ["/bin/bash", "-c"] ENV DOCKERBUILD 1 +ENV APACHE_RUN_USER=www-data +ENV APACHE_RUN_GROUP=www-data +ENV APACHE_LOG_DIR=/var/log/apache2 +ENV APACHE_LOCK_DIR=/var/lock/apache2 +ENV APACHE_PID_FILE=/var/run/apache2.pid +ENV APACHE_RUN_DIR=/var/run/apache2 COPY etc/ncp.cfg etc/library.sh lamp.sh /usr/local/etc/ COPY etc/ncp-templates /usr/local/etc/ncp-templates @@ -147,7 +153,7 @@ COPY etc/ncp-config.d/nc-init.cfg /usr/local/etc/ncp-config.d/nc-init-copy.cfg COPY etc/ncp-config.d/nc-datadir.cfg /usr/local/etc/ncp-config.d/nc-datadir-copy.cfg RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \ -set -e; \ +set -ex; \ # make sure we don't accidentally disable first run wizard rm -f ncp-web/{wizard.cfg,ncp-web.cfg}; \ diff --git a/build/docker/lamp/010lamp b/build/docker/lamp/010lamp index cd02a2159..ea706cce9 100755 --- a/build/docker/lamp/010lamp +++ b/build/docker/lamp/010lamp @@ -26,6 +26,7 @@ if [[ -f /usr/local/bin/ncp-docker-hook ]]; then fi echo "Starting PHP-fpm" +clear_opcache php-fpm"${PHPVER}" echo "Starting Apache" diff --git a/etc/library.sh b/etc/library.sh index ed90dab01..7f04a2f80 100644 --- a/etc/library.sh +++ b/etc/library.sh @@ -162,7 +162,7 @@ function set-nc-domain() for try in {1..5} do echo "Setup notify_push (attempt ${try}/5)" - ncc notify_push:setup "${url}/push" + ncc notify_push:setup "${url}/push" && break sleep 10 done fi From 615b6f1c4df19040629ac10a10d7d410511d1eaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Fri, 20 Jan 2023 01:13:46 +0100 Subject: [PATCH 38/54] build-docker.yml: Disable update test for armhf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/build-docker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 50a93c9e2..36f0c8e58 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -64,6 +64,7 @@ jobs: docker push "thecalcaholic/ncp-internal-${ARCH?}:${{ github.run_id }}-testing" update-test: + if: ${{ inputs.arch != 'armhf' }} needs: - build runs-on: ubuntu-latest From 624b560e0153d4221a4068062fb51a37e08a9da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Fri, 20 Jan 2023 01:25:45 +0100 Subject: [PATCH 39/54] release.yml: Disable 32bit armbian images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/release.yml | 50 ++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1547f51eb..6b013cd37 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -170,18 +170,19 @@ jobs: dry_run: ${{ (!inputs.release && github.event_name == 'workflow_dispatch') || github.ref_type != 'tag' || !(github.ref_protected || startsWith(github.ref, 'refs/tags/v')) }} secrets: inherit - odroidxu4-release: - needs: - - odroidxu4 - - github-release - if: ${{ inputs.sd-images || github.event_name != 'workflow_dispatch' }} - uses: ./.github/workflows/publish-image.yml - with: - git_ref: "${{ inputs.git_ref || github.head_ref || github.ref_name }}" - artifact_id: "${{ needs.odroidxu4.outputs.artifact_name }}" - artifact_file: "${{ needs.odroidxu4.outputs.artifact_file }}" - dry_run: ${{ (!inputs.release && github.event_name == 'workflow_dispatch') || github.ref_type != 'tag' || !(github.ref_protected || startsWith(github.ref, 'refs/tags/v')) }} - secrets: inherit +# TODO: Fix 32bit armbian images +# odroidxu4-release: +# needs: +# - odroidxu4 +# - github-release +# if: ${{ inputs.sd-images || github.event_name != 'workflow_dispatch' }} +# uses: ./.github/workflows/publish-image.yml +# with: +# git_ref: "${{ inputs.git_ref || github.head_ref || github.ref_name }}" +# artifact_id: "${{ needs.odroidxu4.outputs.artifact_name }}" +# artifact_file: "${{ needs.odroidxu4.outputs.artifact_file }}" +# dry_run: ${{ (!inputs.release && github.event_name == 'workflow_dispatch') || github.ref_type != 'tag' || !(github.ref_protected || startsWith(github.ref, 'refs/tags/v')) }} +# secrets: inherit rockpro64-release: needs: - rockpro64 @@ -206,18 +207,19 @@ jobs: artifact_file: "${{ needs.rock64.outputs.artifact_file }}" dry_run: ${{ (!inputs.release && github.event_name == 'workflow_dispatch') || github.ref_type != 'tag' || !(github.ref_protected || startsWith(github.ref, 'refs/tags/v')) }} secrets: inherit - bananapi-release: - needs: - - bananapi - - github-release - if: ${{ inputs.sd-images || github.event_name != 'workflow_dispatch' }} - uses: ./.github/workflows/publish-image.yml - with: - git_ref: "${{ inputs.git_ref || github.head_ref || github.ref_name }}" - artifact_id: "${{ needs.bananapi.outputs.artifact_name }}" - artifact_file: "${{ needs.bananapi.outputs.artifact_file }}" - dry_run: ${{ (!inputs.release && github.event_name == 'workflow_dispatch') || github.ref_type != 'tag' || !(github.ref_protected || startsWith(github.ref, 'refs/tags/v')) }} - secrets: inherit +# TODO: Fix 32bit armbian images +# bananapi-release: +# needs: +# - bananapi +# - github-release +# if: ${{ inputs.sd-images || github.event_name != 'workflow_dispatch' }} +# uses: ./.github/workflows/publish-image.yml +# with: +# git_ref: "${{ inputs.git_ref || github.head_ref || github.ref_name }}" +# artifact_id: "${{ needs.bananapi.outputs.artifact_name }}" +# artifact_file: "${{ needs.bananapi.outputs.artifact_file }}" +# dry_run: ${{ (!inputs.release && github.event_name == 'workflow_dispatch') || github.ref_type != 'tag' || !(github.ref_protected || startsWith(github.ref, 'refs/tags/v')) }} +# secrets: inherit odroidhc4-release: needs: - odroidhc4 From 30fe8c763c6725e25ff88f3a501678cddcbbe409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Fri, 20 Jan 2023 03:55:12 +0100 Subject: [PATCH 40/54] 000ncp: Copy new config files to persistent config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- build/docker/nextcloudpi/000ncp | 1 + 1 file changed, 1 insertion(+) diff --git a/build/docker/nextcloudpi/000ncp b/build/docker/nextcloudpi/000ncp index 6f215a5db..f033b4078 100755 --- a/build/docker/nextcloudpi/000ncp +++ b/build/docker/nextcloudpi/000ncp @@ -3,6 +3,7 @@ source /usr/local/etc/library.sh # INIT NCP CONFIG (first run) +cp -u /usr/local/ncp-config.d/*.cfg /data/ncp/ persistent_cfg /usr/local/etc/ncp-config.d /data/ncp persistent_cfg /etc/letsencrypt # persist SSL certificates persistent_cfg /etc/shadow # persist ncp-web password From dea9d5df4e195c8c92e798f68605c39113a4d56a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Fri, 20 Jan 2023 03:55:44 +0100 Subject: [PATCH 41/54] ncp.cfg, nc-nextcloud.cfg: Update NC to 25.0.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- etc/ncp-config.d/nc-nextcloud.cfg | 2 +- etc/ncp.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/ncp-config.d/nc-nextcloud.cfg b/etc/ncp-config.d/nc-nextcloud.cfg index 0fcfd7d42..43ff481dc 100644 --- a/etc/ncp-config.d/nc-nextcloud.cfg +++ b/etc/ncp-config.d/nc-nextcloud.cfg @@ -9,7 +9,7 @@ { "id": "VER", "name": "Version", - "value": "25.0.2" + "value": "25.0.3" }, { "id": "MAXFILESIZE", diff --git a/etc/ncp.cfg b/etc/ncp.cfg index 95fa59d50..95241ac6f 100644 --- a/etc/ncp.cfg +++ b/etc/ncp.cfg @@ -1,5 +1,5 @@ { - "nextcloud_version": "25.0.2", + "nextcloud_version": "25.0.3", "php_version": "8.1", "release": "bullseye" } From d2ba6498d6ae4436472fbb7d09cdbb3070647e5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Fri, 20 Jan 2023 03:56:09 +0100 Subject: [PATCH 42/54] release.yml: Disable broken image builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/build-docker.yml | 4 +++ .github/workflows/release.yml | 58 +++++++++++++++--------------- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 36f0c8e58..003f6e21d 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -64,6 +64,10 @@ jobs: docker push "thecalcaholic/ncp-internal-${ARCH?}:${{ github.run_id }}-testing" update-test: + # TODO: Fix update-test for armhf + # The issues are originating in a seemingly bug in apache2 that only occurs in the GH action and only + # if a docker volume or directory is mounted to /data. + # In this configuration, apache will serve the default placeholder page instead of the sites configured in ncp. if: ${{ inputs.arch != 'armhf' }} needs: - build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6b013cd37..2c4f0d5bd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -87,8 +87,10 @@ jobs: board_name: RaspberryPi secrets: inherit + # TODO: Fix 32bit armbian images odroidxu4: - if: ${{ inputs.sd-images || github.event_name != 'workflow_dispatch' }} + # if: ${{ inputs.sd-images || github.event_name != 'workflow_dispatch' }} + if: ${{ false }} uses: ./.github/workflows/build-sd-images.yml with: git_ref: "${{ inputs.git_ref || github.head_ref || github.ref_name }}" @@ -111,8 +113,10 @@ jobs: board_id: rock64 board_name: Rock64 secrets: inherit + # TODO: Fix 32bit armbian images bananapi: - if: ${{ inputs.sd-images || github.event_name != 'workflow_dispatch' }} + #if: ${{ inputs.sd-images || github.event_name != 'workflow_dispatch' }} + if: ${{ false }} uses: ./.github/workflows/build-sd-images.yml with: git_ref: "${{ inputs.git_ref || github.head_ref || github.ref_name }}" @@ -170,19 +174,18 @@ jobs: dry_run: ${{ (!inputs.release && github.event_name == 'workflow_dispatch') || github.ref_type != 'tag' || !(github.ref_protected || startsWith(github.ref, 'refs/tags/v')) }} secrets: inherit -# TODO: Fix 32bit armbian images -# odroidxu4-release: -# needs: -# - odroidxu4 -# - github-release -# if: ${{ inputs.sd-images || github.event_name != 'workflow_dispatch' }} -# uses: ./.github/workflows/publish-image.yml -# with: -# git_ref: "${{ inputs.git_ref || github.head_ref || github.ref_name }}" -# artifact_id: "${{ needs.odroidxu4.outputs.artifact_name }}" -# artifact_file: "${{ needs.odroidxu4.outputs.artifact_file }}" -# dry_run: ${{ (!inputs.release && github.event_name == 'workflow_dispatch') || github.ref_type != 'tag' || !(github.ref_protected || startsWith(github.ref, 'refs/tags/v')) }} -# secrets: inherit + odroidxu4-release: + needs: + - odroidxu4 + - github-release + if: ${{ inputs.sd-images || github.event_name != 'workflow_dispatch' }} + uses: ./.github/workflows/publish-image.yml + with: + git_ref: "${{ inputs.git_ref || github.head_ref || github.ref_name }}" + artifact_id: "${{ needs.odroidxu4.outputs.artifact_name }}" + artifact_file: "${{ needs.odroidxu4.outputs.artifact_file }}" + dry_run: ${{ (!inputs.release && github.event_name == 'workflow_dispatch') || github.ref_type != 'tag' || !(github.ref_protected || startsWith(github.ref, 'refs/tags/v')) }} + secrets: inherit rockpro64-release: needs: - rockpro64 @@ -207,19 +210,18 @@ jobs: artifact_file: "${{ needs.rock64.outputs.artifact_file }}" dry_run: ${{ (!inputs.release && github.event_name == 'workflow_dispatch') || github.ref_type != 'tag' || !(github.ref_protected || startsWith(github.ref, 'refs/tags/v')) }} secrets: inherit -# TODO: Fix 32bit armbian images -# bananapi-release: -# needs: -# - bananapi -# - github-release -# if: ${{ inputs.sd-images || github.event_name != 'workflow_dispatch' }} -# uses: ./.github/workflows/publish-image.yml -# with: -# git_ref: "${{ inputs.git_ref || github.head_ref || github.ref_name }}" -# artifact_id: "${{ needs.bananapi.outputs.artifact_name }}" -# artifact_file: "${{ needs.bananapi.outputs.artifact_file }}" -# dry_run: ${{ (!inputs.release && github.event_name == 'workflow_dispatch') || github.ref_type != 'tag' || !(github.ref_protected || startsWith(github.ref, 'refs/tags/v')) }} -# secrets: inherit + bananapi-release: + needs: + - bananapi + - github-release + if: ${{ inputs.sd-images || github.event_name != 'workflow_dispatch' }} + uses: ./.github/workflows/publish-image.yml + with: + git_ref: "${{ inputs.git_ref || github.head_ref || github.ref_name }}" + artifact_id: "${{ needs.bananapi.outputs.artifact_name }}" + artifact_file: "${{ needs.bananapi.outputs.artifact_file }}" + dry_run: ${{ (!inputs.release && github.event_name == 'workflow_dispatch') || github.ref_type != 'tag' || !(github.ref_protected || startsWith(github.ref, 'refs/tags/v')) }} + secrets: inherit odroidhc4-release: needs: - odroidhc4 From a5f777ae86ab4a4ee9922ffa4f59020a8f901034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Fri, 20 Jan 2023 14:43:54 +0100 Subject: [PATCH 43/54] 000ncp: Fix copying of new config files to persistent config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- build/docker/nextcloudpi/000ncp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/docker/nextcloudpi/000ncp b/build/docker/nextcloudpi/000ncp index f033b4078..0a5455e6d 100755 --- a/build/docker/nextcloudpi/000ncp +++ b/build/docker/nextcloudpi/000ncp @@ -3,7 +3,10 @@ source /usr/local/etc/library.sh # INIT NCP CONFIG (first run) -cp -u /usr/local/ncp-config.d/*.cfg /data/ncp/ +[[ "$1" == "start" ]] && { + echo "Install default configurations for new ncp apps" + rsync --ignore-existing -a --out-format="%n" /usr/local/etc/ncp-config.d/*.cfg /data/ncp/ | awk '{ print " > " $0 }' +} persistent_cfg /usr/local/etc/ncp-config.d /data/ncp persistent_cfg /etc/letsencrypt # persist SSL certificates persistent_cfg /etc/shadow # persist ncp-web password From f121aac809d0cc8917cb26b11b9d55687a4987f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Fri, 20 Jan 2023 19:05:41 +0100 Subject: [PATCH 44/54] library.sh: Simplify clear_opcache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- bin/ncp-dist-upgrade | 2 -- bin/ncp-update-nc | 2 -- bin/ncp/CONFIG/nc-nextcloud.sh | 1 - bin/ncp/TOOLS/clear-php-opcache.sh | 5 +---- build/docker/Dockerfile | 13 ++++++++++++- build/docker/debian-ncp/run-parts.sh | 9 --------- build/docker/lamp/010lamp | 1 - build/docker/nextcloudpi/000ncp | 14 ++++++++------ etc/library.sh | 1 + 9 files changed, 22 insertions(+), 26 deletions(-) diff --git a/bin/ncp-dist-upgrade b/bin/ncp-dist-upgrade index fe6897bd3..d63dee59f 100755 --- a/bin/ncp-dist-upgrade +++ b/bin/ncp-dist-upgrade @@ -125,9 +125,7 @@ is_active_app unattended-upgrades && run_app unattended-upgrades || true # mark as successful mv "${new_cfg}" "${old_cfg}" install_template "php/opcache.ini.sh" "/etc/php/${php_ver_new}/mods-available/opcache.ini" --defaults -service "php${php_ver_new}-fpm" stop clear_opcache -service "php${php_ver_new}-fpm" start source /usr/local/etc/library.sh # refresh NCPCFG RELEASE PHPVER run_app nc-limits diff --git a/bin/ncp-update-nc b/bin/ncp-update-nc index ddd1ac2ee..2e6883986 100755 --- a/bin/ncp-update-nc +++ b/bin/ncp-update-nc @@ -185,9 +185,7 @@ find nextcloud/ -type d -exec chmod 750 {} \; find nextcloud/ -type f -exec chmod 640 {} \; # Clear PHP opcache -service "php${PHPVER}-fpm" stop clear_opcache -service "php${PHPVER}-fpm" start # upgrade #################### diff --git a/bin/ncp/CONFIG/nc-nextcloud.sh b/bin/ncp/CONFIG/nc-nextcloud.sh index e131ac919..b7a89a34d 100644 --- a/bin/ncp/CONFIG/nc-nextcloud.sh +++ b/bin/ncp/CONFIG/nc-nextcloud.sh @@ -78,7 +78,6 @@ EOF service redis-server restart update-rc.d redis-server enable clear_opcache - service php${PHPVER}-fpm restart # service to randomize passwords on first boot mkdir -p /usr/lib/systemd/system diff --git a/bin/ncp/TOOLS/clear-php-opcache.sh b/bin/ncp/TOOLS/clear-php-opcache.sh index 57a5a5e6d..8f3e0a62a 100644 --- a/bin/ncp/TOOLS/clear-php-opcache.sh +++ b/bin/ncp/TOOLS/clear-php-opcache.sh @@ -11,11 +11,8 @@ configure() { - echo "Stopping php..." - service "php${PHPVER}-fpm" stop + echo "Clearing opcache..." clear_opcache - echo "Starting php..." - service "php${PHPVER}-fpm" start } install() { :; } diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index 939c08419..7c1da624e 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -170,7 +170,9 @@ apt-get install --no-install-recommends -y wget ca-certificates; \ # install nextcloudpiset_app_param nc-datadir.sh DATADIR '/data-ro/ncdata' \ source /usr/local/etc/library.sh; \ cd /tmp/ncp-build/; \ -install_app ncp.sh; \ +branch=master; \ +[[ "$ncp_ver" == "v0.0.0" ]] || branch="$ncp_ver"; \ +BRANCH="$branch" install_app ncp.sh; \ mv /usr/local/etc/ncp-config.d/nc-init-copy.cfg /usr/local/etc/ncp-config.d/nc-init.cfg; \ run_app_unsafe bin/ncp/CONFIG/nc-init.sh; \ @@ -185,13 +187,22 @@ rm /usr/local/etc/ncp-config.d/nc-datadir.cfg; \ sed -i 's|data-ro|data|' /data-ro/nextcloud/config/config.php; \ # fix default paths +echo "Update data-ro"; \ sed -i 's|/media/USBdrive|/data/backups|' /usr/local/etc/ncp-config.d/nc-backup.cfg; \ sed -i 's|/media/USBdrive|/data/backups|' /usr/local/etc/ncp-config.d/nc-backup-auto.cfg; \ sed -i 's|/data-ro|/data|' /etc/mysql/mariadb.conf.d/90-ncp.cnf; \ +echo "DEBUGGING:"; \ +cat /etc/mysql/mariadb.conf.d/90-ncp.cnf; \ +ls -l /usr/local/bin/; \ + # cleanup all NCP extras run_app_unsafe post-inst.sh; \ +echo "DEBUGGING:"; \ +cat /etc/mysql/mariadb.conf.d/90-ncp.cnf; \ +ls -l /usr/local/bin/; \ + # specific cleanup cd /; rm -r /tmp/ncp-build; \ rm /usr/local/etc/ncp-config.d/nc-init.cfg; \ diff --git a/build/docker/debian-ncp/run-parts.sh b/build/docker/debian-ncp/run-parts.sh index db5a9f434..bbf8c2246 100755 --- a/build/docker/debian-ncp/run-parts.sh +++ b/build/docker/debian-ncp/run-parts.sh @@ -9,15 +9,6 @@ cleanup() exit } -grep '/data-ro' /etc/mysql/mariadb.conf.d/90-ncp.cnf > /dev/null 2>&1 && { - echo "WARNING: Looks like you have been affected by a critical bug in NCP that can cause data loss. We're trying" \ - "to fix this now, but if you encounter any issues, please check" \ - "https://github.com/nextcloud/nextcloudpi/issues/1577#issuecomment-1260830341" \ - "It is likely that you will have to restore a backup" - chown -R mysql:mysql /data/database || true -} -sed -i 's|/data-ro|/data|' "/etc/mysql/mariadb.conf.d/90-ncp.cnf" || true - trap cleanup SIGTERM # if an empty volume is mounted to /data, pre-populate it diff --git a/build/docker/lamp/010lamp b/build/docker/lamp/010lamp index ea706cce9..cd02a2159 100755 --- a/build/docker/lamp/010lamp +++ b/build/docker/lamp/010lamp @@ -26,7 +26,6 @@ if [[ -f /usr/local/bin/ncp-docker-hook ]]; then fi echo "Starting PHP-fpm" -clear_opcache php-fpm"${PHPVER}" echo "Starting Apache" diff --git a/build/docker/nextcloudpi/000ncp b/build/docker/nextcloudpi/000ncp index 0a5455e6d..879c6aaa7 100755 --- a/build/docker/nextcloudpi/000ncp +++ b/build/docker/nextcloudpi/000ncp @@ -3,7 +3,7 @@ source /usr/local/etc/library.sh # INIT NCP CONFIG (first run) -[[ "$1" == "start" ]] && { +[[ "$1" == "start" ]] && [[ -d /data/ncp ]] && { echo "Install default configurations for new ncp apps" rsync --ignore-existing -a --out-format="%n" /usr/local/etc/ncp-config.d/*.cfg /data/ncp/ | awk '{ print " > " $0 }' } @@ -25,11 +25,13 @@ persistent_cfg /etc/cron.weekly } persistent_cfg /usr/local/bin /data/bin -install_template "php/opcache.ini.sh" "/etc/php/${PHPVER}/mods-available/opcache.ini" -install_template "php/90-ncp.ini.sh" "/etc/php/${PHPVER}/fpm/conf.d/90-ncp.ini" -install_template "php/pool.d.www.conf.sh" "/etc/php/${PHPVER}/fpm/pool.d/www.conf" -#install_template "mysql/91-ncp.cnf.sh" "/etc/mysql/mariadb.conf.d/91-ncp.cnf" -install_template "ncp-metrics.cfg.sh" "/usr/local/etc/ncp-metrics.cfg" +[[ "$1" == "start" ]] && { + install_template "php/opcache.ini.sh" "/etc/php/${PHPVER}/mods-available/opcache.ini" + install_template "php/90-ncp.ini.sh" "/etc/php/${PHPVER}/fpm/conf.d/90-ncp.ini" + install_template "php/pool.d.www.conf.sh" "/etc/php/${PHPVER}/fpm/pool.d/www.conf" + #install_template "mysql/91-ncp.cnf.sh" "/etc/mysql/mariadb.conf.d/91-ncp.cnf" + install_template "ncp-metrics.cfg.sh" "/usr/local/etc/ncp-metrics.cfg" +} touch /var/log/ncp.log tail -f -n0 "/var/log/ncp.log" & diff --git a/etc/library.sh b/etc/library.sh index 7f04a2f80..cc330404c 100644 --- a/etc/library.sh +++ b/etc/library.sh @@ -604,6 +604,7 @@ function clear_opcache() { rm -rf "${data_dir:-/var/www/data}/.opcache"/* echo "Done." } + service php${PHPVER}-fpm reload } # License From b9acc8a0d79340e5a8ab3f539e49da7ff8c7baf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Fri, 20 Jan 2023 19:53:34 +0100 Subject: [PATCH 45/54] Dockerfile: Disable branch pinning as it has no effect during build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- bin/ncp-update | 15 +++++++++------ build/docker/Dockerfile | 4 +--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/bin/ncp-update b/bin/ncp-update index b6f7a333f..25753417f 100755 --- a/bin/ncp-update +++ b/bin/ncp-update @@ -29,14 +29,16 @@ fi } # shellcheck disable=SC2164 - [[ -f /.ncp-image ]] || cd "$TMPDIR" # update locally during build + [[ -f /.ncp-image ]] || { + cd "$TMPDIR" # update locally during build - [[ -z "$2" ]] || { - git fetch origin "$2" || { - echo "Error: Could not fetch $2" - exit 1 + [[ -z "$2" ]] || { + git fetch origin "$2" || { + echo "Error: Could not fetch $2" + exit 1 + } + git checkout FETCH_HEAD } - git checkout FETCH_HEAD } echo -e "Performing updates" @@ -61,4 +63,5 @@ fi echo -e "NextCloudPi updated to version $VER" exit 0 + } # force to read the whole thing into memory, as its contents might change in update.sh diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index 7c1da624e..a0e1b3766 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -170,9 +170,7 @@ apt-get install --no-install-recommends -y wget ca-certificates; \ # install nextcloudpiset_app_param nc-datadir.sh DATADIR '/data-ro/ncdata' \ source /usr/local/etc/library.sh; \ cd /tmp/ncp-build/; \ -branch=master; \ -[[ "$ncp_ver" == "v0.0.0" ]] || branch="$ncp_ver"; \ -BRANCH="$branch" install_app ncp.sh; \ +install_app ncp.sh; \ mv /usr/local/etc/ncp-config.d/nc-init-copy.cfg /usr/local/etc/ncp-config.d/nc-init.cfg; \ run_app_unsafe bin/ncp/CONFIG/nc-init.sh; \ From d5fcc40bab5996a710ab4f54acf9bde682a5d1fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Sat, 21 Jan 2023 02:28:30 +0100 Subject: [PATCH 46/54] build-sd-images.yml: Fix aborted tests before retries are reached MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/build-sd-images.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-sd-images.yml b/.github/workflows/build-sd-images.yml index 3e93cac18..6a6c35f7f 100644 --- a/.github/workflows/build-sd-images.yml +++ b/.github/workflows/build-sd-images.yml @@ -172,7 +172,7 @@ jobs: path: output - name: Prepare test run: | - set -ex + set -x mv output/${ARTIFACT_FILE?} ncp.img sudo apt-get install -y systemd-container sudo pip install selenium @@ -224,10 +224,10 @@ jobs: redis_pw="$("${CONTAINER_CMD[@]}" bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"password'")" \ && redis_socket="$("${CONTAINER_CMD[@]}" bash -c ". /usr/local/etc/library.sh; get_nc_config_value 'redis\"][\"host'")" \ || log_err $? "Error retrieving redis credentials" || true - if { [[ "$("${CONTAINER_CMD[@]}" ncc maintenance:mode)" =~ .*disabled.* ]] || log_err $? "Maintenance mode is enabled or could not be retrieved"; } \ - && { "${CONTAINER_CMD[@]}" ncc status || log_err $? "ncc status check failed"; } \ - && { "${CONTAINER_CMD[@]}" redis-cli -s "$redis_socket" -a "$redis_pw" set redisready yes || log_err $? "Failed to set redis variable"; } \ - && { "${CONTAINER_CMD[@]}" redis-cli -s "$redis_socket" -a "$redis_pw" get redisready || log_err $? "Failed to read redis variable"; } + if { "${CONTAINER_CMD[@]}" -q ncc status |& awk "{ print \"${LOG_DIAG} \" \$0 }" || log_err $? "ncc status check failed"; } \ + && { [[ "$("${CONTAINER_CMD[@]}" ncc maintenance:mode)" =~ .*disabled.* ]] || log_err $? "Maintenance mode is enabled or could not be retrieved"; } \ + && { "${CONTAINER_CMD[@]}" redis-cli -s "$redis_socket" -a "$redis_pw" set redisready yes |& awk "{ print \"${LOG_DIAG} \" \$0 }" || log_err $? "Failed to set redis variable"; } \ + && { "${CONTAINER_CMD[@]}" redis-cli -s "$redis_socket" -a "$redis_pw" get redisready |& awk "{ print \"${LOG_DIAG} \" \$0 }" || log_err $? "Failed to read redis variable"; } then echo -e "${LOG_CICD} Startup successful" success=true @@ -248,6 +248,7 @@ jobs: } set -x + set +e success=false for attempt in {1..5} @@ -257,11 +258,11 @@ jobs: [[ ${PIPESTATUS[0]} -eq 0 ]] || { echo -e "${LOG_CICD} Activation test failed!" echo -e "${LOG_DIAG} Geckodriver logs:" - tail -n 20 geckodriver.log >&2 |& awk "{ print \"${LOG_DIAG} \" \$0 }" + tail -n 20 geckodriver.log >&2 |& awk "{ print \"${LOG_DIAG} \" \$0 }" || true echo "================" echo -e "${LOG_DIAG} mysql: " "${CONTAINER_CMD[@]}" -q ncp-diag |& awk "{ print \"${LOG_DIAG} \" \$0 }" || true - "${CONTAINER_CMD[@]}" -q systemctl status mysql |& awk "{ print \"${LOG_DIAG} \" \$0 }" + "${CONTAINER_CMD[@]}" -q systemctl status mysql |& awk "{ print \"${LOG_DIAG} \" \$0 }" || true sleep 12 continue } From 39c915dc6752887639fd0a057228f275c434c3d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Sat, 21 Jan 2023 14:59:43 +0100 Subject: [PATCH 47/54] library.sh: Simplify clear_opcache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- bin/ncp-restore | 7 ++++++- etc/library.sh | 8 -------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/bin/ncp-restore b/bin/ncp-restore index aea4c064d..78c00ea02 100755 --- a/bin/ncp-restore +++ b/bin/ncp-restore @@ -38,7 +38,10 @@ free=$( df "$TMPDIR" | tail -1 | awk '{ print $4 }' ) # EXTRACT FILES echo "extracting backup file $BACKUPFILE..." -tar $compress_arg -xf "$BACKUPFILE" -C "$TMPDIR" || exit 1 +tar $compress_arg -xf "$BACKUPFILE" -C "$TMPDIR" || { + echo "An error occurred. Abort" + exit 1 +} ## SANITY CHECKS [[ -d "$TMPDIR"/nextcloud ]] && [[ -f "$( ls "$TMPDIR"/nextcloud-sqlbkp_*.bak 2>/dev/null )" ]] || { @@ -185,3 +188,5 @@ ncc files:scan-app-data clear_opcache bash -c "sleep 3; service php${PHPVER}-fpm restart" &>/dev/null & } + +} diff --git a/etc/library.sh b/etc/library.sh index cc330404c..8e4de6bdf 100644 --- a/etc/library.sh +++ b/etc/library.sh @@ -596,14 +596,6 @@ function get_nc_config_value() { } function clear_opcache() { - # shellcheck disable=SC2155 - local data_dir="$(get_nc_config_value datadirectory)" - ! [[ -d "${data_dir:-/var/www/data}/.opcache" ]] || { - echo "Clearing opcache..." - echo "This can take some time. Please don't interrupt the process/close your browser tab." - rm -rf "${data_dir:-/var/www/data}/.opcache"/* - echo "Done." - } service php${PHPVER}-fpm reload } From e8352bd10efcfe101f5185d2162e50b203c71b82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Sat, 21 Jan 2023 15:53:58 +0100 Subject: [PATCH 48/54] ncp-restore: Make sure to clear opcache before executing ncc commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- bin/ncp-restore | 3 ++- etc/ncp-templates/php/opcache.ini.sh | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/ncp-restore b/bin/ncp-restore index 78c00ea02..41987b703 100755 --- a/bin/ncp-restore +++ b/bin/ncp-restore @@ -106,8 +106,9 @@ fi cd "$NCDIR" -### INCLUDEDATA=yes situation +clear_opcache +### INCLUDEDATA=yes situation NUMFILES=2 if [[ $( ls "$TMPDIR" | wc -l ) -eq $NUMFILES ]]; then diff --git a/etc/ncp-templates/php/opcache.ini.sh b/etc/ncp-templates/php/opcache.ini.sh index aa482af34..d991ff35a 100644 --- a/etc/ncp-templates/php/opcache.ini.sh +++ b/etc/ncp-templates/php/opcache.ini.sh @@ -31,6 +31,6 @@ opcache.max_accelerated_files=10000 opcache.memory_consumption=128 opcache.save_comments=1 opcache.revalidate_freq=1 -opcache.file_cache=${TMP_DIR}; -opcache.jit=function; +opcache.file_cache=${TMP_DIR} +opcache.jit=function EOF From cfc4d5730698834f92ac63dab19a1a28cd52a837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Sat, 21 Jan 2023 15:54:41 +0100 Subject: [PATCH 49/54] opcache.ini.sh: Disable opcache for cli MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- etc/ncp-templates/php/opcache.ini.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/ncp-templates/php/opcache.ini.sh b/etc/ncp-templates/php/opcache.ini.sh index d991ff35a..132c8d822 100644 --- a/etc/ncp-templates/php/opcache.ini.sh +++ b/etc/ncp-templates/php/opcache.ini.sh @@ -24,7 +24,7 @@ mkdir -p "$TMP_DIR" cat < Date: Sat, 21 Jan 2023 16:02:48 +0100 Subject: [PATCH 50/54] Revert "library.sh: Simplify clear_opcache" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 59c2297c808a44344a22966369f4b26166779d4d. Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- bin/ncp-restore | 7 +------ etc/library.sh | 8 ++++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/ncp-restore b/bin/ncp-restore index 41987b703..228afc6d8 100755 --- a/bin/ncp-restore +++ b/bin/ncp-restore @@ -38,10 +38,7 @@ free=$( df "$TMPDIR" | tail -1 | awk '{ print $4 }' ) # EXTRACT FILES echo "extracting backup file $BACKUPFILE..." -tar $compress_arg -xf "$BACKUPFILE" -C "$TMPDIR" || { - echo "An error occurred. Abort" - exit 1 -} +tar $compress_arg -xf "$BACKUPFILE" -C "$TMPDIR" || exit 1 ## SANITY CHECKS [[ -d "$TMPDIR"/nextcloud ]] && [[ -f "$( ls "$TMPDIR"/nextcloud-sqlbkp_*.bak 2>/dev/null )" ]] || { @@ -189,5 +186,3 @@ ncc files:scan-app-data clear_opcache bash -c "sleep 3; service php${PHPVER}-fpm restart" &>/dev/null & } - -} diff --git a/etc/library.sh b/etc/library.sh index 8e4de6bdf..cc330404c 100644 --- a/etc/library.sh +++ b/etc/library.sh @@ -596,6 +596,14 @@ function get_nc_config_value() { } function clear_opcache() { + # shellcheck disable=SC2155 + local data_dir="$(get_nc_config_value datadirectory)" + ! [[ -d "${data_dir:-/var/www/data}/.opcache" ]] || { + echo "Clearing opcache..." + echo "This can take some time. Please don't interrupt the process/close your browser tab." + rm -rf "${data_dir:-/var/www/data}/.opcache"/* + echo "Done." + } service php${PHPVER}-fpm reload } From 88ec3a8720fec40f6760a2f859d153023a34ed67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Sat, 21 Jan 2023 16:06:10 +0100 Subject: [PATCH 51/54] library.sh: Fix opcache path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- etc/library.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/library.sh b/etc/library.sh index cc330404c..e0676ccc7 100644 --- a/etc/library.sh +++ b/etc/library.sh @@ -598,10 +598,10 @@ function get_nc_config_value() { function clear_opcache() { # shellcheck disable=SC2155 local data_dir="$(get_nc_config_value datadirectory)" - ! [[ -d "${data_dir:-/var/www/data}/.opcache" ]] || { + ! [[ -d "${data_dir:-/var/www/nextcloud/data}/.opcache" ]] || { echo "Clearing opcache..." echo "This can take some time. Please don't interrupt the process/close your browser tab." - rm -rf "${data_dir:-/var/www/data}/.opcache"/* + rm -rf "${data_dir:-/var/www/nextcloud/data}/.opcache"/* "${data_dir:-/var/www/nextcloud/data}/.opcache"/.[!.]* echo "Done." } service php${PHPVER}-fpm reload From 362c8288f5f1dbd894b6a146b9dddfcb4158a560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Sat, 21 Jan 2023 20:07:09 +0100 Subject: [PATCH 52/54] Remove unnecessary clear_opcache calls, as opcache is now disabled for cli MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- bin/ncp-restore | 5 +---- bin/ncp-update-nc | 6 ++---- bin/ncp/CONFIG/nc-limits.sh | 3 +-- bin/ncp/TOOLS/clear-php-opcache.sh | 3 ++- updates/1.50.0.sh | 5 +---- updates/1.50.1.sh | 3 +-- 6 files changed, 8 insertions(+), 17 deletions(-) diff --git a/bin/ncp-restore b/bin/ncp-restore index 228afc6d8..e22bd703f 100755 --- a/bin/ncp-restore +++ b/bin/ncp-restore @@ -103,8 +103,6 @@ fi cd "$NCDIR" -clear_opcache - ### INCLUDEDATA=yes situation NUMFILES=2 if [[ $( ls "$TMPDIR" | wc -l ) -eq $NUMFILES ]]; then @@ -183,6 +181,5 @@ ncc files:scan-app-data # restart PHP if needed [[ "$NEED_RESTART" == "1" ]] && { - clear_opcache - bash -c "sleep 3; service php${PHPVER}-fpm restart" &>/dev/null & + bash -c "sleep 5; source /usr/local/etc/library.sh; clear_opcache; service php${PHPVER}-fpm restart" &>/dev/null & } diff --git a/bin/ncp-update-nc b/bin/ncp-update-nc index 2e6883986..7ae4a1d73 100755 --- a/bin/ncp-update-nc +++ b/bin/ncp-update-nc @@ -184,9 +184,6 @@ chown -R www-data:www-data nextcloud find nextcloud/ -type d -exec chmod 750 {} \; find nextcloud/ -type f -exec chmod 640 {} \; -# Clear PHP opcache -clear_opcache - # upgrade #################### echo "Upgrade..." @@ -250,7 +247,6 @@ then apt-get install -y --no-install-recommends -t "$RELEASE" "${PHP_PACKAGES_OLD[@]}" set_ncpcfg "php_version" "${PHPVER_OLD}" install_template "php/opcache.ini.sh" "/etc/php/${PHPVER_NEW}/mods-available/opcache.ini" - clear_opcache run_app nc-limits a2enconf "php${PHPVER_OLD}-fpm" service "php${PHPVER_OLD}-fpm" start @@ -308,3 +304,5 @@ mv "$BKP" "$DATADIR"/ncp-update-backups chown -R www-data:www-data "$DATADIR"/ncp-update-backups BKP="$DATADIR"/ncp-update-backups/"$( basename "$BKP" )" echo "Backup stored at $BKP" + +bash -c "sleep 5; source /usr/local/etc/library.sh; clear_opcache;" &>/dev/null & diff --git a/bin/ncp/CONFIG/nc-limits.sh b/bin/ncp/CONFIG/nc-limits.sh index bcbe63ea4..3ce229b46 100644 --- a/bin/ncp/CONFIG/nc-limits.sh +++ b/bin/ncp/CONFIG/nc-limits.sh @@ -80,8 +80,7 @@ configure() # RESTART PHP [[ "$require_fpm_restart" == "true" ]] && { - clear_opcache - bash -c "sleep 3; service php${PHPVER}-fpm restart" &>/dev/null & + bash -c "sleep 3; source /usr/local/etc/library.sh; clear_opcache; service php${PHPVER}-fpm restart" &>/dev/null & } # redis max memory diff --git a/bin/ncp/TOOLS/clear-php-opcache.sh b/bin/ncp/TOOLS/clear-php-opcache.sh index 8f3e0a62a..7aed7bce5 100644 --- a/bin/ncp/TOOLS/clear-php-opcache.sh +++ b/bin/ncp/TOOLS/clear-php-opcache.sh @@ -12,7 +12,8 @@ configure() { echo "Clearing opcache..." - clear_opcache + bash -c "sleep 5; source /usr/local/etc/library.sh; clear_opcache;" &>/dev/null & + echo "Done." } install() { :; } diff --git a/updates/1.50.0.sh b/updates/1.50.0.sh index 9aa6cd78a..5799fe139 100644 --- a/updates/1.50.0.sh +++ b/updates/1.50.0.sh @@ -2,8 +2,5 @@ set -e export NCPCFG=/usr/local/etc/ncp.cfg -source /usr/local/etc/library.sh - -clear_opcache -bash -c "sleep 6; service php${PHPVER}-fpm restart" &>/dev/null & +bash -c "sleep 6; source /usr/local/etc/library.sh; clear_opcache" &>/dev/null & diff --git a/updates/1.50.1.sh b/updates/1.50.1.sh index 645f184ab..d8ef38371 100644 --- a/updates/1.50.1.sh +++ b/updates/1.50.1.sh @@ -6,5 +6,4 @@ source /usr/local/etc/library.sh install_template systemd/notify_push.service.sh /etc/systemd/system/notify_push.service -clear_opcache -bash -c "sleep 6; service php${PHPVER}-fpm restart" &>/dev/null & +bash -c "sleep 6; source /usr/local/etc/library.sh; clear_opcache; service php${PHPVER}-fpm reload" &>/dev/null & From 33af0ed554e57e81b225e18bcd7453c9f2abc1f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Sat, 21 Jan 2023 20:09:24 +0100 Subject: [PATCH 53/54] 1.51.0.sh: Make sure, Changes to opcache.ini are in effect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- updates/1.51.0.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/updates/1.51.0.sh b/updates/1.51.0.sh index 165919af8..79736c6a9 100644 --- a/updates/1.51.0.sh +++ b/updates/1.51.0.sh @@ -10,7 +10,6 @@ dpkg -l | grep -e '^ii' | grep -e 'php-json' > /dev/null && { echo "Updating opcache configuration..." install_template "php/opcache.ini.sh" "/etc/php/${PHPVER}/mods-available/opcache.ini" -run_app "clear-php-opcache" dpkg -l | grep -e '^ii' | grep -e 'php8.2' > /dev/null && { msg="PHP 8.2 packages have been detected on your ncp instance, which could cause issues. If you didn't install them on purpose, please remove them with the following command: sudo apt remove php8.2-*" @@ -18,4 +17,6 @@ dpkg -l | grep -e '^ii' | grep -e 'php8.2' > /dev/null && { notify_admin "NextcloudPi" "$msg" } +bash -c "sleep 5; source /usr/local/etc/library.sh; clear_opcache; service php${PHPVER}-fpm restart;" &> /dev/null & + exit 0 From cdf99f65113c01d12f7ee593a368f9ccb969dcd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Sun, 22 Jan 2023 01:16:24 +0100 Subject: [PATCH 54/54] Update changelog.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- changelog.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/changelog.md b/changelog.md index aead65d47..f4af39ef6 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,28 @@ +## [v1.51.0](https://github.com/nextcloud/nextcloudpi/tree/v1.51.0) (2023-01-22) Update to Nextcloud 25.0.3 and new PortCheck Service + +### Changes + +- Push latest supported version of Nextcloud to 25.0.3 +- Use new PortCheck backend (shoutout to [@ZendaiOwl](https://github.com/ZendaiOwl)) +- Add ncp app for manually clearing the PHP opcache (including file cache) +- + +### Fixes + +- Remove deprecated apt package `php-json` and warn users if `php8.2-*` packages are detected on their instance +- Whenever ncp sends a notification, all NC users in the admin group will now receive it (instead of the first admin user) +- Fix bug in ncp-update-nc that would prevent the backup from being restored on error in some cases +- Adjust PHP opcache config to hopefully avoid one source of opcache JIT segmentation fault errors +- Disable PHP opcache for cli usage (so the segmentation faults don't affect ncp tools and ncc commands) +- (docker) Fix display of nextcloud logs in container output in some cases +- (docker) Config files of new ncp apps are now properly installed + +### Development related + +- (CI/CD) Include NC updates in update integration tests +- (CI/CD) Improve output formatting and robustness for sd image tests +- (CI/CD) Disable image builds and tests that are known to fail for reasons out of our influence + ## [v1.50.5](https://github.com/nextcloud/nextcloudpi/tree/v1.50.5) (2023-01-08) Various fixes and update to NC 24.0.8 ### Changes