From ef811078d5d3a6438ea3cb48db67a316d87fe865 Mon Sep 17 00:00:00 2001 From: Pietro Abate Date: Fri, 28 Feb 2025 10:22:37 +0100 Subject: [PATCH 1/4] packages: add baker service template --- .../octez/debian/octez-baker.install | 1 + .../octez/debian/octez-baker.postinst | 8 ++++++ .../octez/debian/octez-baker@.service | 26 +++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 scripts/packaging/octez/debian/octez-baker@.service diff --git a/scripts/packaging/octez/debian/octez-baker.install b/scripts/packaging/octez/debian/octez-baker.install index 46041ef7cdb5..2a857ea62b58 100644 --- a/scripts/packaging/octez/debian/octez-baker.install +++ b/scripts/packaging/octez/debian/octez-baker.install @@ -1,3 +1,4 @@ binaries/octez-baker-* /usr/bin/ binaries/octez-accuser-* /usr/bin/ scripts/wait-for-node-up.sh /usr/share/octez-baker/ +debian/octez-baker@.service /lib/systemd/system/ diff --git a/scripts/packaging/octez/debian/octez-baker.postinst b/scripts/packaging/octez/debian/octez-baker.postinst index a8dc1949a592..2b9492b3afe3 100755 --- a/scripts/packaging/octez/debian/octez-baker.postinst +++ b/scripts/packaging/octez/debian/octez-baker.postinst @@ -37,10 +37,12 @@ configure) db_get octez-baker/liquidity-vote echo "LQVOTE=${RET}" > /etc/default/octez-baker-active echo "LQVOTE=${RET}" > /etc/default/octez-baker-next + echo "LQVOTE=${RET}" > /etc/default/octez-baker db_get octez-baker/baker-key echo "BAKER_KEY=${RET}" >> /etc/default/octez-baker-active echo "BAKER_KEY=${RET}" >> /etc/default/octez-baker-next + echo "BAKER_KEY=${RET}" >> /etc/default/octez-baker echo "PROTOCOL=${ACTIVE_PROTOCOL}" >> /etc/default/octez-baker-active echo "PROTOCOL=${NEXT_PROTOCOL}" >> /etc/default/octez-baker-next @@ -53,10 +55,12 @@ configure) DALURL=${RET} echo "RUNTIME_OPTS=\"--dal-node $DALURL\"" >> /etc/default/octez-baker-next echo "RUNTIME_OPTS=\"--dal-node $DALURL\"" >> /etc/default/octez-baker-active + echo "RUNTIME_OPTS=\"--dal-node $DALURL\"" >> /etc/default/octez-baker ;; false) echo "RUNTIME_OPTS=--without-dal" >> /etc/default/octez-baker-next echo "RUNTIME_OPTS=--without-dal" >> /etc/default/octez-baker-active + echo "RUNTIME_OPTS=--without-dal" >> /etc/default/octez-baker ;; esac @@ -83,11 +87,13 @@ configure) db_get octez-baker/liquidity-vote echo "LQVOTE=${RET}" >> /etc/default/octez-baker-active echo "LQVOTE=${RET}" >> /etc/default/octez-baker-next + echo "LQVOTE=${RET}" >> /etc/default/octez-baker echoerr "LQVOTE=${RET}" db_get octez-baker/baker-key echo "BAKER_KEY=${RET}" >> /etc/default/octez-baker-active echo "BAKER_KEY=${RET}" >> /etc/default/octez-baker-next + echo "BAKER_KEY=${RET}" >> /etc/default/octez-baker echoerr "BAKER_KEY=${RET}" db_get octez-baker/dal-node @@ -98,11 +104,13 @@ configure) DALURL=${RET} echo "RUNTIME_OPTS=\"--dal-node $DALURL\"" >> /etc/default/octez-baker-next echo "RUNTIME_OPTS=\"--dal-node $DALURL\"" >> /etc/default/octez-baker-active + echo "RUNTIME_OPTS=\"--dal-node $DALURL\"" >> /etc/default/octez-baker echoerr "RUNTIME_OPTS=--dal-node $DALURL" ;; false) echo "RUNTIME_OPTS=--without-dal" >> /etc/default/octez-baker-next echo "RUNTIME_OPTS=--without-dal" >> /etc/default/octez-baker-active + echo "RUNTIME_OPTS=--without-dal" >> /etc/default/octez-baker echoerr "RUNTIME_OPTS=--without-dal" ;; esac diff --git a/scripts/packaging/octez/debian/octez-baker@.service b/scripts/packaging/octez/debian/octez-baker@.service new file mode 100644 index 000000000000..88557a90b9b2 --- /dev/null +++ b/scripts/packaging/octez/debian/octez-baker@.service @@ -0,0 +1,26 @@ +[Unit] +Description=Octez baker for protocol %i +Documentation=https://tezos.gitlab.io/ +After=network.target + +[Service] +# We use the octez-node default to determine the node's DATADIR +EnvironmentFile=-/etc/default/octez-node +EnvironmentFile=-/etc/default/octez-baker +WorkingDirectory=/var/tezos +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-%i --base-dir /var/tezos/.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-%i.log + +# The baker is started only if the node is up and running +ExecStartPre=/usr/share/octez-baker/wait-for-node-up.sh +StandardOutput=append:/var/log/tezos/baker-%i.log +StandardError=inherit + +[Install] +WantedBy=multi-user.target -- GitLab From 9017dbb718b48a289b85514efeb4dac314646d69 Mon Sep 17 00:00:00 2001 From: Pietro Abate Date: Fri, 28 Feb 2025 13:56:11 +0100 Subject: [PATCH 2/4] packages: remove active/next baker services --- .../packaging/octez/debian/octez-baker.config | 4 +-- ...ker-active.default => octez-baker.default} | 0 .../octez/debian/octez-baker.install | 6 ++-- .../octez-baker.octez-accuser-active.service | 17 ----------- .../octez-baker.octez-accuser-next.default | 2 -- .../octez-baker.octez-accuser-next.service | 17 ----------- ...ault => octez-baker.octez-accuser.default} | 0 .../debian/octez-baker.octez-accuser@.service | 21 +++++++++++++ .../octez-baker.octez-baker-active.service | 26 ---------------- .../octez-baker.octez-baker-next.default | 7 ----- .../octez-baker.octez-baker-next.service | 26 ---------------- .../octez/debian/octez-baker.postinst | 28 ----------------- .../packaging/octez/debian/octez-baker.postrm | 12 ++------ .../octez/debian/octez-baker.preinst | 4 +-- .../packaging/octez/debian/octez-baker.prerm | 25 ++++------------ .../octez/debian/octez-baker.service | 16 +++++----- .../octez/debian/octez-baker@.service | 10 +++---- scripts/packaging/octez/debian/rules | 15 +--------- .../packaging/octez/docs/README.octez-baker | 4 +-- .../octez/scripts/systemd-octez-bakers.sh | 30 +++++++++++++++++++ 20 files changed, 79 insertions(+), 191 deletions(-) rename scripts/packaging/octez/debian/{octez-baker.octez-baker-active.default => octez-baker.default} (100%) delete mode 100644 scripts/packaging/octez/debian/octez-baker.octez-accuser-active.service delete mode 100644 scripts/packaging/octez/debian/octez-baker.octez-accuser-next.default delete mode 100644 scripts/packaging/octez/debian/octez-baker.octez-accuser-next.service rename scripts/packaging/octez/debian/{octez-baker.octez-accuser-active.default => octez-baker.octez-accuser.default} (100%) create mode 100644 scripts/packaging/octez/debian/octez-baker.octez-accuser@.service delete mode 100644 scripts/packaging/octez/debian/octez-baker.octez-baker-active.service delete mode 100644 scripts/packaging/octez/debian/octez-baker.octez-baker-next.default delete mode 100644 scripts/packaging/octez/debian/octez-baker.octez-baker-next.service create mode 100755 scripts/packaging/octez/scripts/systemd-octez-bakers.sh diff --git a/scripts/packaging/octez/debian/octez-baker.config b/scripts/packaging/octez/debian/octez-baker.config index f878aebccbf7..6b7d8a8d91b5 100755 --- a/scripts/packaging/octez/debian/octez-baker.config +++ b/scripts/packaging/octez/debian/octez-baker.config @@ -17,9 +17,9 @@ case "$new" in ;; 1:*) echoerr "Upgrade from $new" - if [ -e /etc/default/octez-baker-active ]; then + if [ -e /etc/default/octez-baker ]; then #shellcheck disable=SC1091 - . /etc/default/octez-baker-active + . /etc/default/octez-baker db_set octez-baker/liquidity-vote "$LQVOTE" db_set octez-baker/baker-key "$BAKER_KEY" fi diff --git a/scripts/packaging/octez/debian/octez-baker.octez-baker-active.default b/scripts/packaging/octez/debian/octez-baker.default similarity index 100% rename from scripts/packaging/octez/debian/octez-baker.octez-baker-active.default rename to scripts/packaging/octez/debian/octez-baker.default diff --git a/scripts/packaging/octez/debian/octez-baker.install b/scripts/packaging/octez/debian/octez-baker.install index 2a857ea62b58..ee247f4b8105 100644 --- a/scripts/packaging/octez/debian/octez-baker.install +++ b/scripts/packaging/octez/debian/octez-baker.install @@ -1,4 +1,4 @@ -binaries/octez-baker-* /usr/bin/ -binaries/octez-accuser-* /usr/bin/ +binaries/octez-baker-P* /usr/bin/ +binaries/octez-accuser-P* /usr/bin/ scripts/wait-for-node-up.sh /usr/share/octez-baker/ -debian/octez-baker@.service /lib/systemd/system/ +scripts/systemd-octez-bakers.sh /usr/share/octez-baker/ diff --git a/scripts/packaging/octez/debian/octez-baker.octez-accuser-active.service b/scripts/packaging/octez/debian/octez-baker.octez-accuser-active.service deleted file mode 100644 index 4be9d69e4958..000000000000 --- a/scripts/packaging/octez/debian/octez-baker.octez-accuser-active.service +++ /dev/null @@ -1,17 +0,0 @@ -[Unit] -Description=Octez accuser -Documentation=https://tezos.gitlab.io/ -After=network.target - -[Service] -EnvironmentFile=-/etc/default/octez-baker-active -EnvironmentFile=-/etc/default/octez-accuser-active -WorkingDirectory=~ -Restart=on-failure -User=tezos -ExecStart=/bin/sh -c "/usr/bin/octez-accuser-$PROTOCOL run $RUNTIME_OPTS" -StandardOutput=append:/var/log/tezos/accuser-active.log -StandardError=inherit - -[Install] -WantedBy=multi-user.target diff --git a/scripts/packaging/octez/debian/octez-baker.octez-accuser-next.default b/scripts/packaging/octez/debian/octez-baker.octez-accuser-next.default deleted file mode 100644 index ca9dff757782..000000000000 --- a/scripts/packaging/octez/debian/octez-baker.octez-accuser-next.default +++ /dev/null @@ -1,2 +0,0 @@ -# Keep the daemon process alive: when the connection with the node is lost -RUNTIME_OPTS="--keep-alive" diff --git a/scripts/packaging/octez/debian/octez-baker.octez-accuser-next.service b/scripts/packaging/octez/debian/octez-baker.octez-accuser-next.service deleted file mode 100644 index e5d64662e64c..000000000000 --- a/scripts/packaging/octez/debian/octez-baker.octez-accuser-next.service +++ /dev/null @@ -1,17 +0,0 @@ -[Unit] -Description=Octez accuser -Documentation=https://tezos.gitlab.io/ -After=network.target - -[Service] -EnvironmentFile=-/etc/default/octez-baker-next -EnvironmentFile=-/etc/default/octez-accuser-next -WorkingDirectory=~ -Restart=on-failure -User=tezos -ExecStart=/bin/sh -c "/usr/bin/octez-accuser-$PROTOCOL run $RUNTIME_OPTS" -StandardOutput=append:/var/log/tezos/accuser-next.log -StandardError=inherit - -[Install] -WantedBy=multi-user.target diff --git a/scripts/packaging/octez/debian/octez-baker.octez-accuser-active.default b/scripts/packaging/octez/debian/octez-baker.octez-accuser.default similarity index 100% rename from scripts/packaging/octez/debian/octez-baker.octez-accuser-active.default rename to scripts/packaging/octez/debian/octez-baker.octez-accuser.default diff --git a/scripts/packaging/octez/debian/octez-baker.octez-accuser@.service b/scripts/packaging/octez/debian/octez-baker.octez-accuser@.service new file mode 100644 index 000000000000..53bde9abe77a --- /dev/null +++ b/scripts/packaging/octez/debian/octez-baker.octez-accuser@.service @@ -0,0 +1,21 @@ +[Unit] +Description=Octez accuser for protocol %i +Documentation=https://octez.tezos.com/docs/ +After=network.target + +[Service] +EnvironmentFile=-/etc/default/octez-baker +EnvironmentFile=-/etc/default/octez-accuser +WorkingDirectory=~ +Restart=on-failure +User=tezos +ExecStart=/bin/sh -c "/usr/bin/octez-accuser-%i run $RUNTIME_OPTS" + +ExecStartPre=+touch /var/log/tezos/accuser-%i.log +ExecStartPre=+chown tezos:tezos /var/log/tezos/accuser-%i.log + +StandardOutput=append:/var/log/tezos/accuser-%i.log +StandardError=inherit + +[Install] +WantedBy=multi-user.target diff --git a/scripts/packaging/octez/debian/octez-baker.octez-baker-active.service b/scripts/packaging/octez/debian/octez-baker.octez-baker-active.service deleted file mode 100644 index 3ad64254b29a..000000000000 --- a/scripts/packaging/octez/debian/octez-baker.octez-baker-active.service +++ /dev/null @@ -1,26 +0,0 @@ -[Unit] -Description=Octez baker -Documentation=https://tezos.gitlab.io/ -After=network.target - -[Service] -# We use the octez-node default to determine the node's DATADIR -EnvironmentFile=-/etc/default/octez-node -EnvironmentFile=-/etc/default/octez-baker-active -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 $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 - -# The baker is started only if the node is up and running -ExecStartPre=/usr/share/octez-baker/wait-for-node-up.sh -StandardOutput=append:/var/log/tezos/baker-active.log -StandardError=inherit - -[Install] -WantedBy=multi-user.target diff --git a/scripts/packaging/octez/debian/octez-baker.octez-baker-next.default b/scripts/packaging/octez/debian/octez-baker.octez-baker-next.default deleted file mode 100644 index 9e6e89537f5f..000000000000 --- a/scripts/packaging/octez/debian/octez-baker.octez-baker-next.default +++ /dev/null @@ -1,7 +0,0 @@ - -# Data Directory -# we use the datadir defined in /etc/default/octez-node - -# Other options -# Keep the daemon process alive -RUNTIME_OPTS="--keep-alive" diff --git a/scripts/packaging/octez/debian/octez-baker.octez-baker-next.service b/scripts/packaging/octez/debian/octez-baker.octez-baker-next.service deleted file mode 100644 index 4ebfb4a6c204..000000000000 --- a/scripts/packaging/octez/debian/octez-baker.octez-baker-next.service +++ /dev/null @@ -1,26 +0,0 @@ -[Unit] -Description=Octez baker -Documentation=https://tezos.gitlab.io/ -After=network.target - -[Service] -# We use the octez-node default to determine the node's DATADIR -EnvironmentFile=-/etc/default/octez-node -EnvironmentFile=-/etc/default/octez-baker-next -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 $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 - -# The baker is started only if the node is up and running -ExecStartPre=/usr/share/octez-baker/wait-for-node-up.sh -StandardOutput=append:/var/log/tezos/baker-next.log -StandardError=inherit - -[Install] -WantedBy=multi-user.target diff --git a/scripts/packaging/octez/debian/octez-baker.postinst b/scripts/packaging/octez/debian/octez-baker.postinst index 2b9492b3afe3..95060727a1fb 100755 --- a/scripts/packaging/octez/debian/octez-baker.postinst +++ b/scripts/packaging/octez/debian/octez-baker.postinst @@ -22,10 +22,6 @@ for file in /usr/bin/octez-baker-*; do fi done -# we guess the active protocol -ACTIVE_PROTOCOL=$(echo "$PROTO_CHOICES" | tr ' ' '\n' | grep -v '^(alpha|next)$' | sort | head -n 1) -NEXT_PROTOCOL=$(echo "$PROTO_CHOICES" | tr ' ' '\n' | grep -v '^(alpha|next)$' | sort | head -n 2 | tail -n 1) - case "${1}" in configure) # if $2 is empty, then we're doing a fresh install. @@ -35,31 +31,20 @@ configure) echoerr "Fresh installation (or reconfigure) of the Octez baker" db_get octez-baker/liquidity-vote - echo "LQVOTE=${RET}" > /etc/default/octez-baker-active - echo "LQVOTE=${RET}" > /etc/default/octez-baker-next echo "LQVOTE=${RET}" > /etc/default/octez-baker db_get octez-baker/baker-key - echo "BAKER_KEY=${RET}" >> /etc/default/octez-baker-active - echo "BAKER_KEY=${RET}" >> /etc/default/octez-baker-next echo "BAKER_KEY=${RET}" >> /etc/default/octez-baker - echo "PROTOCOL=${ACTIVE_PROTOCOL}" >> /etc/default/octez-baker-active - echo "PROTOCOL=${NEXT_PROTOCOL}" >> /etc/default/octez-baker-next - db_get octez-baker/dal-node DAL=${RET} case "$DAL" in true) db_get octez-baker/dal-node-url DALURL=${RET} - echo "RUNTIME_OPTS=\"--dal-node $DALURL\"" >> /etc/default/octez-baker-next - echo "RUNTIME_OPTS=\"--dal-node $DALURL\"" >> /etc/default/octez-baker-active echo "RUNTIME_OPTS=\"--dal-node $DALURL\"" >> /etc/default/octez-baker ;; false) - echo "RUNTIME_OPTS=--without-dal" >> /etc/default/octez-baker-next - echo "RUNTIME_OPTS=--without-dal" >> /etc/default/octez-baker-active echo "RUNTIME_OPTS=--without-dal" >> /etc/default/octez-baker ;; esac @@ -79,20 +64,11 @@ configure) echoerr "Setting defaults in /etc/default/octez-baker-*" echoerr "Migrating values when possible" - echo "PROTOCOL=${ACTIVE_PROTOCOL}" >> /etc/default/octez-baker-active - echoerr "ACTIVE PROTO=${ACTIVE_PROTOCOL}" - echo "PROTOCOL=${NEXT_PROTOCOL}" >> /etc/default/octez-baker-next - echoerr "NEXT PROTO=${NEXT_PROTOCOL}" - db_get octez-baker/liquidity-vote - echo "LQVOTE=${RET}" >> /etc/default/octez-baker-active - echo "LQVOTE=${RET}" >> /etc/default/octez-baker-next echo "LQVOTE=${RET}" >> /etc/default/octez-baker echoerr "LQVOTE=${RET}" db_get octez-baker/baker-key - echo "BAKER_KEY=${RET}" >> /etc/default/octez-baker-active - echo "BAKER_KEY=${RET}" >> /etc/default/octez-baker-next echo "BAKER_KEY=${RET}" >> /etc/default/octez-baker echoerr "BAKER_KEY=${RET}" @@ -102,14 +78,10 @@ configure) true) db_get octez-baker/dal-node-url DALURL=${RET} - echo "RUNTIME_OPTS=\"--dal-node $DALURL\"" >> /etc/default/octez-baker-next - echo "RUNTIME_OPTS=\"--dal-node $DALURL\"" >> /etc/default/octez-baker-active echo "RUNTIME_OPTS=\"--dal-node $DALURL\"" >> /etc/default/octez-baker echoerr "RUNTIME_OPTS=--dal-node $DALURL" ;; false) - echo "RUNTIME_OPTS=--without-dal" >> /etc/default/octez-baker-next - echo "RUNTIME_OPTS=--without-dal" >> /etc/default/octez-baker-active echo "RUNTIME_OPTS=--without-dal" >> /etc/default/octez-baker echoerr "RUNTIME_OPTS=--without-dal" ;; diff --git a/scripts/packaging/octez/debian/octez-baker.postrm b/scripts/packaging/octez/debian/octez-baker.postrm index 85cf93231213..bfa58de28e6d 100755 --- a/scripts/packaging/octez/debian/octez-baker.postrm +++ b/scripts/packaging/octez/debian/octez-baker.postrm @@ -22,16 +22,8 @@ purge) echo "Octez baker purged" ;; upgrade) - for s in baker accuser; do - for p in next active; do - # Check if the daemon was running before the upgrade - if [ -f "/run/octez-baker/$s-$p-daemon_was_running" ]; then - # Start the daemon if it was running - echo "Restarting Octez baker daemon: octez-$s-$p" - $debsystemctl "start octez-$s-$p.service" - fi - done - done + echo "Restarting Octez baker daemon: octez-baker" + $debsystemctl "start octez-baker.service" ;; failed-upgrade | abort-install | abort-upgrade | disappear) ;; *) diff --git a/scripts/packaging/octez/debian/octez-baker.preinst b/scripts/packaging/octez/debian/octez-baker.preinst index ee6ee6e44816..0f5f7d667aaf 100755 --- a/scripts/packaging/octez/debian/octez-baker.preinst +++ b/scripts/packaging/octez/debian/octez-baker.preinst @@ -21,9 +21,9 @@ install | upgrade) echo "Upgrading Octez baker from version $2 ( preinst )" case "$2" in 1:*) - if [ -e /etc/default/octez-baker-active ]; then + if [ -e /etc/default/octez-baker ]; then #shellcheck disable=SC1091 - . /etc/default/octez-baker-active + . /etc/default/octez-baker db_set octez-baker/liquidity-vote "$LQVOTE" db_set octez-baker/baker-key "$BAKER_KEY" fi diff --git a/scripts/packaging/octez/debian/octez-baker.prerm b/scripts/packaging/octez/debian/octez-baker.prerm index c359652643a0..80e3be5dfc07 100755 --- a/scripts/packaging/octez/debian/octez-baker.prerm +++ b/scripts/packaging/octez/debian/octez-baker.prerm @@ -9,23 +9,8 @@ set -e # wrapper script if available debsystemctl=$(command -v deb-systemd-invoke || echo systemctl) -for s in baker accuser; do - - # Check if the old daemon is active before stopping it - if $debsystemctl is-active --quiet "octez-$s.service"; then - echo "Stopping old octez-$s" - $debsystemctl stop "octez-$s.service" - fi - - for p in active next; do - # Check if the daemon is active before stopping it - if $debsystemctl is-active --quiet "octez-$s-$p.service"; then - # Set a flag in a temporary file to indicate the daemon was running - touch "/run/octez-baker/$s-$p-daemon_was_running" - echo "Stopping octez-$s-$p" - $debsystemctl stop "octez-$s-$p.service" - fi - done - - $debsystemctl stop "octez-baker.service" || true -done +# Check if the old daemon is active before stopping it +if systemctl is-active --quiet "octez-baker.service"; then + echo "Stopping old octez-baker" + $debsystemctl stop "octez-baker.service" +fi diff --git a/scripts/packaging/octez/debian/octez-baker.service b/scripts/packaging/octez/debian/octez-baker.service index ddbd8fe5a65f..15b26a76118c 100644 --- a/scripts/packaging/octez/debian/octez-baker.service +++ b/scripts/packaging/octez/debian/octez-baker.service @@ -1,7 +1,6 @@ [Unit] Description=Octez baker service After=network.target -Requires=octez-baker-active.service octez-baker-next.service octez-accuser-active.service octez-accuser-next.service [Service] Type=oneshot @@ -11,15 +10,14 @@ Restart=on-failure TimeoutStartSec=300 TimeoutStopSec=300 -ExecStartPre=systemctl start octez-baker-active.service -ExecStartPre=systemctl start octez-baker-next.service -ExecStartPre=systemctl start octez-accuser-active.service -ExecStartPre=systemctl start octez-accuser-next.service +EnvironmentFile=-/etc/default/octez-node +EnvironmentFile=-/etc/default/octez-baker -ExecStopPost=systemctl stop octez-baker-active.service -ExecStopPost=systemctl stop octez-baker-next.service -ExecStopPost=systemctl stop octez-accuser-active.service -ExecStopPost=systemctl stop octez-accuser-next.service +# The baker is started only if the node is up and running +ExecStartPre=/usr/share/octez-baker/wait-for-node-up.sh + +ExecStartPre=/usr/share/octez-baker/systemd-octez-bakers.sh start +ExecStopPost=/usr/share/octez-baker/systemd-octez-bakers.sh stop [Install] WantedBy=multi-user.target diff --git a/scripts/packaging/octez/debian/octez-baker@.service b/scripts/packaging/octez/debian/octez-baker@.service index 88557a90b9b2..c922a3139f25 100644 --- a/scripts/packaging/octez/debian/octez-baker@.service +++ b/scripts/packaging/octez/debian/octez-baker@.service @@ -1,24 +1,22 @@ [Unit] Description=Octez baker for protocol %i -Documentation=https://tezos.gitlab.io/ +Documentation=https://octez.tezos.com/docs/ After=network.target [Service] # We use the octez-node default to determine the node's DATADIR EnvironmentFile=-/etc/default/octez-node EnvironmentFile=-/etc/default/octez-baker -WorkingDirectory=/var/tezos +WorkingDirectory=~ Restart=on-failure User=tezos -# We wrap the command in /bin/sh to use identify the baker associated to $PROTOCOL +# We wrap the command in /bin/sh to identify the baker associated to $PROTOCOL ExecStart=/bin/sh -c "/usr/bin/octez-baker-%i --base-dir /var/tezos/.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=+touch /var/log/tezos/baker-%i.log ExecStartPre=+chown tezos:tezos /var/log/tezos/baker-%i.log -# The baker is started only if the node is up and running -ExecStartPre=/usr/share/octez-baker/wait-for-node-up.sh StandardOutput=append:/var/log/tezos/baker-%i.log StandardError=inherit diff --git a/scripts/packaging/octez/debian/rules b/scripts/packaging/octez/debian/rules index 209a950aa63a..0dcda9ed861d 100755 --- a/scripts/packaging/octez/debian/rules +++ b/scripts/packaging/octez/debian/rules @@ -33,12 +33,9 @@ override_dh_installdocs: override_dh_installsystemd: dh_installsystemd -p octez-node --no-start dh_installsystemd -p octez-dal-node --no-start - dh_installsystemd -p octez-baker --no-start --name octez-baker-active dh_installsystemd -p octez-smart-rollup-node --no-start - dh_installsystemd -p octez-baker --no-enable --no-start --name octez-baker-next - dh_installsystemd -p octez-baker --no-enable --no-start --name octez-accuser-next - dh_installsystemd -p octez-baker --no-enable --no-start --name octez-accuser-active dh_installsystemd -p octez-baker --no-start + dh_installsystemd -p octez-baker --no-enable --no-start --name octez-accuser@ override_dh_installlogrotate: dh_installlogrotate --package=octez-node @@ -46,20 +43,10 @@ override_dh_installlogrotate: override_dh_install: dh_install - # Include debconf configuration - mkdir -p debian/octez-baker/etc/default/ - cp debian/octez-baker.octez-accuser-next.default debian/octez-baker/etc/default/octez-accuser-next - cp debian/octez-baker.octez-accuser-active.default debian/octez-baker/etc/default/octez-accuser-active - cp debian/octez-baker.octez-baker-next.default debian/octez-baker/etc/default/octez-baker-next - cp debian/octez-baker.octez-baker-active.default debian/octez-baker/etc/default/octez-baker-active dh_installdebconf override_dh_fixperms: dh_fixperms - chmod 644 debian/octez-baker/etc/default/octez-accuser-next - chmod 644 debian/octez-baker/etc/default/octez-accuser-active - chmod 644 debian/octez-baker/etc/default/octez-baker-active - chmod 644 debian/octez-baker/etc/default/octez-baker-next # avoid creating debug symbols override_dh_dwz: diff --git a/scripts/packaging/octez/docs/README.octez-baker b/scripts/packaging/octez/docs/README.octez-baker index 768f8ccedc4c..6bd26c059ae8 100644 --- a/scripts/packaging/octez/docs/README.octez-baker +++ b/scripts/packaging/octez/docs/README.octez-baker @@ -7,10 +7,10 @@ and for the active and next protocol. For example, you can start the baker using ``` -$ sudo systemctl start octez-baker-active +$ sudo systemctl start octez-baker ``` -All services are disables and inactive by default. It's up to the user +All services are enabled but not started by default. It's up to the user to configure them. ## Usage with a remote signer diff --git a/scripts/packaging/octez/scripts/systemd-octez-bakers.sh b/scripts/packaging/octez/scripts/systemd-octez-bakers.sh new file mode 100755 index 000000000000..3c179d58058a --- /dev/null +++ b/scripts/packaging/octez/scripts/systemd-octez-bakers.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# + +# Check if the argument is valid (start or stop) +if [ "$1" != "start" ] && [ "$1" != "stop" ]; then + echo "Usage: $0 {start|stop}" + exit 1 +fi + +# Loop through each file matching the pattern +# NB: we avoid selecting `-alpha` or `-next` bakers +for file in /usr/bin/octez-baker-P*; do + file=$(basename "$file") + proto=$(echo "$file" | sed 's/^octez-baker-//' ) + + # Enable or start/stop the systemd service based on the argument + if [ "$1" = "start" ]; then + if grep -q "\-\-dal-node" /etc/default/octez-baker; then + systemctl enable octez-dal-node + systemctl start octez-dal-node + fi + systemctl enable "octez-baker@$proto" + systemctl start "octez-baker@$proto" + elif [ "$1" = "stop" ]; then + systemctl stop "octez-baker@$proto" + if grep -q '--dal-node' /etc/default/octez-baker; then + systemctl stop octez-dal-node + fi + fi +done -- GitLab From 101be3289ddf472b864eed0e1819e8211fc0d7b7 Mon Sep 17 00:00:00 2001 From: Pietro Abate Date: Mon, 3 Mar 2025 09:39:02 +0100 Subject: [PATCH 3/4] packages: adapt tests for new baker service --- .../octez/scripts/systemd-octez-bakers.sh | 2 +- scripts/packaging/tests/deb/install-bin-deb.sh | 15 ++++++++------- .../packaging/tests/deb/upgrade-systemd-test.sh | 9 ++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/packaging/octez/scripts/systemd-octez-bakers.sh b/scripts/packaging/octez/scripts/systemd-octez-bakers.sh index 3c179d58058a..f884f5bf43e7 100755 --- a/scripts/packaging/octez/scripts/systemd-octez-bakers.sh +++ b/scripts/packaging/octez/scripts/systemd-octez-bakers.sh @@ -11,7 +11,7 @@ fi # NB: we avoid selecting `-alpha` or `-next` bakers for file in /usr/bin/octez-baker-P*; do file=$(basename "$file") - proto=$(echo "$file" | sed 's/^octez-baker-//' ) + proto=$(echo "$file" | sed 's/^octez-baker-//') # Enable or start/stop the systemd service based on the argument if [ "$1" = "start" ]; then diff --git a/scripts/packaging/tests/deb/install-bin-deb.sh b/scripts/packaging/tests/deb/install-bin-deb.sh index 8e2d87996f48..c74c4e306dfc 100755 --- a/scripts/packaging/tests/deb/install-bin-deb.sh +++ b/scripts/packaging/tests/deb/install-bin-deb.sh @@ -59,19 +59,18 @@ sudo systemctl status octez-node.service # give some time to the node to create the identity # otherwise the octez-client call below will give an error -sleep 20 +/usr/share/octez-baker/wait-for-node-up.sh sudo su tezos -c "octez-client gen keys alice" key=$(sudo su tezos -c "octez-client show address alice" | grep Hash: | awk '{ print $2 }') -echo "BAKER_KEY=$key" >> /etc/default/octez-baker-active +echo "BAKER_KEY=$key" >> /etc/default/octez-baker -sudo systemctl enable octez-baker-active +sudo systemctl enable octez-baker sudo systemctl start octez-baker.service sudo systemctl status octez-baker.service -sudo systemctl status octez-baker-active.service -sudo systemctl status octez-baker-next.service +sudo systemctl status octez-baker.service sudo su tezos -c "octez-node config show" @@ -79,10 +78,12 @@ echo "-----------------------" cat /etc/default/octez-node echo "-----------------------" -cat /etc/default/octez-baker-active +cat /etc/default/octez-baker echo "-----------------------" tail /var/log/tezos/node.log echo "-----------------------" -tail /var/log/tezos/baker-active.log +for logfile in /var/log/tezos/baker-P*.log; do + tail "$logfile" +done diff --git a/scripts/packaging/tests/deb/upgrade-systemd-test.sh b/scripts/packaging/tests/deb/upgrade-systemd-test.sh index c9f5539b585d..f63fe7d378c1 100755 --- a/scripts/packaging/tests/deb/upgrade-systemd-test.sh +++ b/scripts/packaging/tests/deb/upgrade-systemd-test.sh @@ -68,18 +68,17 @@ sudo apt-get update sudo apt-get upgrade -y -o DPkg::options::="--force-overwrite" octez-baker cat /etc/default/octez-node -cat /etc/default/octez-baker-active +cat /etc/default/octez-baker sudo systemctl restart octez-node.service sudo systemctl status octez-node.service -sudo systemctl enable octez-baker-active +sudo systemctl enable octez-baker sudo systemctl restart octez-baker.service sudo systemctl status octez-baker.service -sudo systemctl status octez-baker-active.service -sudo systemctl status octez-baker-next.service +sudo systemctl status octez-baker.service ERR=0 @@ -87,7 +86,7 @@ ERR=0 # we check the debconf parameters #shellcheck disable=SC1091 -. /etc/default/octez-baker-active +. /etc/default/octez-baker # we check if the configuration of octez did not change BAKER_KEY_AFTER=$(sudo su tezos -c "octez-client -p $PROTOCOL show address baker" | head -1 | awk '{print $2}') -- GitLab From baf9103cc4105248680162ee2ceaf4bf864705d9 Mon Sep 17 00:00:00 2001 From: Pietro Abate Date: Mon, 3 Mar 2025 14:53:09 +0100 Subject: [PATCH 4/4] packages: adapt rpm spec for octez-baker --- .../octez/rpm/SPECS/octez-baker.spec | 32 ++++++++---------- scripts/packaging/tests/rpm/rpm-install.sh | 33 ++++++++++++------- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/scripts/packaging/octez/rpm/SPECS/octez-baker.spec b/scripts/packaging/octez/rpm/SPECS/octez-baker.spec index ea37b407da49..2bffdbe258af 100644 --- a/scripts/packaging/octez/rpm/SPECS/octez-baker.spec +++ b/scripts/packaging/octez/rpm/SPECS/octez-baker.spec @@ -19,35 +19,31 @@ Requires(pre): octez-client %install mkdir -p %{buildroot}/usr/bin/ mkdir -p %{buildroot}/usr/share/octez-baker -install -m 0755 $HOME/rpmbuild/SPECS/binaries/octez-baker-* %{buildroot}/usr/bin/ -install -m 0755 $HOME/rpmbuild/SPECS/binaries/octez-accuser-* %{buildroot}/usr/bin/ +install -m 0755 $HOME/rpmbuild/SPECS/binaries/octez-baker-P* %{buildroot}/usr/bin/ +install -m 0755 $HOME/rpmbuild/SPECS/binaries/octez-accuser-P* %{buildroot}/usr/bin/ install -m 0755 $HOME/rpmbuild/SPECS/scripts/wait-for-node-up.sh %{buildroot}/usr/share/octez-baker/ +install -m 0755 $HOME/rpmbuild/SPECS/scripts/systemd-octez-bakers.sh %{buildroot}/usr/share/octez-baker/ install -D -m 644 $HOME/rpmbuild/SPECS/manpages/octez-baker.1 %{buildroot}%{_mandir}/man1/octez-baker.1 gzip %{buildroot}%{_mandir}/man1/octez-baker.1 install -D -m 644 $HOME/rpmbuild/SPECS/manpages/octez-accuser.1 %{buildroot}%{_mandir}/man1/octez-accuser.1 gzip %{buildroot}%{_mandir}/man1/octez-accuser.1 -install -D -m 644 $HOME/rpmbuild/SPECS/octez-baker.octez-accuser-active.service %{buildroot}/usr/lib/systemd/system/octez-accuser-active.service -install -D -m 644 $HOME/rpmbuild/SPECS/octez-baker.octez-accuser-next.service %{buildroot}/usr/lib/systemd/system/octez-accuser-next.service -install -D -m 644 $HOME/rpmbuild/SPECS/octez-baker.octez-baker-active.service %{buildroot}/usr/lib/systemd/system/octez-baker-active.service -install -D -m 644 $HOME/rpmbuild/SPECS/octez-baker.octez-baker-next.service %{buildroot}/usr/lib/systemd/system/octez-baker-next.service -install -D -m 644 $HOME/rpmbuild/SPECS/octez-baker.octez-accuser-active.default %{buildroot}/etc/default/octez-accuser-active -install -D -m 644 $HOME/rpmbuild/SPECS/octez-baker.octez-accuser-next.default %{buildroot}/etc/default/octez-accuser-next -install -D -m 644 $HOME/rpmbuild/SPECS/octez-baker.octez-baker-active.default %{buildroot}/etc/default/octez-baker-active -install -D -m 644 $HOME/rpmbuild/SPECS/octez-baker.octez-baker-next.default %{buildroot}/etc/default/octez-baker-next +install -D -m 644 $HOME/rpmbuild/SPECS/octez-baker.octez-accuser@.service %{buildroot}/usr/lib/systemd/system/octez-accuser@.service +install -D -m 644 $HOME/rpmbuild/SPECS/octez-baker@.service %{buildroot}/usr/lib/systemd/system/octez-baker@.service +install -D -m 644 $HOME/rpmbuild/SPECS/octez-baker.service %{buildroot}/usr/lib/systemd/system/octez-baker.service +install -D -m 644 $HOME/rpmbuild/SPECS/octez-baker.octez-accuser.default %{buildroot}/etc/default/octez-accuser +install -D -m 644 $HOME/rpmbuild/SPECS/octez-baker.default %{buildroot}/etc/default/octez-baker %files /usr/bin/octez-baker-* /usr/bin/octez-accuser-* /usr/share/octez-baker/wait-for-node-up.sh +/usr/share/octez-baker/systemd-octez-bakers.sh %{_mandir}/man1/octez-baker.1* %{_mandir}/man1/octez-accuser.1* -/usr/lib/systemd/system/octez-accuser-active.service -/usr/lib/systemd/system/octez-accuser-next.service -/usr/lib/systemd/system/octez-baker-active.service -/usr/lib/systemd/system/octez-baker-next.service -/etc/default/octez-accuser-active -/etc/default/octez-accuser-next -/etc/default/octez-baker-active -/etc/default/octez-baker-next +/usr/lib/systemd/system/octez-accuser@.service +/usr/lib/systemd/system/octez-baker@.service +/usr/lib/systemd/system/octez-baker.service +/etc/default/octez-accuser +/etc/default/octez-baker %postun %post %preun diff --git a/scripts/packaging/tests/rpm/rpm-install.sh b/scripts/packaging/tests/rpm/rpm-install.sh index 017965af434e..f3a04668c6d2 100755 --- a/scripts/packaging/tests/rpm/rpm-install.sh +++ b/scripts/packaging/tests/rpm/rpm-install.sh @@ -34,8 +34,7 @@ rpm --import "$REPO/$DISTRO/octez.asc" dnf -y install sudo procps -sudo dnf -y install octez-client -dnf -y install octez-node +dnf -y install octez-client octez-node octez-baker #shellcheck disable=SC2129,SC1091 echo "NETWORK=ghostnet" >> /etc/default/octez-node @@ -44,7 +43,7 @@ echo "SNAPSHOT_NO_CHECK=" >> /etc/default/octez-node #shellcheck disable=SC1091 . /etc/default/octez-node -rm "$DATADIR/config.json" +rm -f "$DATADIR/config.json" su tezos -c "/usr/bin/octez-node config init \ --data-dir=$DATADIR \ --network=$NETWORK \ @@ -54,19 +53,31 @@ su tezos -c "/usr/bin/octez-node config init \ # if systemd is available we test the service scripts if [ "$(ps --no-headers -o comm 1)" = "systemd" ]; then + systemctl enable octez-node systemctl start octez-node - sleep 5 - systemctl status octez-node + systemctl enable octez-baker + systemctl start octez-baker.service - journalctl -xeu octez-node.service + systemctl status octez-baker.service -fi + sudo su tezos -c "octez-node config show" -sudo dnf -y install octez-baker + echo "-----------------------" + cat /etc/default/octez-node + + echo "-----------------------" + cat /etc/default/octez-baker + + echo "-----------------------" + tail /var/log/tezos/node.log + + echo "-----------------------" + for logfile in /var/log/tezos/baker-P*.log; do + if [ -e "$logfile" ]; then + tail "$logfile" + fi + done -# If systemd is available we stop the service scripts started above. -if [ "$(ps --no-headers -o comm 1)" = "systemd" ]; then - systemctl stop octez-node fi -- GitLab