diff --git a/scripts/packaging/octez/debian/octez-baker.config b/scripts/packaging/octez/debian/octez-baker.config index f878aebccbf7b833197926371851fdac54e8b775..6b7d8a8d91b59b7e27193de7a963e50e60519a5e 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 46041ef7cdb5a75e705507900cb5fd921fd4c3ed..ee247f4b810597e95ec90d60085b9deb3aa4b606 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/ +binaries/octez-baker-P* /usr/bin/ +binaries/octez-accuser-P* /usr/bin/ scripts/wait-for-node-up.sh /usr/share/octez-baker/ +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 4be9d69e4958df03564f351b25005696ca2e5b0f..0000000000000000000000000000000000000000 --- 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 ca9dff7577828037319508a37e2a956680624e5b..0000000000000000000000000000000000000000 --- 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 e5d64662e64c60229eed05cd1139974070da2da3..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..53bde9abe77a15fff99e4dcbdfa2fd1f4591fcd5 --- /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 3ad64254b29a7d0250e8c705eb4e0bc2a5167d36..0000000000000000000000000000000000000000 --- 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 9e6e89537f5fd3325bd7f8867d18e09a1d51b108..0000000000000000000000000000000000000000 --- 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 4ebfb4a6c2044c1f3eab72a76a566d9301800557..0000000000000000000000000000000000000000 --- 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 a8dc1949a592ea3d84371f8c2aa119134e181f91..95060727a1fbeb722cb8fa2bdb9670ed76728d48 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,15 +31,10 @@ 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 "PROTOCOL=${ACTIVE_PROTOCOL}" >> /etc/default/octez-baker-active - echo "PROTOCOL=${NEXT_PROTOCOL}" >> /etc/default/octez-baker-next + echo "BAKER_KEY=${RET}" >> /etc/default/octez-baker db_get octez-baker/dal-node DAL=${RET} @@ -51,12 +42,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 ;; 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 @@ -75,19 +64,12 @@ 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}" db_get octez-baker/dal-node @@ -96,13 +78,11 @@ 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" ;; esac diff --git a/scripts/packaging/octez/debian/octez-baker.postrm b/scripts/packaging/octez/debian/octez-baker.postrm index 85cf93231213121c3c3163badd8f8dcd723d9d2d..bfa58de28e6da96492e8aee9b2d3f9137c2e482a 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 ee6ee6e448161f31a2bfb48271919ed1928f64ac..0f5f7d667aaf7c7b9948528aff1ed88361bf0e10 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 c359652643a0b5041ed17419517c6efd73fff3c4..80e3be5dfc07e578f630a6844b17ebe70033a4d3 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 ddbd8fe5a65fed57316d19abeff9683c04d7e146..15b26a76118c96730a492e737da58cab6e484ed1 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 new file mode 100644 index 0000000000000000000000000000000000000000..c922a3139f25be333aae79bbad397c689e6f23e6 --- /dev/null +++ b/scripts/packaging/octez/debian/octez-baker@.service @@ -0,0 +1,24 @@ +[Unit] +Description=Octez baker for protocol %i +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=~ +Restart=on-failure +User=tezos + +# 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-%i.log +ExecStartPre=+chown tezos:tezos /var/log/tezos/baker-%i.log + +StandardOutput=append:/var/log/tezos/baker-%i.log +StandardError=inherit + +[Install] +WantedBy=multi-user.target diff --git a/scripts/packaging/octez/debian/rules b/scripts/packaging/octez/debian/rules index 209a950aa63aa1ddf95933a2516bd8d7b698481c..0dcda9ed861d832034f7356b3da5c7d03a824dad 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 768f8ccedc4c85f2c03234e797cdfff445c7258c..6bd26c059ae853da2a769f960c55ee34f6091c6d 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/rpm/SPECS/octez-baker.spec b/scripts/packaging/octez/rpm/SPECS/octez-baker.spec index ea37b407da49e67d0f8a6656f12c56a4674c00aa..2bffdbe258afe4cbfa3d34b47cd266f399e44150 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/octez/scripts/systemd-octez-bakers.sh b/scripts/packaging/octez/scripts/systemd-octez-bakers.sh new file mode 100755 index 0000000000000000000000000000000000000000..f884f5bf43e7d8bd7b06e37fd99f1e1ba07de71e --- /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 diff --git a/scripts/packaging/tests/deb/install-bin-deb.sh b/scripts/packaging/tests/deb/install-bin-deb.sh index 8e2d87996f484532430ebfb35f61cd378b0d35cc..c74c4e306dfc4e75dc13b934ed784391d55b35eb 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 c9f5539b585d70a21352a26eefe071a1de107dd3..f63fe7d378c1e17effd48cb020fad157ae55f5eb 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}') diff --git a/scripts/packaging/tests/rpm/rpm-install.sh b/scripts/packaging/tests/rpm/rpm-install.sh index 017965af434efeb98a5de910ae6ea3b73b043f1a..f3a04668c6d282e8c576d14f2efea938b560b860 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