diff --git a/.github/workflows/build-lxd.yml b/.github/workflows/build-lxd.yml index 1eb351d32..dd207856b 100644 --- a/.github/workflows/build-lxd.yml +++ b/.github/workflows/build-lxd.yml @@ -43,7 +43,7 @@ jobs: if [[ "${LXD_ARCH}" == "arm64" ]] then LXC_CMD="incus" - RUNNER_LABEL="ubuntu-20.04-arm64" + RUNNER_LABEL="ubuntu-26.04-arm64" echo "lxd_extra_profile=network" | tee -a "$GITHUB_OUTPUT" else LXC_CMD="incus" @@ -71,10 +71,11 @@ jobs: with: ref: "${{ env.VERSION }}" - name: Setup incus - if: ${{ needs.determine-runner.outputs.runner_label != 'ubuntu-20.04-arm64' }} + if: ${{ needs.determine-runner.outputs.runner_label != 'ubuntu-26.04-arm64' }} run: | sudo apt-get update - sudo apt-get install -y incus qemu-system incus-tools + sudo apt-get install -y incus qemu-system + sudo apt-get install -y incus-tools || sudo apt-get install -y incus-extra sudo iptables -I DOCKER-USER -i incusbr0 -j ACCEPT sudo iptables -I DOCKER-USER -o incusbr0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT sudo incus admin init --auto @@ -147,7 +148,7 @@ jobs: echo "VERSION=$version" >> "$GITHUB_ENV" echo "previous_version=${version}" >> $GITHUB_OUTPUT - name: Setup incus - if: ${{ needs.determine-runner.outputs.runner_label != 'ubuntu-20.04-arm64' }} + if: ${{ needs.determine-runner.outputs.runner_label != 'ubuntu-26.04-arm64' }} run: | sudo apt-get update sudo apt-get install -y incus qemu-system incus-tools @@ -199,7 +200,7 @@ jobs: with: ref: "${{ env.VERSION }}" - name: Setup incus - if: ${{ needs.determine-runner.outputs.runner_label != 'ubuntu-20.04-arm64' }} + if: ${{ needs.determine-runner.outputs.runner_label != 'ubuntu-26.04-arm64' }} run: | sudo apt-get update sudo apt-get install -y incus qemu-system incus-tools @@ -254,7 +255,7 @@ jobs: . ./build/buildlib.sh sudo "$LXC" delete -q -f ncp || true sudo "$LXC" image import -q "./${ARTIFACT_FILE?}" --alias "ncp/test" || true - LXC_ARGS=(-p default) + LXC_ARGS=(-p default -c security.nesting=true) [[ -z "$LXD_EXTRA_PROFILE" ]] || LXC_ARGS+=(-p "$LXD_EXTRA_PROFILE") systemd-run --user --scope -p "Delegate=yes" "$LXC" launch -q "${LXC_ARGS[@]}" "ncp/test" ncp || \ sudo systemd-run --scope -p "Delegate=yes" "$LXC" launch -q "${LXC_ARGS[@]}" "ncp/test" ncp @@ -418,7 +419,7 @@ jobs: USE_INCUS: "${{ needs.determine-runner.outputs.lxc_cmd == 'incus' && 'yes' || 'no' }}" steps: - name: Setup incus - if: ${{ needs.determine-runner.outputs.runner_label != 'ubuntu-20.04-arm64' }} + if: ${{ needs.determine-runner.outputs.runner_label != 'ubuntu-26.04-arm64' }} run: | sudo apt-get update sudo apt-get install -y incus qemu-system incus-tools @@ -474,7 +475,7 @@ jobs: . ./build/buildlib.sh sudo "$LXC" delete -q -f ncp || true sudo "$LXC" image import -q "./ncp.tar.gz" --alias "ncp/update" || true - LXC_ARGS=(-p default) + LXC_ARGS=(-p default -c security.nesting=true) [[ -z "$LXD_EXTRA_PROFILE" ]] || LXC_ARGS+=(-p "$LXD_EXTRA_PROFILE") systemd-run --user --scope -p "Delegate=yes" "$LXC" launch -q "${LXC_ARGS[@]}" "ncp/update" ncp || \ sudo systemd-run --scope -p "Delegate=yes" "$LXC" launch -q "${LXC_ARGS[@]}" "ncp/update" ncp @@ -547,7 +548,7 @@ jobs: echo "Running update to ${VERSION}" current_nc_version="$(sudo "$LXC" exec ncp -- ncc status | grep "version:" | awk '{ print $3 }')" - latest_nc_version="33.0.3" + latest_nc_version="33.0.2" sudo "$LXC" exec ncp -- bash -c "DBG=x ncp-update ${UPDATE_ARGS[*]}" sudo "$LXC" exec ncp -- /usr/local/bin/ncc status @@ -739,7 +740,7 @@ jobs: with: ref: "${{ env.VERSION }}" - name: Setup incus - if: ${{ needs.determine-runner.outputs.runner_label != 'ubuntu-20.04-arm64' }} + if: ${{ needs.determine-runner.outputs.runner_label != 'ubuntu-26.04-arm64' }} run: | sudo apt-get update sudo apt-get install -y incus qemu-system incus-tools @@ -794,7 +795,7 @@ jobs: . ./build/buildlib.sh sudo "$LXC" delete -q -f ncp || true sudo "$LXC" image import -q "./${ARTIFACT_FILE?}" --alias "ncp/test" || true - LXC_ARGS=(-p default) + LXC_ARGS=(-p default -c security.nesting=true) [[ -z "$LXD_EXTRA_PROFILE" ]] || LXC_ARGS+=(-p "$LXD_EXTRA_PROFILE") systemd-run --user --scope -p "Delegate=yes" "$LXC" launch -q "${LXC_ARGS[@]}" "ncp/test" ncp || \ sudo systemd-run --scope -p "Delegate=yes" "$LXC" launch -q "${LXC_ARGS[@]}" "ncp/test" ncp @@ -837,6 +838,8 @@ jobs: echo "nextcloud log: " datadir="$(sudo "$LXC" exec ncp -- ncc config:system:get datadirectory)" sudo "$LXC" exec ncp -- cat "$datadir/nextcloud.log" || true + echo "opcache.interned_strings_buffer:" + sudo "$LXC" exec ncp -- bash -c 'grep -R opcache.interned_strings_buffer /etc/php/*/fpm/conf.d/' exit 1 } USE_INCUS="$USE_INCUS" ../.venv/bin/python system_tests.py --non-interactive || { diff --git a/.github/workflows/build-sd-images.yml b/.github/workflows/build-sd-images.yml index 24688ad9f..ae95ef0fa 100644 --- a/.github/workflows/build-sd-images.yml +++ b/.github/workflows/build-sd-images.yml @@ -122,7 +122,7 @@ jobs: test: needs: build - runs-on: ubuntu-22.04 + runs-on: ubuntu-20.04-arm64 env: VERSION: "${{ inputs.git_ref }}" ARTIFACT_ID: ${{ needs.build.outputs.artifact_name }} @@ -161,6 +161,8 @@ jobs: - name: Prepare test run: | set -x + + PHPVER="$(jq -r .php_version ./etc/ncp.cfg)" mv "output/${ARTIFACT_FILE?}" ncp.img sudo apt-get update sudo apt-get install -y systemd-container @@ -181,13 +183,30 @@ jobs: echo '[Service]' | sudo tee raspbian_root/etc/systemd/system/redis-server.service.d/ncp-ci.conf echo 'PrivateUsers=false' | sudo tee -a raspbian_root/etc/systemd/system/redis-server.service.d/ncp-ci.conf - sudo mkdir -p raspbian_root/etc/systemd/system/php8.3-fpm.service.d - echo '[Service]' | sudo tee raspbian_root/etc/systemd/system/php8.3-fpm.service.d/ncp-ci.conf - echo 'ExecStartPre=mkdir -p /var/run/php' | sudo tee -a raspbian_root/etc/systemd/system/php8.3-fpm.service.d/ncp-ci.conf + sudo mkdir -p raspbian_root/etc/systemd/system/php${PHPVER}-fpm.service.d + echo '[Service]' | sudo tee raspbian_root/etc/systemd/system/php${PHPVER}-fpm.service.d/ncp-ci.conf + echo 'ExecStartPre=mkdir -p /var/run/php' | sudo tee -a raspbian_root/etc/systemd/system/php${PHPVER}-fpm.service.d/ncp-ci.conf + + # Disable ImportCredential and LoadCredential directives to workaround https://gitlab.com/qemu-project/qemu/-/work_items/1962 + # see https://github.com/systemd/systemd/issues/31219#issuecomment-2846006948 + for i in raspbian_root/usr/lib/systemd/system/*.service + do + [[ -f $i ]] || continue + grep -q '^ImportCredential=' "$i" && { + sudo mkdir -p "${i/usr\/lib/etc}.d" + echo -e '[Service]\nImportCredential=' | sudo tee "${i/usr\/lib/etc}.d/unset-ImportCredential.conf" + } + grep -q '^LoadCredenital=' "$i" && { + sudo mkdir -p "${i/usr\/lib/etc}.d" + echo -e '[Service]\nLoadCredential=' | sudo tee "${i/usr\/lib/etc}.d/unset-LoadCredential.conf" + } + done - name: Test image id: test run: | + PHPVER="$(jq -r .php_version ./etc/ncp.cfg)" + log_err() { rc="${1?}" msg="${2?}" @@ -215,7 +234,7 @@ jobs: echo -e "${LOG_CICD} Could not reach container. Aborting..." "${CONTAINER_CMD[@]}" systemctl status --no-pager redis-server || :; "${CONTAINER_CMD[@]}" systemctl status --no-pager mariadb || :; - "${CONTAINER_CMD[@]}" systemctl status --no-pager php8.3-fpm || :; + "${CONTAINER_CMD[@]}" systemctl status --no-pager php${PHPVER}-fpm :; exit 1 } diff --git a/bin/ncp-restore b/bin/ncp-restore index d613fdbe1..e8423fdf3 100755 --- a/bin/ncp-restore +++ b/bin/ncp-restore @@ -153,6 +153,7 @@ sed -i "s|'datadirectory' =>.*|'datadirectory' => '${DATADIR}',|" "${NCDIR}"/con # Just in case we moved the opcache dir install_template "php/opcache.ini.sh" "/etc/php/${PHPVER}/mods-available/opcache.ini" +systemctl reload "php${PHPVER}-fpm" # tmp upload dir mkdir -p "$DATADIR/tmp" diff --git a/bin/ncp-update-nc.d/update-nc.sh b/bin/ncp-update-nc.d/update-nc.sh index 401677fbb..a838ce4a3 100755 --- a/bin/ncp-update-nc.d/update-nc.sh +++ b/bin/ncp-update-nc.d/update-nc.sh @@ -258,6 +258,12 @@ elif ! is_more_recent_than "29.0.0" "${NCVER}" && is_more_recent_than "8.3.0" "$ then /usr/local/bin/ncp-update-nc.d/upgrade-php-bookworm-8.3.sh + # Reload library.sh to reset PHPVER + source /usr/local/etc/library.sh +elif ! is_more_recent_than "33.0.0" "${NCVER}" && is_more_recent_than "8.5.0" "${PHPVER}.0" && [[ "$DEBIAN_VERSION" -ge 13 ]] +then + /usr/local/bin/ncp-update-nc.d/upgrade-php-trixie-8.5.sh + # Reload library.sh to reset PHPVER source /usr/local/etc/library.sh fi diff --git a/bin/ncp-update-nc.d/upgrade-php-trixie-8.5.sh b/bin/ncp-update-nc.d/upgrade-php-trixie-8.5.sh new file mode 100755 index 000000000..d5b1f7303 --- /dev/null +++ b/bin/ncp-update-nc.d/upgrade-php-trixie-8.5.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +source /usr/local/etc/library.sh + +echo "Upgrading PHP..." +export DEBIAN_FRONTEND=noninteractive +PHPVER_OLD="$PHPVER" +PHPVER_NEW="8.5" +PHP_PACKAGES_OLD=("php${PHPVER_OLD}" \ + "php${PHPVER_OLD}"-{curl,gd,fpm,cli,opcache,mbstring,xml,zip,fileinfo,ldap,intl,bz2,mysql,bcmath,gmp,redis,common,apcu}) +PHP_PACKAGES_NEW=("php${PHPVER_NEW}" \ + "php${PHPVER_NEW}"-{curl,gd,fpm,cli,mbstring,xml,zip,fileinfo,ldap,intl,bz2,mysql,bcmath,gmp,redis,common,apcu}) + +php_restore() { + trap "" INT TERM HUP ERR + echo "Something went wrong while upgrading PHP. Rolling back to version ${PHPVER_OLD}..." + set +e + service "php${PHPVER_NEW}-fpm" stop + a2disconf php${PHPVER_NEW}-fpm + wget -O /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb + dpkg -i /tmp/debsuryorg-archive-keyring.deb + echo "deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list + apt-get update + apt-get remove --purge -y "${PHP_PACKAGES_NEW[@]}" + 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_OLD}/mods-available/opcache.ini" + phpenmod -v "${PHPVER_OLD}" -s fpm opcache + run_app nc-limits + a2enconf "php${PHPVER_OLD}-fpm" + service "php${PHPVER_OLD}-fpm" start + service apache2 restart + echo "PHP upgrade has been successfully reverted" + set -e +} + +trap php_restore INT TERM HUP ERR + +apt-get update + +clear_opcache + +echo "Stopping apache and php-fpm..." +service "php${PHPVER_OLD}-fpm" stop +service apache2 stop + +echo "Remove old PHP (${PHPVER_OLD})..." +a2disconf "php${PHPVER_OLD}-fpm" + +apt-get remove --purge -y "${PHP_PACKAGES_OLD[@]}" + +echo "Install PHP ${PHPVER_NEW}..." +install_with_shadow_workaround --no-install-recommends systemd +apt-get install -y --no-install-recommends -t "$RELEASE" "${PHP_PACKAGES_NEW[@]}" + +set_ncpcfg "php_version" "${PHPVER_NEW}" +install_template "php/opcache.ini.sh" "/etc/php/${PHPVER_NEW}/mods-available/opcache.ini" +phpenmod -v "${PHPVER_NEW}" -s fpm opcache +( set -e; export PHPVER="${PHPVER_NEW}"; run_app nc-limits ) + +a2enconf "php${PHPVER_NEW}-fpm" + +install_template "systemd/php-fpm.service.d.ncp.conf.sh" "/etc/systemd/system/php${PHPVER_NEW}-fpm.service.d/ncp.conf" + +echo "Starting apache and php-fpm..." +service "php${PHPVER_NEW}-fpm" start +service apache2 start +ncc status \ No newline at end of file diff --git a/bin/ncp/CONFIG/nc-datadir.sh b/bin/ncp/CONFIG/nc-datadir.sh index 4a2ae35a8..2516a7cc3 100644 --- a/bin/ncp/CONFIG/nc-datadir.sh +++ b/bin/ncp/CONFIG/nc-datadir.sh @@ -142,6 +142,7 @@ configure() # opcache dir create_opcache_dir install_template "php/opcache.ini.sh" "/etc/php/${PHPVER}/mods-available/opcache.ini" + systemctl reload "php${PHPVER}-fpm" # update fail2ban logpath [[ -f /etc/fail2ban/jail.local ]] && \ diff --git a/bin/ncp/CONFIG/nc-init.sh b/bin/ncp/CONFIG/nc-init.sh index 92ec85990..dd31f005c 100644 --- a/bin/ncp/CONFIG/nc-init.sh +++ b/bin/ncp/CONFIG/nc-init.sh @@ -195,7 +195,7 @@ EOF ncc config:system:set jpeg_quality --value 60 # other - ncc config:system:set serverid --value="$((RANDOM % 1024))" --type=integer + ncc config:system:set serverid --value="$((RANDOM % 512))" --type=integer ncc config:system:set overwriteprotocol --value=https ncc config:system:set overwrite.cli.url --value="https://nextcloudpi/" diff --git a/bin/ncp/CONFIG/nc-nextcloud.sh b/bin/ncp/CONFIG/nc-nextcloud.sh index 5582dfee4..224cdd3be 100644 --- a/bin/ncp/CONFIG/nc-nextcloud.sh +++ b/bin/ncp/CONFIG/nc-nextcloud.sh @@ -180,10 +180,12 @@ configure() if [[ -z "${OPCACHEDIR}" ]] then install_template "php/opcache.ini.sh" "/etc/php/${PHPVER}/mods-available/opcache.ini" --defaults + systemctl reload "php${PHPVER}-fpm" else mkdir -p "$OPCACHEDIR" chown -R www-data:www-data "$OPCACHEDIR" install_template "php/opcache.ini.sh" "/etc/php/${PHPVER}/mods-available/opcache.ini" + systemctl reload "php${PHPVER}-fpm" fi ## RE-CREATE DATABASE TABLE diff --git a/build/build-LXD.sh b/build/build-LXD.sh index ee5732eb3..7753ab10e 100755 --- a/build/build-LXD.sh +++ b/build/build-LXD.sh @@ -39,7 +39,7 @@ LXC_CMD=(lxc) "${LXC_CMD[@]}" info || LXC_CMD=(sudo "${LXC_CMD[0]}") "${LXC_CMD[@]}" delete -f ncp 2>/dev/null || true -LXC_CREATE=("${LXC_CMD[@]}" init -p default) +LXC_CREATE=("${LXC_CMD[@]}" init -p default -c security.nesting=true) [[ -n "$LXD_EXTRA_PROFILE" ]] && LXC_CREATE+=(-p "$LXD_EXTRA_PROFILE") if [[ -n "$LXD_ARCH" ]] && [[ "$LXD_ARCH" != "x86" ]] then diff --git a/etc/library.sh b/etc/library.sh index 9d48133ab..8f381188f 100644 --- a/etc/library.sh +++ b/etc/library.sh @@ -256,7 +256,7 @@ install_template() { local target="${2?}" local bkp="$(mktemp)" - echo "Installing template '$template'..." + echo "Installing template '$template' to '$target'..." mkdir -p "$(dirname "$target")" [[ -f "$target" ]] && cp -a "$target" "$bkp" diff --git a/etc/ncp-config.d/nc-nextcloud.cfg b/etc/ncp-config.d/nc-nextcloud.cfg index 54ab64bc7..9738ce936 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": "33.0.2" + "value": "34.0.2" }, { "id": "MAXFILESIZE", diff --git a/etc/ncp-templates/php/opcache.ini.sh b/etc/ncp-templates/php/opcache.ini.sh index 132c8d822..b2134de08 100644 --- a/etc/ncp-templates/php/opcache.ini.sh +++ b/etc/ncp-templates/php/opcache.ini.sh @@ -23,10 +23,12 @@ mkdir -p "$TMP_DIR" cat <tools https://github.com/nextcloud/nextcloudpi/issues - + diff --git a/tests/nextcloud_tests.py b/tests/nextcloud_tests.py index 3123537fc..159339814 100755 --- a/tests/nextcloud_tests.py +++ b/tests/nextcloud_tests.py @@ -189,6 +189,10 @@ def test_nextcloud(IP: str, nc_port: str, driver: WebDriver, skip_release_check: wait.until(VisibilityOfElementLocatedByAnyLocator([(By.CSS_SELECTOR, "#security-warning.settings-section")])) settings_config_check(wait, test) except TimeoutException: + try: + print(driver.find_element(By.CSS_SELECTOR, "#security-warning").get_attribute("innerHTML")) + except NoSuchElementException: + print(driver.page_source) settings_config_check_pre32(wait, test) close_first_run_wizard(driver, wait_multiplier) @@ -234,6 +238,8 @@ def test_nextcloud(IP: str, nc_port: str, driver: WebDriver, skip_release_check: expected['ncp_version'] = True elif 'php version' in divs[0].text.lower() and divs[1].text == ncp_cfg['php_version']: expected['php_version'] = True + elif 'php version' in divs[0].text.lower() and divs[1].text != ncp_cfg['php_version']: + print(f"{tc.yellow}{divs[1].text} != ${ncp_cfg['php_version']}") elif 'debian release' in divs[0].text.lower(): if divs[1].text == ncp_cfg['release'] or skip_release_check: expected['debian_release'] = True @@ -322,7 +328,10 @@ def settings_config_check(wait, test): test.check(True) except Exception as e: - print(driver.find_element(By.CSS_SELECTOR, "#security-warning").get_attribute("innerHTML")) + try: + print(driver.find_element(By.CSS_SELECTOR, "#security-warning").get_attribute("innerHTML")) + except NoSuchElementException: + print(driver.page_source) test.check(e) diff --git a/tests/system_tests.py b/tests/system_tests.py index d8d96ccd5..8624913d5 100755 --- a/tests/system_tests.py +++ b/tests/system_tests.py @@ -24,7 +24,7 @@ from typing import Optional def run(*args, **kwargs): - print("running command: " + " ".join(args[0])) + # print("running command: " + " ".join(args[0])) return sp_run(*args, **kwargs) processes_must_be_running = [ diff --git a/updates/1.57.0.sh b/updates/1.57.0.sh index 97402f3e3..82c62e957 100644 --- a/updates/1.57.0.sh +++ b/updates/1.57.0.sh @@ -18,7 +18,7 @@ then fi echo "Configuring serverid ..." -ncc config:system:get serverid > /dev/null || ncc config:system:set serverid --value="$((RANDOM % 1024))" --type=integer +ncc config:system:get serverid > /dev/null || ncc config:system:set serverid --value="$((RANDOM % 512))" --type=integer echo "Installing PHP APCU ..." apt-get install -y php${PHPVER}-apcu echo "Enable apache2 remoteip" diff --git a/updates/1.59.0.sh b/updates/1.59.0.sh new file mode 100644 index 000000000..b0be8fe79 --- /dev/null +++ b/updates/1.59.0.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +set -euo pipefail + +source /usr/local/etc/library.sh + +echo "Configuring serverid ..." +old_id="$(ncc config:system:get serverid)" +[[ "$old_id" -lt 512 ]] || ncc config:system:set serverid --value="$((RANDOM % 512))" --type=integer + +[[ -f "/etc/php/${PHPVER}/mods-available/opcache.ini" ]] \ + || install_template "php/opcache.ini.sh" "/etc/php/${PHPVER}/mods-available/opcache.ini" + +OPCACHE_FOUND=0 +for ini in /etc/php/"${PHPVER}"/fpm/conf.d/*opcache.ini; +do + if [[ -L "$ini" ]] + then + OPCACHE_FOUND=1 + fi +done +if [[ "$OPCACHE_FOUND" != 1 ]] +then + phpenmod -v "${PHPVER}" -s fpm opcache +fi