diff options
author | thecalcaholic <6317548+theCalcaholic@users.noreply.github.com> | 2022-09-29 03:07:30 +0300 |
---|---|---|
committer | thecalcaholic <6317548+theCalcaholic@users.noreply.github.com> | 2022-09-29 03:07:30 +0300 |
commit | 84b78e83620d9430da1ec36f0977199840860070 (patch) | |
tree | 81d04c809cdd42d087fc98cb317a0356386fab13 | |
parent | 3f795f812ef649b8c9fc011a5a25a2704dbbf4cc (diff) | |
parent | 06de15d5c7ce56d49af2407b5dbd64a36ab23acf (diff) |
Merge branch 'devel'
-rw-r--r-- | .github/workflows/build-docker.yml | 156 | ||||
-rw-r--r-- | .github/workflows/release.yml | 24 | ||||
-rw-r--r-- | .github/workflows/vm-tests.yml | 71 | ||||
-rw-r--r-- | bin/ncp/CONFIG/nc-limits.sh | 10 | ||||
-rw-r--r-- | bin/ncp/SYSTEM/metrics.sh | 2 | ||||
-rw-r--r-- | bin/nextcloud-domain.sh | 5 | ||||
-rw-r--r-- | build/docker/Dockerfile | 7 | ||||
-rwxr-xr-x | build/docker/debian-ncp/run-parts.sh | 28 | ||||
-rwxr-xr-x | build/docker/lamp/010lamp | 2 | ||||
-rwxr-xr-x | build/docker/nextcloud/020nextcloud | 3 | ||||
-rw-r--r-- | changelog.md | 13 | ||||
-rw-r--r-- | etc/ncp-templates/mysql/90-ncp.cnf.sh | 2 | ||||
-rw-r--r-- | lamp.sh | 8 |
13 files changed, 254 insertions, 77 deletions
diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 0a9b91a0..3d96f996 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -10,6 +10,10 @@ on: git_ref: required: true type: string + arch: + required: false + type: string + default: 'x86' push: branches: - master @@ -23,15 +27,9 @@ jobs: build: if: ${{ github.repository == 'nextcloud/nextcloudpi' }} runs-on: ubuntu-latest - strategy: - matrix: - arch: - - x86 - - armhf - - arm64 - fail-fast: false env: VERSION: "${{ inputs.git_ref || github.ref }}" + ARCH: "${{ inputs.arch || 'x86' }}" steps: - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -53,28 +51,134 @@ jobs: - name: Build images id: build-container run: | - ./build/build-docker.sh "${{ matrix.arch }}" - docker tag "ownyourbits/nextcloudpi-${{ matrix.arch }}:latest" "thecalcaholic/ncp-internal-${{ matrix.arch }}:${{ github.run_id }}" - testing_image="ownyourbits/nextcloudpi-${{ matrix.arch }}:latest" - [[ "${{ matrix.arch }}" == "arm64" ]] && testing_image="ownyourbits/ncp-qemu-fix-${{ matrix.arch }}:latest" - docker tag "${testing_image}" "thecalcaholic/ncp-internal-${{ matrix.arch }}:${{ github.run_id }}-testing" - docker push "thecalcaholic/ncp-internal-${{ matrix.arch }}:${{ github.run_id }}" - docker push "thecalcaholic/ncp-internal-${{ matrix.arch }}:${{ github.run_id }}-testing" + ./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" + 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" - test: + update-test: needs: - build runs-on: ubuntu-latest env: VERSION: "${{ inputs.git_ref || github.ref }}" + ARCH: "${{ inputs.arch || 'x86' }}" + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Start ncp container + run: | + docker volume create ncdata + platform=linux/${ARCH?} + [[ "$ARCH" == 'x86' ]] && platform=linux/amd64 + docker run --platform "$platform" -v ncdata:/data -d --rm -p 8443:443 -p 4443:4443 --name nextcloudpi ownyourbits/nextcloudpi:latest + + - name: Checkout code + uses: actions/checkout@v3 + with: + ref: "${{ env.VERSION }}" - strategy: - matrix: - arch: - - armhf - - x86 - - arm64 - fail-fast: false + - name: Setup Firefox + uses: browser-actions/setup-firefox@latest + - name: Setup GeckoDriver + uses: browser-actions/setup-geckodriver@latest + - name: Setup Selenium + run: pip install selenium + + - name: Activate container + working-directory: ./tests + run: | + docker logs nextcloudpi |& awk '{ print "CONTAINER::" $0 }' + echo 'CONTAINER:: ==========' + docker logs -f nextcloudpi |& awk '{ print "CONTAINER::" $0 }' & + docker exec nextcloudpi bash -c 'tail -f /var/log/ncp.log' |& awk '{ print "NCP::" $0 }' & + cmd=(python activation_tests.py --no-gui localhost 8443 4443) + [[ "${ARCH?}" == "x86" ]] || cmd+=(--timeout 300) + + success=false + for attempt in {1..3} + do + echo ":: Activation Tests (attempt $attempt/3) ::" + "${cmd[@]}" || { + tail -n 20 geckodriver.log >&2 || true + echo "CI:: Activation test (attempt $attempt/3) failed!" + docker exec nextcloudpi bash /usr/local/bin/ncp-diag + sleep 12 + continue + } + success=true + break + done + [[ "$success" == "true" ]] || { + echo "CI:: Activation test failed in all attempts!" + exit 1 + } + echo "CI:: Activation test successful" + - 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 + - name: Integration Tests + working-directory: ./tests + run: | + docker logs nextcloudpi |& awk '{ print "CONTAINER::" $0 }' + echo 'CONTAINER:: ==========' + docker logs -f nextcloudpi |& awk '{ print "CONTAINER::" $0 }' & + docker exec nextcloudpi bash -c 'tail -f /var/log/ncp.log' |& awk '{ print "NCP::" $0 }' & + [[ "${ARCH?}" == "x86" ]] || sleep 30 + + sleep 20 + + success=false + for attempt in {1..3} + do + echo ":: System Tests (attempt $attempt/3) ::" + python system_tests.py --no-ping --non-interactive || { + echo "CI:: System test (attempt $attempt) failed!" + sleep 12 + continue + } + success=true + break + done + [[ "$success" == "true" ]] || { + echo "CI:: System test failed in all attempts!" + exit 1 + } + echo "CI:: System test successful" + + success=false + for attempt in {1..3} + do + echo ":: Nextcloud Tests (attempt $attempt/3) ::" + python nextcloud_tests.py --no-gui localhost 8443 4443 || { + tail -n 20 geckodriver.log >&2 || true + echo "CI:: Nextcloud test (attempt $attempt/3) failed!" + sleep 12 + continue + } + success=true + break + done + [[ "$success" == "true" ]] || { + echo "CI:: Nextcloud test failed in all attempts!" + exit 1 + } + echo "CI:: Nextcloud test successful" + + docker exec nextcloudpi bash /usr/local/bin/ncp-diag + + test: + needs: + - build + runs-on: ubuntu-latest + env: + VERSION: "${{ inputs.git_ref || github.ref }}" + ARCH: "${{ inputs.arch || 'x86' }}" steps: - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -84,7 +188,7 @@ jobs: echo "${{ secrets.DOCKER_PASSWORD_INTERNAL }}" | docker login -u "${{ secrets.DOCKER_LOGIN_INTERNAL }}" --password-stdin - name: Start ncp container run: | - docker run -d --rm -p 8443:443 -p 4443:4443 --name nextcloudpi thecalcaholic/ncp-internal-${{ matrix.arch }}:${{ github.run_id }}-testing + docker run -d --rm -p 8443:443 -p 4443:4443 --name nextcloudpi thecalcaholic/ncp-internal-${ARCH?}:${{ github.run_id }}-testing - name: Checkout code uses: actions/checkout@v3 @@ -106,7 +210,7 @@ jobs: docker logs -f nextcloudpi |& awk '{ print "CONTAINER::" $0 }' & docker exec nextcloudpi bash -c 'tail -f /var/log/ncp.log' |& awk '{ print "NCP::" $0 }' & cmd=(python activation_tests.py --no-gui localhost 8443 4443) - [[ "${{ matrix.arch }}" == "x86" ]] || cmd+=(--timeout 300) + [[ "${ARCH?}" == "x86" ]] || cmd+=(--timeout 300) success=false for attempt in {1..3} @@ -134,6 +238,7 @@ jobs: echo ":: System Tests (attempt $attempt/3) ::" python system_tests.py --no-ping --non-interactive || { echo "CI:: System test (attempt $attempt) failed!" + sleep 5 continue } success=true @@ -152,6 +257,7 @@ jobs: python nextcloud_tests.py --no-gui localhost 8443 4443 || { tail -n 20 geckodriver.log >&2 || true echo "CI:: Nextcloud test (attempt $attempt/3) failed!" + sleep 5 continue } success=true @@ -162,4 +268,6 @@ jobs: exit 1 } echo "CI:: Nextcloud test successful" + + docker exec nextcloudpi bash /usr/local/bin/ncp-diag diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6ddf9f15..776524b7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,11 +47,28 @@ jobs: git_ref: "${{ inputs.git_ref || github.head_ref || github.ref_name }}" secrets: inherit - docker: + docker-x86: if: ${{ inputs.docker || github.event_name != 'workflow_dispatch' }} uses: ./.github/workflows/build-docker.yml with: git_ref: "${{ inputs.git_ref || github.head_ref || github.ref_name }}" + arch: "x86" + secrets: inherit + + docker-armhf: + if: ${{ inputs.docker || github.event_name != 'workflow_dispatch' }} + uses: ./.github/workflows/build-docker.yml + with: + git_ref: "${{ inputs.git_ref || github.head_ref || github.ref_name }}" + arch: "armhf" + secrets: inherit + + docker-arm64: + if: ${{ inputs.docker || github.event_name != 'workflow_dispatch' }} + uses: ./.github/workflows/build-docker.yml + with: + git_ref: "${{ inputs.git_ref || github.head_ref || github.ref_name }}" + arch: "arm64" secrets: inherit test-curl-installer: @@ -127,7 +144,6 @@ jobs: board_name: OdroidC2 secrets: inherit - lxd-release: needs: - github-release @@ -241,7 +257,9 @@ jobs: docker-release: needs: - - docker + - docker-x86 + - docker-armhf + - docker-arm64 - test-curl-installer if: ${{ (inputs.release || github.event_name != 'workflow_dispatch') && github.ref_type == 'tag' && (github.ref_protected || startsWith(github.ref, 'refs/tags/v')) }} runs-on: ubuntu-latest diff --git a/.github/workflows/vm-tests.yml b/.github/workflows/vm-tests.yml index 89eb437b..7c3024ec 100644 --- a/.github/workflows/vm-tests.yml +++ b/.github/workflows/vm-tests.yml @@ -239,29 +239,24 @@ jobs: image: thecalcaholic/ncp-test-automation:latest env: HCLOUD_TOKEN: "${{ secrets.TEST_AUTOMATION_HCLOUD_API_TOKEN }}" - strategy: - matrix: - test_type: [install] - include: - - test_type: install - server_address: ${{ needs.setup-installation-test-instance.outputs.server_address }} - test_result: ${{ needs.setup-installation-test-instance.result }} - test_server_id: ${{ needs.setup-installation-test-instance.outputs.test_server_id }} - version: ${{ needs.setup-installation-test-instance.outputs.version }} - fail-fast: false env: - UID: ${{ github.run_id }}-${{ matrix.test_type }} - VERSION: ${{ matrix.version }} + TEST_TYPE: install + SERVER_ADDRESS: ${{ needs.setup-installation-test-instance.outputs.server_address }} + TEST_RESULT: ${{ needs.setup-installation-test-instance.result }} + TEST_SERVER_ID: ${{ needs.setup-installation-test-instance.outputs.test_server_id }} + VERSION: ${{ needs.setup-installation-test-instance.outputs.version }} + + UID: ${{ github.run_id }}-${TEST_TYPE} steps: - name: download ssh private key from artifact store uses: actions/download-artifact@v3 - if: ${{ contains('success|failure', matrix.test_result) }} + if: ${{ contains('success|failure', env.TEST_RESULT) }} with: - name: ${{ github.run_id }}-${{ matrix.test_type }}-ssh-privkey + name: ${{ github.run_id }}-${{ env.TEST_TYPE }}-ssh-privkey path: /github/workspace/.ssh - name: Shutdown server - if: ${{ contains('success|failure', matrix.test_result) }} + if: ${{ contains('success|failure', env.TEST_RESULT) }} run: | chmod 0600 /github/workspace/.ssh/automation_ssh_key export SSH_PUBLIC_KEY="$(cat /github/workspace/.ssh/automation_ssh_key.pub)" @@ -269,25 +264,25 @@ jobs: eval "$(ssh-agent)" ssh-add /github/workspace/.ssh/automation_ssh_key - ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null" "root@${{ matrix.server_address }}" <<EOF + ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null" "root@${SERVER_ADDRESS?}" <<EOF systemctl stop mariadb systemctl poweroff EOF - name: Create Snapshot - if: ${{ contains('success|failure', matrix.test_result) }} + if: ${{ contains('success|failure', env.TEST_RESULT) }} shell: bash run: | set -x echo "${{ needs.setup-installation-test-instance.outputs.test_server_id }}" - echo "${{ matrix.test_server_id }}" + echo "${TEST_SERVER_ID?}" cd /ncp-test-automation/bin . ./library.sh tf-init "$TF_SNAPSHOT" - tf-apply "$TF_SNAPSHOT" "$TF_VAR_FILE" -var="branch=${{ matrix.version }}" -var="snapshot_provider_id=${{ matrix.test_server_id }}" -var="snapshot_type=ncp-postactivation" -state="${TF_SNAPSHOT}/${VERSION//\//.}.postactivation.tfstate" + tf-apply "$TF_SNAPSHOT" "$TF_VAR_FILE" -var="branch=${VERSION?}" -var="snapshot_provider_id=${TEST_SERVER_ID?}" -var="snapshot_type=ncp-postactivation" -state="${TF_SNAPSHOT}/${VERSION//\//.}.postactivation.tfstate" snapshot_id="$(tf-output "$TF_SNAPSHOT" -state="${TF_SNAPSHOT}/${VERSION//\//.}.postactivation.tfstate" snapshot_id)" - hcloud image add-label -o "$snapshot_id" "test-result=${{ matrix.test_result }}" + hcloud image add-label -o "$snapshot_id" "test-result=${TEST_RESULT?}" update-postactivation-snapshot: if: ${{ always() }} @@ -299,29 +294,23 @@ jobs: image: thecalcaholic/ncp-test-automation:latest env: HCLOUD_TOKEN: "${{ secrets.TEST_AUTOMATION_HCLOUD_API_TOKEN }}" - strategy: - matrix: - test_type: [update] - include: - - test_type: update - server_address: ${{ needs.setup-update-test-instance.outputs.server_address }} - test_result: ${{ needs.setup-update-test-instance.result }} - test_server_id: ${{ needs.setup-update-test-instance.outputs.test_server_id }} - version: ${{ needs.setup-update-test-instance.outputs.version }} - fail-fast: false env: - UID: ${{ github.run_id }}-${{ matrix.test_type }} - VERSION: ${{ matrix.version }} + TEST_TYPE: update + SERVER_ADDRESS: ${{ needs.setup-update-test-instance.outputs.server_address }} + TEST_RESULT: ${{ needs.setup-update-test-instance.result }} + TEST_SERVER_ID: ${{ needs.setup-update-test-instance.outputs.test_server_id }} + VERSION: ${{ needs.setup-update-test-instance.outputs.version }} + UID: ${{ github.run_id }}-${TEST_TYPE} steps: - name: download ssh private key from artifact store uses: actions/download-artifact@v3 - if: ${{ contains('success|failure', matrix.test_result) }} + if: ${{ contains('success|failure', env.TEST_RESULT) }} with: - name: ${{ github.run_id }}-${{ matrix.test_type }}-ssh-privkey + name: ${{ github.run_id }}-${{ env.TEST_TYPE }}-ssh-privkey path: /github/workspace/.ssh - name: Shutdown server - if: ${{ contains('success|failure', matrix.test_result) }} + if: ${{ contains('success|failure', env.TEST_RESULT) }} run: | chmod 0600 /github/workspace/.ssh/automation_ssh_key export SSH_PUBLIC_KEY="$(cat /github/workspace/.ssh/automation_ssh_key.pub)" @@ -329,25 +318,25 @@ jobs: eval "$(ssh-agent)" ssh-add /github/workspace/.ssh/automation_ssh_key - ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null" "root@${{ matrix.server_address }}" <<EOF + ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null" "root@${SERVER_ADDRESS?}" <<EOF systemctl stop mariadb systemctl poweroff EOF - name: Create Snapshot - if: ${{ contains('success|failure', matrix.test_result) }} + if: ${{ contains('success|failure', env.TEST_RESULT) }} shell: bash run: | set -x echo "${{ needs.setup-update-test-instance.outputs.test_server_id }}" - echo "${{ matrix.test_server_id }}" + echo "${TEST_SERVER_ID?}" cd /ncp-test-automation/bin . ./library.sh tf-init "$TF_SNAPSHOT" - tf-apply "$TF_SNAPSHOT" "$TF_VAR_FILE" -var="branch=${{ matrix.version }}" -var="snapshot_provider_id=${{ matrix.test_server_id }}" -var="snapshot_type=ncp-postactivation" -state="${TF_SNAPSHOT}/${VERSION//\//.}.postactivation.tfstate" + tf-apply "$TF_SNAPSHOT" "$TF_VAR_FILE" -var="branch=${VERSION?}" -var="snapshot_provider_id=${TEST_SERVER_ID?}" -var="snapshot_type=ncp-postactivation" -state="${TF_SNAPSHOT}/${VERSION//\//.}.postactivation.tfstate" snapshot_id="$(tf-output "$TF_SNAPSHOT" -state="${TF_SNAPSHOT}/${VERSION//\//.}.postactivation.tfstate" snapshot_id)" - hcloud image add-label -o "$snapshot_id" "test-result=${{ matrix.test_result }}" + hcloud image add-label -o "$snapshot_id" "test-result=${TEST_RESULT?}" cleanup: if: ${{ always() }} @@ -373,7 +362,7 @@ jobs: steps: - name: Teardown VMs run: | - for server in $(hcloud server list -o noheader -o columns=id -l "ci=${UID}") + for server in $(hcloud server list -o noheader -o columns=id -l "ci=${UID?}") do echo "Deleting server '$server'..." hcloud server delete "$server" diff --git a/bin/ncp/CONFIG/nc-limits.sh b/bin/ncp/CONFIG/nc-limits.sh index c1d0dcfc..bcbe63ea 100644 --- a/bin/ncp/CONFIG/nc-limits.sh +++ b/bin/ncp/CONFIG/nc-limits.sh @@ -9,7 +9,15 @@ # get_total_mem() { - free -b | sed -n 2p | awk '{ print $2 }' + local total_mem="$(free -b | sed -n 2p | awk '{ print $2 }')" + local MAX_32BIT=4096000000 + if [[ "$ARCH" == 'armv7' ]] && [[ $MAX_32BIT -lt "$total_mem" ]] + then + echo "$MAX_32BIT" + else + echo "$total_mem" + fi + } tmpl_innodb_buffer_pool_size() { diff --git a/bin/ncp/SYSTEM/metrics.sh b/bin/ncp/SYSTEM/metrics.sh index 82e58220..54c8561f 100644 --- a/bin/ncp/SYSTEM/metrics.sh +++ b/bin/ncp/SYSTEM/metrics.sh @@ -35,7 +35,7 @@ reload_metrics_config() { echo -e "WARNING: ncp-metrics-exporter failed to start (exit-code $rc)!" return $rc } - } + } || return 0 } metrics_services() { diff --git a/bin/nextcloud-domain.sh b/bin/nextcloud-domain.sh index 95eb0963..dfc757bb 100644 --- a/bin/nextcloud-domain.sh +++ b/bin/nextcloud-domain.sh @@ -34,3 +34,8 @@ while :; do set-nc-domain "${nc_domain}" >> /var/log/ncp.log break done + +[[ -z "$nc_domain" ]] || { + echo "Starting notify_push daemon" + start_notify_push +} diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index 438009b5..1f813bec 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -35,6 +35,9 @@ COPY etc/ncp-templates /usr/local/etc/ncp-templates RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \ set -e; \ +# mark as image build +touch /.ncp-image; \ + # installation apt-get update; \ apt-get install --no-install-recommends -y jq wget procps ca-certificates lsb-release; \ @@ -62,7 +65,8 @@ rm -f /var/log/alternatives.log /var/log/apt/*; \ # specific cleanup rm /data-ro/database/ib_logfile*; \ -rm /usr/local/etc/lamp.sh +rm /usr/local/etc/lamp.sh; \ +rm /.ncp-image; COPY build/docker/lamp/010lamp /etc/services-enabled.d/ @@ -168,6 +172,7 @@ sed -i 's|data-ro|data|' /data-ro/nextcloud/config/config.php; \ # fix default paths 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; \ # cleanup all NCP extras run_app_unsafe post-inst.sh; \ diff --git a/build/docker/debian-ncp/run-parts.sh b/build/docker/debian-ncp/run-parts.sh index 0099a5a1..95c85fae 100755 --- a/build/docker/debian-ncp/run-parts.sh +++ b/build/docker/debian-ncp/run-parts.sh @@ -2,18 +2,30 @@ cleanup() { + for file in $( ls -1rv /etc/services-enabled.d ); do /etc/services-enabled.d/"$file" stop "$1" done 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 -[[ $( ls -1A /data | wc -l ) -eq 0 ]] && { echo "Initializing empty volume.."; cp -raT /data-ro /data; } +if [[ $( ls -1A /data | wc -l ) -eq 0 ]] +then + echo "Initializing empty volume.." + cp -raT /data-ro /data +fi # wrapper to simulate update-rc.d cat > /usr/local/sbin/update-rc.d <<'EOF' @@ -51,4 +63,18 @@ done # wait for trap from 'docker stop' echo "Init done" + +if [[ -z "$NOBACKUP" ]] || [[ "$NOBACKUP" != "true" ]] +then + BKPDIR=/data/docker-startup-backups + WITH_DATA=no + COMPRESSED=yes + LIMIT=5 + mkdir -p "$BKPDIR" + echo "Back up current instance..." + ncp-backup "$BKPDIR" "$WITH_DATA" "$COMPRESSED" "$LIMIT" || echo 'WARN: Backup creation failed' +fi + while true; do sleep 0.5; done + + diff --git a/build/docker/lamp/010lamp b/build/docker/lamp/010lamp index cf192882..cd02a215 100755 --- a/build/docker/lamp/010lamp +++ b/build/docker/lamp/010lamp @@ -32,7 +32,7 @@ echo "Starting Apache" /usr/sbin/apache2ctl start # adjust the dbdir to the persistent storage -install_template "mysql/90-ncp.cnf.sh" "/etc/mysql/mariadb.conf.d/90-ncp.cnf" +install_template "mysql/90-ncp.cnf.sh" "/etc/mysql/mariadb.conf.d/90-ncp.cnf" || exit 1 # start echo "Starting mariaDB" diff --git a/build/docker/nextcloud/020nextcloud b/build/docker/nextcloud/020nextcloud index edfe4b1d..62452c74 100755 --- a/build/docker/nextcloud/020nextcloud +++ b/build/docker/nextcloud/020nextcloud @@ -55,9 +55,6 @@ EOF echo "Provisioning" bash /usr/local/bin/ncp-provisioning.sh -echo "Starting notify_push daemon" -start_notify_push - if needs_decrypt; then echo "Waiting for user to decrypt instance" while :; do diff --git a/changelog.md b/changelog.md index a8d5faf8..8f4fba91 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,16 @@ +## [v1.50.2](https://github.com/nextcloud/nextcloudpi/tree/v1.50.1) (2022-09-27) Various bug fixes + +### docker + +- Fix misconfigured database directory on docker (/data-ro) +- Create backup on container startup +- Fix changed user ids between container versions +- Remove nc-update from docker + +### CI/CD + +- Add tests for container updates + ## [v1.50.1](https://github.com/nextcloud/nextcloudpi/tree/v1.50.1) (2022-09-27) Various bug fixes - Fix CI/CD armbian builds diff --git a/etc/ncp-templates/mysql/90-ncp.cnf.sh b/etc/ncp-templates/mysql/90-ncp.cnf.sh index 6b9efe9f..c61fd1bc 100644 --- a/etc/ncp-templates/mysql/90-ncp.cnf.sh +++ b/etc/ncp-templates/mysql/90-ncp.cnf.sh @@ -8,7 +8,7 @@ then echo "INFO: Restoring template to default settings" >&2 DB_DIR=/var/lib/mysql else - if [[ "$DOCKERBUILD" -eq 1 ]] + if is_docker && [[ -f /.ncp-image ]] then echo "INFO: Docker build detected." >&2 DB_DIR=/data-ro/database @@ -36,6 +36,14 @@ install() mkdir -p /run/lock apache2ctl -V || true + # Create systemd users to keep uids persistent between containers + id -u systemd-resolve || { + addgroup --quiet --system systemd-journal + adduser --quiet -u 180 --system --group --no-create-home --home /run/systemd \ + --gecos "systemd Network Management" systemd-network + adduser --quiet -u 181 --system --group --no-create-home --home /run/systemd \ + --gecos "systemd Resolver" systemd-resolve + } install_with_shadow_workaround --no-install-recommends systemd $APTINSTALL -t $RELEASE php${PHPVER} php${PHPVER}-curl php${PHPVER}-gd php${PHPVER}-fpm php${PHPVER}-cli php${PHPVER}-opcache \ php${PHPVER}-mbstring php${PHPVER}-xml php${PHPVER}-zip php${PHPVER}-fileinfo php${PHPVER}-ldap \ |