diff --git a/.gitlab/ci/pipelines/debian_repository_full.yml b/.gitlab/ci/pipelines/debian_repository_full.yml index 35165b596676718f74fcf01580d31614a58fbba0..98dfcfd53ad0437c79b92ad42b3d68efa126167d 100644 --- a/.gitlab/ci/pipelines/debian_repository_full.yml +++ b/.gitlab/ci/pipelines/debian_repository_full.yml @@ -663,6 +663,33 @@ oc.install_bin_debian_bookworm_systemd_test: DISTRIBUTION: debian RELEASE: bookworm +oc.install_bin_debian_bookworm_systemd_custom_datadir: + image: ${GCP_REGISTRY}/tezos/docker-images/ci-docker:v1.12.0 + stage: publishing_tests + tags: + - gcp + needs: + - oc.docker-systemd_tests_debian + - apt_repo_debian + dependencies: [] + timeout: 60 minutes + before_script: + - ./scripts/ci/docker_initialize.sh + script: + - ./scripts/ci/systemd-packages-test.sh scripts/packaging/tests/deb/install-bin-deb.sh + images/packages/debian-systemd-tests.Dockerfile + services: + - docker:${DOCKER_VERSION}-dind + variables: + DOCKER_VERSION: 24.0.7 + FLAVOUR: systemd-tests + DEP_IMAGE: ${GCP_REGISTRY}/$CI_PROJECT_NAMESPACE/tezos/$FLAVOUR-$DISTRIBUTION-$RELEASE + DEP_IMAGE_PROTECTED: ${GCP_PROTECTED_REGISTRY}/tezos/tezos/$FLAVOUR-$DISTRIBUTION-$RELEASE + PREFIX: "" + DISTRIBUTION: debian + RELEASE: bookworm + DATADIR: /custom/.tezos-node + oc.upgrade_bin_debian_bookworm-systemd: image: ${GCP_REGISTRY}/tezos/docker-images/ci-docker:v1.12.0 stage: publishing_tests diff --git a/.gitlab/ci/pipelines/debian_repository_partial.yml b/.gitlab/ci/pipelines/debian_repository_partial.yml index 32a720e870b6b433cad8fef7ddb1f9b636e4fd00..2919dfd62eff173b89d8b9c18ace2d8360ccf636 100644 --- a/.gitlab/ci/pipelines/debian_repository_partial.yml +++ b/.gitlab/ci/pipelines/debian_repository_partial.yml @@ -387,6 +387,33 @@ oc.install_bin_debian_bookworm_systemd_test: DISTRIBUTION: debian RELEASE: bookworm +oc.install_bin_debian_bookworm_systemd_custom_datadir: + image: ${GCP_REGISTRY}/tezos/docker-images/ci-docker:v1.12.0 + stage: publishing_tests + tags: + - gcp + needs: + - oc.docker-systemd_tests_debian + - apt_repo_debian + dependencies: [] + timeout: 60 minutes + before_script: + - ./scripts/ci/docker_initialize.sh + script: + - ./scripts/ci/systemd-packages-test.sh scripts/packaging/tests/deb/install-bin-deb.sh + images/packages/debian-systemd-tests.Dockerfile + services: + - docker:${DOCKER_VERSION}-dind + variables: + DOCKER_VERSION: 24.0.7 + FLAVOUR: systemd-tests + DEP_IMAGE: ${GCP_REGISTRY}/$CI_PROJECT_NAMESPACE/tezos/$FLAVOUR-$DISTRIBUTION-$RELEASE + DEP_IMAGE_PROTECTED: ${GCP_PROTECTED_REGISTRY}/tezos/tezos/$FLAVOUR-$DISTRIBUTION-$RELEASE + PREFIX: "" + DISTRIBUTION: debian + RELEASE: bookworm + DATADIR: /custom/.tezos-node + oc.upgrade_bin_debian_bookworm-systemd: image: ${GCP_REGISTRY}/tezos/docker-images/ci-docker:v1.12.0 stage: publishing_tests diff --git a/.gitlab/ci/pipelines/debian_repository_partial_auto.yml b/.gitlab/ci/pipelines/debian_repository_partial_auto.yml index 8db875e24953aff1e1be7bcd03f5139bc18a3afc..401ec4fd9098c1924c83063522c5e32b5d6d7f5b 100644 --- a/.gitlab/ci/pipelines/debian_repository_partial_auto.yml +++ b/.gitlab/ci/pipelines/debian_repository_partial_auto.yml @@ -387,6 +387,33 @@ oc.install_bin_debian_bookworm_systemd_test: DISTRIBUTION: debian RELEASE: bookworm +oc.install_bin_debian_bookworm_systemd_custom_datadir: + image: ${GCP_REGISTRY}/tezos/docker-images/ci-docker:v1.12.0 + stage: publishing_tests + tags: + - gcp + needs: + - oc.docker-systemd_tests_debian + - apt_repo_debian + dependencies: [] + timeout: 60 minutes + before_script: + - ./scripts/ci/docker_initialize.sh + script: + - ./scripts/ci/systemd-packages-test.sh scripts/packaging/tests/deb/install-bin-deb.sh + images/packages/debian-systemd-tests.Dockerfile + services: + - docker:${DOCKER_VERSION}-dind + variables: + DOCKER_VERSION: 24.0.7 + FLAVOUR: systemd-tests + DEP_IMAGE: ${GCP_REGISTRY}/$CI_PROJECT_NAMESPACE/tezos/$FLAVOUR-$DISTRIBUTION-$RELEASE + DEP_IMAGE_PROTECTED: ${GCP_PROTECTED_REGISTRY}/tezos/tezos/$FLAVOUR-$DISTRIBUTION-$RELEASE + PREFIX: "" + DISTRIBUTION: debian + RELEASE: bookworm + DATADIR: /custom/.tezos-node + oc.upgrade_bin_debian_bookworm-systemd: image: ${GCP_REGISTRY}/tezos/docker-images/ci-docker:v1.12.0 stage: publishing_tests diff --git a/ci/bin/debian_repository.ml b/ci/bin/debian_repository.ml index ff2c7e7802dbefb17bc7303f9cdf608f54899121..0e8524b12b6bd8a83cff0592770feb3bfd0106ea 100644 --- a/ci/bin/debian_repository.ml +++ b/ci/bin/debian_repository.ml @@ -522,6 +522,29 @@ let jobs pipeline_type = scripts/packaging/tests/deb/install-bin-deb.sh \ images/packages/debian-systemd-tests.Dockerfile"; ]; + job_install_systemd_bin + ~__POS__ + ~name:"oc.install_bin_debian_bookworm_systemd_custom_datadir" + ~dependencies: + (Dependent + [ + Job job_docker_systemd_test_debian_dependencies; + Job job_apt_repo_debian; + ]) + ~variables: + (variables + ~kind:"systemd-tests" + [ + ("PREFIX", ""); + ("DISTRIBUTION", "debian"); + ("RELEASE", "bookworm"); + ("DATADIR", "/custom/.tezos-node"); + ]) + [ + "./scripts/ci/systemd-packages-test.sh \ + scripts/packaging/tests/deb/install-bin-deb.sh \ + images/packages/debian-systemd-tests.Dockerfile"; + ]; job_install_systemd_bin ~__POS__ ~name:"oc.upgrade_bin_debian_bookworm-systemd" diff --git a/scripts/packaging/octez/debian/octez-baker.octez-accuser-active.service b/scripts/packaging/octez/debian/octez-baker.octez-accuser-active.service index c4d06be5062ce1923a208c34ff3416240907e060..4be9d69e4958df03564f351b25005696ca2e5b0f 100644 --- a/scripts/packaging/octez/debian/octez-baker.octez-accuser-active.service +++ b/scripts/packaging/octez/debian/octez-baker.octez-accuser-active.service @@ -6,7 +6,7 @@ After=network.target [Service] EnvironmentFile=-/etc/default/octez-baker-active EnvironmentFile=-/etc/default/octez-accuser-active -WorkingDirectory=/var/tezos +WorkingDirectory=~ Restart=on-failure User=tezos ExecStart=/bin/sh -c "/usr/bin/octez-accuser-$PROTOCOL run $RUNTIME_OPTS" diff --git a/scripts/packaging/octez/debian/octez-baker.octez-accuser-next.service b/scripts/packaging/octez/debian/octez-baker.octez-accuser-next.service index 702005221181cbb6303254222f11e5aad7075f21..e5d64662e64c60229eed05cd1139974070da2da3 100644 --- a/scripts/packaging/octez/debian/octez-baker.octez-accuser-next.service +++ b/scripts/packaging/octez/debian/octez-baker.octez-accuser-next.service @@ -6,7 +6,7 @@ After=network.target [Service] EnvironmentFile=-/etc/default/octez-baker-next EnvironmentFile=-/etc/default/octez-accuser-next -WorkingDirectory=/var/tezos +WorkingDirectory=~ Restart=on-failure User=tezos ExecStart=/bin/sh -c "/usr/bin/octez-accuser-$PROTOCOL run $RUNTIME_OPTS" diff --git a/scripts/packaging/octez/debian/octez-baker.octez-baker-active.service b/scripts/packaging/octez/debian/octez-baker.octez-baker-active.service index 453a403bbd8727a9a5a7737dbdbe0c205f225c54..3ad64254b29a7d0250e8c705eb4e0bc2a5167d36 100644 --- a/scripts/packaging/octez/debian/octez-baker.octez-baker-active.service +++ b/scripts/packaging/octez/debian/octez-baker.octez-baker-active.service @@ -7,12 +7,12 @@ After=network.target # We use the octez-node default to determine the node's DATADIR EnvironmentFile=-/etc/default/octez-node EnvironmentFile=-/etc/default/octez-baker-active -WorkingDirectory=/var/tezos +WorkingDirectory=~ Restart=on-failure User=tezos # We wrap the command in /bin/sh to use identify the baker associated to $PROTOCOL -ExecStart=/bin/sh -c "/usr/bin/octez-baker-$PROTOCOL --base-dir /var/tezos/.tezos-client run with local node $DATADIR --liquidity-baking-toggle-vote $LQVOTE $RUNTIME_OPTS $BAKING_KEY" +ExecStart=/bin/sh -c "/usr/bin/octez-baker-$PROTOCOL --base-dir $HOME/.tezos-client run with local node $DATADIR --liquidity-baking-toggle-vote $LQVOTE $RUNTIME_OPTS $BAKING_KEY" ExecStartPre=+touch /var/log/tezos/baker-active.log ExecStartPre=+chown tezos:tezos /var/log/tezos/baker-active.log diff --git a/scripts/packaging/octez/debian/octez-baker.octez-baker-next.service b/scripts/packaging/octez/debian/octez-baker.octez-baker-next.service index 9c5c2303f20a6456559907c8fa1d06893e5e8f3c..4ebfb4a6c2044c1f3eab72a76a566d9301800557 100644 --- a/scripts/packaging/octez/debian/octez-baker.octez-baker-next.service +++ b/scripts/packaging/octez/debian/octez-baker.octez-baker-next.service @@ -7,12 +7,12 @@ After=network.target # We use the octez-node default to determine the node's DATADIR EnvironmentFile=-/etc/default/octez-node EnvironmentFile=-/etc/default/octez-baker-next -WorkingDirectory=/var/tezos +WorkingDirectory=~ Restart=on-failure User=tezos # We wrap the command in /bin/sh to use identify the baker associated to $PROTOCOL -ExecStart=/bin/sh -c "/usr/bin/octez-baker-$PROTOCOL --base-dir /var/tezos/.tezos-client run with local node $DATADIR --liquidity-baking-toggle-vote $LQVOTE $RUNTIME_OPTS $BAKING_KEY" +ExecStart=/bin/sh -c "/usr/bin/octez-baker-$PROTOCOL --base-dir $HOME/.tezos-client run with local node $DATADIR --liquidity-baking-toggle-vote $LQVOTE $RUNTIME_OPTS $BAKING_KEY" ExecStartPre=+touch /var/log/tezos/baker-next.log ExecStartPre=+chown tezos:tezos /var/log/tezos/baker-next.log diff --git a/scripts/packaging/octez/debian/octez-dal-node.service b/scripts/packaging/octez/debian/octez-dal-node.service index edd701ebb285e84d3c222948e6b585c7e30c9936..7b0c756ed2d0e724debca1fcd79ea9c7e0494c9a 100644 --- a/scripts/packaging/octez/debian/octez-dal-node.service +++ b/scripts/packaging/octez/debian/octez-dal-node.service @@ -5,7 +5,7 @@ After=network.target [Service] EnvironmentFile=-/etc/default/octez-dal-node -WorkingDirectory=/var/tezos +WorkingDirectory=~ Restart=on-failure User=tezos ExecStart=/usr/bin/octez-dal-node run $RUNTIME_OPTS diff --git a/scripts/packaging/octez/debian/octez-node.postinst b/scripts/packaging/octez/debian/octez-node.postinst index 3b9324acf3bb6daaac80ce6cbbfc04c7625c2fed..8320d4868ac64f302e542269f827437492414263 100755 --- a/scripts/packaging/octez/debian/octez-node.postinst +++ b/scripts/packaging/octez/debian/octez-node.postinst @@ -7,7 +7,10 @@ set -e db_version 2.0 -TEZOS_HOME=/var/tezos +if [ -e /etc/default/octez-node ]; then + . /etc/default/octez-node + TEZOS_HOME=$(dirname $DATADIR) +fi # work directory to store temporary files associated to this package mkdir -p /run/octez-node @@ -24,12 +27,11 @@ configure) if [ -z "${2:-}" ] || [ -z "$DPKG_RUNNING_VERSION" ]; then # these are the defaults for the package and only used # in the "configure" stage. - DATADIR="$TEZOS_HOME/.tezos-node" # shellcheck disable=SC2119 if ! id "tezos" > /dev/null 2>&1; then adduser --quiet --disabled-password \ - --home $TEZOS_HOME --shell /bin/bash \ + --home "$TEZOS_HOME" --shell /bin/bash \ --gecos "admin user for octez" tezos else # setup data directory in case the tezos user was already present @@ -53,7 +55,7 @@ configure) db_get octez-node/history-mode HISTORY_MODE=${RET} - if [ ! -e $DATADIR/config.json ]; then + if [ ! -e "$DATADIR/config.json" ]; then su tezos -c "/usr/bin/octez-node config init --data-dir=$DATADIR --network=\"$NETWORK\" \ --history-mode=\"$HISTORY_MODE\" \ --net-addr=\"[::]:9732\" \ diff --git a/scripts/packaging/octez/debian/octez-node.postrm b/scripts/packaging/octez/debian/octez-node.postrm index 87dec5e9449e4f6d0b63f1822cf2d1b36d883f73..fe5e6dfa25bc331fcc6912d6bf381c3754c053e7 100755 --- a/scripts/packaging/octez/debian/octez-node.postrm +++ b/scripts/packaging/octez/debian/octez-node.postrm @@ -10,6 +10,10 @@ set -e # wrapper script if available debsystemctl=$(command -v deb-systemd-invoke || echo systemctl) +if [ -e /etc/default/octez-node ]; then + . /etc/default/octez-node +fi + case "${1}" in remove) # Clean up the temporary directory @@ -18,7 +22,6 @@ remove) rm -Rf /run/octez-node ;; purge) - DATADIR=/var/tezos # display a warning before proceding db_get octez-node/purge_warning || true case "$RET" in diff --git a/scripts/packaging/octez/debian/octez-node.service b/scripts/packaging/octez/debian/octez-node.service index 4ab7ccdef46216d1f76c9311ae5a2bc5de1cb583..b3f3362cd5ab84050d57a222407d041b769be05a 100644 --- a/scripts/packaging/octez/debian/octez-node.service +++ b/scripts/packaging/octez/debian/octez-node.service @@ -6,7 +6,7 @@ After=network.target [Service] TimeoutSec=600s EnvironmentFile=-/etc/default/octez-node -WorkingDirectory=/var/tezos +WorkingDirectory=~ Restart=on-failure TimeoutSec=1500 User=tezos diff --git a/scripts/packaging/octez/debian/octez-smart-rollup-node.service b/scripts/packaging/octez/debian/octez-smart-rollup-node.service index 72d0577f21a861d53e46fcebaaedd5b63941706f..6e5505f7d5c13b386e8046076ca8007e99b83344 100644 --- a/scripts/packaging/octez/debian/octez-smart-rollup-node.service +++ b/scripts/packaging/octez/debian/octez-smart-rollup-node.service @@ -5,7 +5,7 @@ After=network.target octez-node.service [Service] EnvironmentFile=-/etc/default/octez-smart-rollup-node -WorkingDirectory=/var/tezos +WorkingDirectory=~ Restart=on-failure User=tezos ExecStart=/usr/bin/octez-smart-rollup-node run $RUNTIME_OPTS diff --git a/scripts/packaging/octez/scripts/octez-node-prestart.sh b/scripts/packaging/octez/scripts/octez-node-prestart.sh index 87a3ba1edad7827f34d9ec456bcba3b9df839d5f..c971e6ba5f573ca47d5220bef2fa34113ca5b049 100755 --- a/scripts/packaging/octez/scripts/octez-node-prestart.sh +++ b/scripts/packaging/octez/scripts/octez-node-prestart.sh @@ -12,7 +12,10 @@ if [ "$(whoami)" != "tezos" ]; then exit 1 fi -DATADIR=/var/tezos/.tezos-node +if [ -e /etc/default/octez-node ]; then + #shellcheck disable=SC1091 + . /etc/default/octez-node +fi # Function to get a Debconf value get_value() { diff --git a/scripts/packaging/octez/scripts/snapshot-import.sh b/scripts/packaging/octez/scripts/snapshot-import.sh index c0cb229dbcec043bce00027104637ebf39359653..29faf20dd4a4f5959126c626ecb85424fadaca17 100755 --- a/scripts/packaging/octez/scripts/snapshot-import.sh +++ b/scripts/packaging/octez/scripts/snapshot-import.sh @@ -13,7 +13,11 @@ fi NETWORK=mainnet HISTORY_MODE=rolling SNAPSHOT_NO_CHECK="" -DATADIR=/var/tezos/.tezos-node + +if [ -e /etc/default/octez-node ]; then + #shellcheck disable=SC1091 + . /etc/default/octez-node +fi # Function to display help message display_help() { @@ -62,7 +66,7 @@ trap 'rm -f /tmp/$HISTORY_MODE' EXIT # We simply check if the config file exist. But we don't # try to update the octez node configuration. Trying to # do anything automatically might lead to data loss. -if [ ! -e $DATADIR/config.json ]; then +if [ ! -e "$DATADIR/config.json" ]; then echo "Init node in $DATADIR" /usr/bin/octez-node config init --data-dir="$DATADIR" \ --network="$NETWORK" \ diff --git a/scripts/packaging/tests/deb/install-bin-deb.sh b/scripts/packaging/tests/deb/install-bin-deb.sh index 7e40d8ff55bf40e3e93c33453a5a49403828ce2a..a082a44ebe56e57ff8356a6e027e7d03650d3148 100755 --- a/scripts/packaging/tests/deb/install-bin-deb.sh +++ b/scripts/packaging/tests/deb/install-bin-deb.sh @@ -3,9 +3,10 @@ set -eu set -x -REPO="https://storage.googleapis.com/$GCP_LINUX_PACKAGES_BUCKET/$CI_COMMIT_REF_NAME" +REPO="https://storage.googleapis.com/${GCP_LINUX_PACKAGES_BUCKET:-tezos-linux-repo}/$CI_COMMIT_REF_NAME" DISTRO=$1 RELEASE=$2 +DATADIR=${3:-} # For the upgrade script in the CI, we do not want debconf to ask questions export DEBIAN_FRONTEND=noninteractive @@ -44,6 +45,15 @@ fi sudo apt-get install -y octez-baker +if [ -n "$DATADIR" ]; then + echo "Setup Custom data dir" + usermod -m -d /custom tezos + if [ -e /var/tezos/.tezos-node ]; then + cp -a /var/tezos/.tezos-node /custom/ + fi + echo "DATADIR=/custom/.tezos-node" >> /etc/default/octez-node +fi + sudo systemctl enable octez-node sudo systemctl start octez-node.service sudo systemctl status octez-node.service diff --git a/scripts/packaging/tests/systemd-docker-test.sh b/scripts/packaging/tests/systemd-docker-test.sh index 441ac4c6870581796b2d72a0ec6128d754a15c5e..1746858d1fdad9001af97feb9e8da85804a02023 100755 --- a/scripts/packaging/tests/systemd-docker-test.sh +++ b/scripts/packaging/tests/systemd-docker-test.sh @@ -62,7 +62,7 @@ docker exec \ -e "CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA" \ -e "GCP_LINUX_PACKAGES_BUCKET=$GCP_LINUX_PACKAGES_BUCKET" \ -i systemd \ - /bin/sh -c "$TESTFILE $DISTRIBUTION $RELEASE" + /bin/sh -c "$TESTFILE $DISTRIBUTION $RELEASE ${DATADIR:-}" # Capture exit status EXIT=$?