From a0480d79fb82521028871a1369b06f183fa9969c Mon Sep 17 00:00:00 2001 From: Sven-Ola Tuecke Date: Mon, 21 Apr 2025 21:21:07 +0200 Subject: [PATCH 01/15] Move DB_PREFIX query to performance hog group --- etc/library.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/etc/library.sh b/etc/library.sh index 2d41465a6..4d4aafb09 100644 --- a/etc/library.sh +++ b/etc/library.sh @@ -14,7 +14,6 @@ export NCDIR=/var/www/nextcloud export ncc=/usr/local/bin/ncc export NCPCFG=${NCPCFG:-etc/ncp.cfg} export ARCH="$(dpkg --print-architecture)" -export DB_PREFIX="$(php -r 'include("/var/www/nextcloud/config/config.php"); echo $CONFIG['"'dbtableprefix'"'];' || echo 'oc_')" [[ "${ARCH}" =~ ^(armhf|arm)$ ]] && ARCH="armv7" [[ "${ARCH}" == "arm64" ]] && ARCH=aarch64 [[ "${ARCH}" == "amd64" ]] && ARCH=x86_64 @@ -58,6 +57,9 @@ RELEASE=$( jq -r .release < "$NCPCFG") # the default repo in bullseye is bullseye-security grep -Eh '^deb ' /etc/apt/sources.list | grep "${RELEASE}-security" > /dev/null && RELEASE="${RELEASE}-security" command -v ncc &>/dev/null && NCVER="$(ncc status 2>/dev/null | grep "version:" | awk '{ print $3 }')" +DB_PREFIX="$(php -r 'include("/var/www/nextcloud/config/config.php"); echo $CONFIG['"'dbtableprefix'"'];' || echo 'oc_')" + +export DB_PREFIX function configure_app() { From 515c77266d131e146871c209c08ebb51c75c43fe Mon Sep 17 00:00:00 2001 From: Sven-Ola Tuecke Date: Fri, 25 Apr 2025 07:36:25 +0200 Subject: [PATCH 02/15] Better DB_PREFIX fallback --- etc/library.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/library.sh b/etc/library.sh index 4d4aafb09..7a85b3a46 100644 --- a/etc/library.sh +++ b/etc/library.sh @@ -57,9 +57,9 @@ RELEASE=$( jq -r .release < "$NCPCFG") # the default repo in bullseye is bullseye-security grep -Eh '^deb ' /etc/apt/sources.list | grep "${RELEASE}-security" > /dev/null && RELEASE="${RELEASE}-security" command -v ncc &>/dev/null && NCVER="$(ncc status 2>/dev/null | grep "version:" | awk '{ print $3 }')" -DB_PREFIX="$(php -r 'include("/var/www/nextcloud/config/config.php"); echo $CONFIG['"'dbtableprefix'"'];' || echo 'oc_')" +DB_PREFIX="$(php -r 'include("/var/www/nextcloud/config/config.php"); echo $CONFIG["dbtableprefix"];')" -export DB_PREFIX +export DB_PREFIX=${DB_PREFIX:-oc_} function configure_app() { From 1be31839a3ce077d184e2703fbe73a03ba7eb860 Mon Sep 17 00:00:00 2001 From: Sven-Ola Tuecke Date: Fri, 25 Apr 2025 07:39:14 +0200 Subject: [PATCH 03/15] Do some caching around performance hogs --- etc/library.sh | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/etc/library.sh b/etc/library.sh index 7a85b3a46..ea2ed02a2 100644 --- a/etc/library.sh +++ b/etc/library.sh @@ -51,13 +51,27 @@ command -v jq &>/dev/null || { apt-get install -y --no-install-recommends jq } -NCLATESTVER=$(jq -r .nextcloud_version < "$NCPCFG") -PHPVER=$( jq -r .php_version < "$NCPCFG") -RELEASE=$( jq -r .release < "$NCPCFG") -# the default repo in bullseye is bullseye-security -grep -Eh '^deb ' /etc/apt/sources.list | grep "${RELEASE}-security" > /dev/null && RELEASE="${RELEASE}-security" -command -v ncc &>/dev/null && NCVER="$(ncc status 2>/dev/null | grep "version:" | awk '{ print $3 }')" -DB_PREFIX="$(php -r 'include("/var/www/nextcloud/config/config.php"); echo $CONFIG["dbtableprefix"];')" +if [ /var/www/ncp-web/library-cache -ot /etc/apt/sources.list ] || \ + [ /var/www/ncp-web/library-cache -ot /var/www/nextcloud/config/config.php ] || + [ /var/www/ncp-web/library-cache -ot "$NCPCFG" ] +then + NCLATESTVER=$(jq -r .nextcloud_version < "$NCPCFG") + PHPVER=$( jq -r .php_version < "$NCPCFG") + RELEASE=$( jq -r .release < "$NCPCFG") + # the default repo in bullseye is bullseye-security + grep -Eh '^deb ' /etc/apt/sources.list | grep "${RELEASE}-security" > /dev/null && RELEASE="${RELEASE}-security" + command -v ncc &>/dev/null && NCVER="$(ncc status 2>/dev/null | grep "version:" | awk '{ print $3 }')" + DB_PREFIX="$(php -r 'include("/var/www/nextcloud/config/config.php"); echo $CONFIG["dbtableprefix"];')" + cat > /var/www/ncp-web/library-cache << EOF +NCLATESTVER="${NCLATESTVER}" +PHPVER="${PHPVER}" +RELEASE="${RELEASE}" +NCVER="${NCVER}" +DB_PREFIX="${DB_PREFIX}" +EOF +else + source /var/www/ncp-web/library-cache +fi export DB_PREFIX=${DB_PREFIX:-oc_} From c5cc11cfa5fb5b50b70e8d9b92384ff0f0576959 Mon Sep 17 00:00:00 2001 From: Sven-Ola Tuecke Date: Fri, 25 Apr 2025 07:40:15 +0200 Subject: [PATCH 04/15] Do not use cache in early install --- etc/library.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/library.sh b/etc/library.sh index ea2ed02a2..3fe648510 100644 --- a/etc/library.sh +++ b/etc/library.sh @@ -62,7 +62,7 @@ then grep -Eh '^deb ' /etc/apt/sources.list | grep "${RELEASE}-security" > /dev/null && RELEASE="${RELEASE}-security" command -v ncc &>/dev/null && NCVER="$(ncc status 2>/dev/null | grep "version:" | awk '{ print $3 }')" DB_PREFIX="$(php -r 'include("/var/www/nextcloud/config/config.php"); echo $CONFIG["dbtableprefix"];')" - cat > /var/www/ncp-web/library-cache << EOF + test -d /var/www/ncp-web && cat > /var/www/ncp-web/library-cache << EOF NCLATESTVER="${NCLATESTVER}" PHPVER="${PHPVER}" RELEASE="${RELEASE}" From c0cfc0ffa68bcdcc04d44273070045477f21c01f Mon Sep 17 00:00:00 2001 From: Sven-Ola Tuecke Date: Fri, 25 Apr 2025 07:45:49 +0200 Subject: [PATCH 05/15] No error on missing config.php during install --- etc/library.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/etc/library.sh b/etc/library.sh index 3fe648510..7daf92911 100644 --- a/etc/library.sh +++ b/etc/library.sh @@ -61,7 +61,9 @@ then # the default repo in bullseye is bullseye-security grep -Eh '^deb ' /etc/apt/sources.list | grep "${RELEASE}-security" > /dev/null && RELEASE="${RELEASE}-security" command -v ncc &>/dev/null && NCVER="$(ncc status 2>/dev/null | grep "version:" | awk '{ print $3 }')" - DB_PREFIX="$(php -r 'include("/var/www/nextcloud/config/config.php"); echo $CONFIG["dbtableprefix"];')" + if [ -s /var/www/nextcloud/config/config.php ];then + DB_PREFIX="$(php -r 'include("/var/www/nextcloud/config/config.php"); echo $CONFIG["dbtableprefix"];')" + fi test -d /var/www/ncp-web && cat > /var/www/ncp-web/library-cache << EOF NCLATESTVER="${NCLATESTVER}" PHPVER="${PHPVER}" From 35429dde543047c09a03a79c27379ed17bb3f579 Mon Sep 17 00:00:00 2001 From: Sven-Ola Tuecke Date: Fri, 11 Jul 2025 12:47:08 +0200 Subject: [PATCH 06/15] Do not use print_sidebar() with $ticks=true. This feature is damn slow and may need lots of optimization. Also, it introduces web UI quirks which should be corrected anyhow. For example: The nc-webui sidebar has a tick slowly acquired by exec nc-webui.sh which queries if the Apache2 NCP cfg is active. This should be queried during install or updates and put in nc-webui.cfg ACTIVE=true instead of slow runtime grok. --- ncp-web/ncp-launcher.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ncp-web/ncp-launcher.php b/ncp-web/ncp-launcher.php index 6a115045d..8eab1c98c 100644 --- a/ncp-web/ncp-launcher.php +++ b/ncp-web/ncp-launcher.php @@ -179,7 +179,7 @@ require( "elements.php" ); // return JSON echo '{ "token": "' . getCSRFToken() . '",'; // Get new token - echo ' "output": ' . json_encode( print_sidebar( $l, true ) ) . ' , '; + echo ' "output": ' . json_encode( print_sidebar( $l, false ) ) . ' , '; echo ' "ret": "0" }'; } From 35a678c8bf07db793cf806b44bc9c1dffa0e9bd7 Mon Sep 17 00:00:00 2001 From: Sven-Ola Tuecke Date: Sun, 13 Jul 2025 16:43:47 +0200 Subject: [PATCH 07/15] Filter out CNAME answers (will give wrong value warning for trusted_proxies) --- etc/library.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/library.sh b/etc/library.sh index 7daf92911..7ed45b9b3 100644 --- a/etc/library.sh +++ b/etc/library.sh @@ -176,8 +176,8 @@ function set-nc-domain() ncc config:system:set trusted_proxies 11 --value="127.0.0.1" ncc config:system:set trusted_proxies 12 --value="::1" # ncc config:system:set trusted_proxies 13 --value="${domain}" - local domain_ip="$(dig +short "${domain}")" - [[ -z "$domain_ip" ]] || ncc config:system:set trusted_proxies 14 --value="$(dig +short "${domain}")" + local domain_ip="$(dig +short "${domain}"|tail -n1)" + [[ -z "$domain_ip" ]] || ncc config:system:set trusted_proxies 14 --value="$(dig +short "${domain}"|tail -n1)" 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..5} do From d6b59b2c42443cc5fc1ffece543a22faba1a351e Mon Sep 17 00:00:00 2001 From: Sven-Ola Tuecke Date: Sun, 13 Jul 2025 17:01:10 +0200 Subject: [PATCH 08/15] Relieve the ncp.log file a bit by removing set -x here and there --- bin/ncp-provisioning.sh | 2 +- bin/ncp/NETWORKING/dnsmasq.sh | 1 - build/build-LXD.sh | 1 - lamp.sh | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/bin/ncp-provisioning.sh b/bin/ncp-provisioning.sh index b4b7400cb..a6d73ebf8 100644 --- a/bin/ncp-provisioning.sh +++ b/bin/ncp-provisioning.sh @@ -3,7 +3,7 @@ # this script runs at startup to provide an unique random passwords for each instance source /usr/local/etc/library.sh -set -x + ## redis provisioning CFG=/var/www/nextcloud/config/config.php diff --git a/bin/ncp/NETWORKING/dnsmasq.sh b/bin/ncp/NETWORKING/dnsmasq.sh index 1427a4b06..48c9894b6 100644 --- a/bin/ncp/NETWORKING/dnsmasq.sh +++ b/bin/ncp/NETWORKING/dnsmasq.sh @@ -11,7 +11,6 @@ install() { - set -x apt-get update apt-get install --no-install-recommends -y dnsmasq sleep 10 diff --git a/build/build-LXD.sh b/build/build-LXD.sh index ee5732eb3..0d56e09a1 100755 --- a/build/build-LXD.sh +++ b/build/build-LXD.sh @@ -63,7 +63,6 @@ LXC_CREATE+=(ncp) # fi #fi -set -x EXEC_ARGS=() [[ -z "$BRANCH" ]] || EXEC_ARGS+=(--env "BRANCH=${BRANCH}") systemd-run --user --scope -p "Delegate=yes" "${LXC_CMD[@]}" start ncp -q || \ diff --git a/lamp.sh b/lamp.sh index 7a1cdf134..7cb28d29a 100644 --- a/lamp.sh +++ b/lamp.sh @@ -24,7 +24,6 @@ export DEBIAN_FRONTEND=noninteractive install() { - set -x # Setup apt repository for php 8 wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg echo "deb https://packages.sury.org/php/ ${RELEASE%-security} main" > /etc/apt/sources.list.d/php.list From 66281634d85dc5477baf7dd9400636fa1b9fe490 Mon Sep 17 00:00:00 2001 From: Sven-Ola Tuecke Date: Mon, 14 Jul 2025 12:17:40 +0200 Subject: [PATCH 09/15] Prevent exception on Admin:Overview. Was: ipv6 needs [] with trusted_domains --- bin/nextcloud-domain.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nextcloud-domain.sh b/bin/nextcloud-domain.sh index a8d0af1d5..d118a3c22 100644 --- a/bin/nextcloud-domain.sh +++ b/bin/nextcloud-domain.sh @@ -11,7 +11,7 @@ done # wicd service finishes before completing DHCP while :; do local_ip="$(get_ip)" - pub_ip="$(curl -m4 icanhazip.com 2>/dev/null)" + pub_ip="$(curl -m4 icanhazip.com 2>/dev/null|sed '/:/s/.*/[&]/')" [[ "$pub_ip" != "" ]] && ncc config:system:set trusted_domains 11 --value="$pub_ip" [[ "$local_ip" != "" ]] && break From 29295639828679ba99bc777ff41aa856d541f14d Mon Sep 17 00:00:00 2001 From: Sven-Ola Tuecke Date: Sun, 24 Aug 2025 14:42:41 +0200 Subject: [PATCH 10/15] Use my own repo on install --- bin/ncp-update | 2 +- install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ncp-update b/bin/ncp-update index 108e188b8..df1e866ea 100755 --- a/bin/ncp-update +++ b/bin/ncp-update @@ -23,7 +23,7 @@ fi trap 'cd /; rm -rf "${TEMPDIR}"' EXIT echo -e "Downloading updates" - git clone --depth 20 -b "$BRANCH" -q https://github.com/nextcloud/nextcloudpi.git "$TEMPDIR" || { + git clone --depth 20 -b "$BRANCH" -q https://github.com/sven-ola/nextcloudpi.git "$TEMPDIR" || { echo "No internet connectivity" exit 1 } diff --git a/install.sh b/install.sh index e77104ab8..bce3000e1 100644 --- a/install.sh +++ b/install.sh @@ -47,7 +47,7 @@ DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y git ca if [[ "${CODE_DIR}" == "" ]]; then echo "Getting build code..." CODE_DIR_TMP="${TEMPDIR}"/nextcloudpi - git clone -b "${BRANCH}" https://github.com/nextcloud/nextcloudpi.git "${CODE_DIR_TMP}" + git clone -b "${BRANCH}" https://github.com/sven-ola/nextcloudpi.git "${CODE_DIR_TMP}" cd "$CODE_DIR_TMP" else cd "${CODE_DIR}" From e426dc1955753a0814992ef9671c5bf8a1a2e7e7 Mon Sep 17 00:00:00 2001 From: Sven-Ola Tuecke Date: Sun, 24 Aug 2025 14:44:38 +0200 Subject: [PATCH 11/15] Adpations for Debian trixie --- etc/ncp.cfg | 2 +- lamp.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/ncp.cfg b/etc/ncp.cfg index 5c30ba3d5..77a4cbba6 100644 --- a/etc/ncp.cfg +++ b/etc/ncp.cfg @@ -1,5 +1,5 @@ { "nextcloud_version": "31.0.2", "php_version": "8.3", - "release": "bookworm" + "release": "trixie" } diff --git a/lamp.sh b/lamp.sh index 7cb28d29a..d37d2f237 100644 --- a/lamp.sh +++ b/lamp.sh @@ -99,7 +99,7 @@ install() done cd /tmp - mysql_secure_installation < Date: Sun, 24 Aug 2025 21:00:48 +0200 Subject: [PATCH 12/15] Adpations for Debian trixie, take2 --- etc/ncp.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/ncp.cfg b/etc/ncp.cfg index 77a4cbba6..1df34dd76 100644 --- a/etc/ncp.cfg +++ b/etc/ncp.cfg @@ -1,5 +1,5 @@ { - "nextcloud_version": "31.0.2", - "php_version": "8.3", + "nextcloud_version": "31.0.8", + "php_version": "8.4", "release": "trixie" } From 5874a23d5770b569dbb89a20833be4ac5eeedde6 Mon Sep 17 00:00:00 2001 From: Sven-Ola Tuecke Date: Mon, 25 Aug 2025 21:15:52 +0200 Subject: [PATCH 13/15] Adpations for Debian trixie, take3 --- etc/ncp-config.d/nc-nextcloud.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/ncp-config.d/nc-nextcloud.cfg b/etc/ncp-config.d/nc-nextcloud.cfg index aaa39fb97..94a7a741b 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": "31.0.2" + "value": "31.0.8" }, { "id": "MAXFILESIZE", From b212b233b8c2d831c16d975711a23117efea3683 Mon Sep 17 00:00:00 2001 From: Sven-Ola Tuecke Date: Thu, 23 Oct 2025 18:20:20 +0200 Subject: [PATCH 14/15] Do not overwrite existing apt/php.list --- lamp.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lamp.sh b/lamp.sh index d37d2f237..cbea204ba 100644 --- a/lamp.sh +++ b/lamp.sh @@ -25,8 +25,10 @@ export DEBIAN_FRONTEND=noninteractive install() { # Setup apt repository for php 8 - wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg - echo "deb https://packages.sury.org/php/ ${RELEASE%-security} main" > /etc/apt/sources.list.d/php.list + if [ ! -f /etc/apt/sources.list.d/php.list ] || [ ! -f /etc/apt/trusted.gpg.d/php.gpg ];then + wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg + echo "deb https://packages.sury.org/php/ ${RELEASE%-security} main" > /etc/apt/sources.list.d/php.list + fi apt-get update $APTINSTALL apt-utils cron curl ls -l /var/lock || true From e2434da2b33a332124418a6b24afd592efef925b Mon Sep 17 00:00:00 2001 From: Sven-Ola Tuecke Date: Sat, 25 Oct 2025 23:43:35 +0200 Subject: [PATCH 15/15] Make diverse commands compat to overlayfs --- bin/ncp-restore | 2 +- bin/ncp/CONFIG/nc-database.sh | 2 +- bin/ncp/CONFIG/nc-datadir.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ncp-restore b/bin/ncp-restore index d613fdbe1..bc225fd50 100755 --- a/bin/ncp-restore +++ b/bin/ncp-restore @@ -17,7 +17,7 @@ DIR="$( cd "$( dirname "$BACKUPFILE" )" &>/dev/null && pwd )" #abspath [[ "$DIR" =~ "$NCDIR".* ]] && { echo "Refusing to restore from $NCDIR"; exit 1; } TEMPDIR="$( mktemp -d "$( dirname "$BACKUPFILE" )"/ncp-restore.XXXXXX )" || { echo "Failed to create temp dir" >&2; exit 1; } -[[ "$(stat -fc%T "${TEMPDIR}")" =~ ext|btrfs|zfs ]] || { echo "Can only restore from ext/btrfs/zfs filesystems (found '$(stat -fc%T "${TEMPDIR}")" >&2; exit 1; } +[[ "$(stat -fc%T "${TEMPDIR}")" =~ ext|btrfs|zfs|overlayfs ]] || { echo "Can only restore from ext/btrfs/zfs filesystems (found '$(stat -fc%T "${TEMPDIR}")" >&2; exit 1; } TEMPDIR="$( cd "$TEMPDIR" &>/dev/null && pwd )" || { echo "$TEMPDIR not found"; exit 1; } #abspath cleanup(){ local RET=$?; echo "Cleanup..."; rm -rf "${TEMPDIR}"; trap "" EXIT; exit $RET; } diff --git a/bin/ncp/CONFIG/nc-database.sh b/bin/ncp/CONFIG/nc-database.sh index 0b84de1c3..e0c61e4e3 100644 --- a/bin/ncp/CONFIG/nc-database.sh +++ b/bin/ncp/CONFIG/nc-database.sh @@ -37,7 +37,7 @@ configure() local BASEDIR=$( dirname "$DBDIR" ) mkdir -p "$BASEDIR" - [[ "$(stat -fc%T "${BASEDIR}")" =~ ext|btrfs|zfs ]] || { echo -e "Only ext/btrfs/zfs filesystems can hold the data directory (found '$(stat -fc%T "${BASEDIR}")"; return 1; } + [[ "$(stat -fc%T "${BASEDIR}")" =~ ext|btrfs|zfs|overlayfs ]] || { echo -e "Only ext/btrfs/zfs filesystems can hold the data directory (found '$(stat -fc%T "${BASEDIR}")"; return 1; } sudo -u mysql test -x "$BASEDIR" || { echo -e "ERROR: the user mysql does not have access permissions over $BASEDIR"; return 1; } diff --git a/bin/ncp/CONFIG/nc-datadir.sh b/bin/ncp/CONFIG/nc-datadir.sh index 967516ffe..8aecb4f78 100644 --- a/bin/ncp/CONFIG/nc-datadir.sh +++ b/bin/ncp/CONFIG/nc-datadir.sh @@ -79,7 +79,7 @@ configure() ENCDIR="${BASEDIR}"/ncdata_enc # checks - [[ "$DISABLE_FS_CHECK" == 1 ]] || [[ "$(stat -fc%T "${BASEDIR}")" =~ ext|btrfs|zfs ]] || { + [[ "$DISABLE_FS_CHECK" == 1 ]] || [[ "$(stat -fc%T "${BASEDIR}")" =~ ext|btrfs|zfs|overlayfs ]] || { echo -e "Only ext/btrfs/zfs filesystems can hold the data directory (found '$(stat -fc%T "${BASEDIR}")')" return 1 }