Skip to content

Commit

Permalink
Fixes #37877 - Compatibility with yggdrasil 0.2.z and 0.4.z
Browse files Browse the repository at this point in the history
The service name changed between the package we shipped and official 0.4.z builds, these changes account for this discrepancy.

Config file changes:
- broker is an array of mqtt servers used by 0.2
- server is an array of mqtt servers used by 0.4
- data-host needs to be set to an empty string to override certain compile-time
  defaults set in RHEL and CentOS Stream
- prefix needs to be set to the value we expect to override certain compile-time
  defaults set in RHEL and CentOS Stream

broker and server can be set at both once, each will be honored by their
respective versions

data-host and prefix can be set both at once on our build of yggdrasil they'll
just duplicate the defaults, on RHEL/CentOS Stream they'll act as overrides
  • Loading branch information
adamruzicka committed Oct 4, 2024
1 parent 5fdab0f commit e093bce
Showing 1 changed file with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,45 @@ if [ -f $CONFIGTOML ]; then
cat <<EOF > $CONFIGTOML
# yggdrasil global configuration settings written by katello-pull-transport-migrate
broker = ["mqtts://$SERVER_NAME:1883"]
server = ["mqtts://$SERVER_NAME:1883"]
cert-file = "$CERT_FILE"
key-file = "$KEY_FILE"
ca-root = ["$CA_FILE"]
log-level = "error"
data-host = ""
prefix = "yggdrasil"
EOF

else
echo "$SYSCONFDIR/yggdrasil/config.toml not found! Did 'yum install yggdrasil' succeed?"
exit 1
fi

YGGDRASIL_SERVICE=yggdrasil.service
systemctl cat $YGGDRASIL_SERVICE >/dev/null 2>/dev/null || YGGDRASIL_SERVICE=yggdrasild.service

# start the yggdrasild service
if systemctl is-enabled yggdrasild 2>/dev/null && [ -n "$YGGDRASIL_RESTART_DELAY" ] && [ "$YGGDRASIL_RESTART_DELAY" -gt 0 ]; then
systemd-run --on-active="$YGGDRASIL_RESTART_DELAY" --collect --no-block systemctl restart yggdrasild
if systemctl is-enabled $YGGDRASIL_SERVICE 2>/dev/null && [ -n "$YGGDRASIL_RESTART_DELAY" ] && [ "$YGGDRASIL_RESTART_DELAY" -gt 0 ]; then
systemd-run --on-active="$YGGDRASIL_RESTART_DELAY" --collect --no-block systemctl restart $YGGDRASIL_SERVICE
else
echo "Starting yggdrasild..."
systemctl try-restart yggdrasild
systemctl enable --now yggdrasild
echo "Starting $YGGDRASIL_SERVICE..."
systemctl try-restart $YGGDRASIL_SERVICE
systemctl enable --now $YGGDRASIL_SERVICE

# check status of yggdrasild and fail if it is not running
# check status of $YGGDRASIL_SERVICE and fail if it is not running
# possible failure reason: incorrect protocol (should be tcp:// or mqtt://) or port (should be 1883)
# also, cert-file and key-file must be valid
# and broker must be running on the server
yggdrasil status
# yggdrasil-0.2.z provides a dedicated status subcommand, newer yggdrasil doesn't have anything like that
if which yggdrasil >/dev/null 2>/dev/null; then
yggdrasil status
else
systemctl status $YGGDRASIL_SERVICE
fi

if ! systemctl is-active --quiet yggdrasild; then
if ! systemctl is-active --quiet $YGGDRASIL_SERVICE; then
echo ""
echo "yggdrasild failed to start! Check configuration in $CONFIGTOML and make sure the broker is running on the server."
echo "$YGGDRASIL_SERVICE failed to start! Check configuration in $CONFIGTOML and make sure the broker is running on the server."
exit $?
fi
fi
Expand Down

0 comments on commit e093bce

Please sign in to comment.