Skip to content

Commit

Permalink
snapcraft/commands: Fix check for first execution during daemon start (
Browse files Browse the repository at this point in the history
…canonical#532)

This PR adjusts the point at which we check if it is the first lxd start
in `daemon.start`. We are currently making this check after we begin the
process of starting lxd, which means the check will always fail. This PR
ensures we make the check before we start lxd.

Solves related issue: canonical/lxd#13818.
  • Loading branch information
tomponline authored Jul 26, 2024
2 parents 99d3c73 + 39bd791 commit d34d19b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions snapcraft/commands/daemon.start
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,12 @@ if [ "${daemon_verbose:-"false"}" = "true" ]; then
CMD="${CMD} --verbose"
fi

# Check if this is the first time LXD is started.
FIRSTRUN="false"
if [ ! -d "${SNAP_COMMON}/lxd/database" ]; then
FIRSTRUN="true"
fi

# We deal with errors ourselves from this point on
set +e

Expand Down Expand Up @@ -754,12 +760,11 @@ if [ "${RET}" -gt "0" ]; then
exit 1
fi

## Check if this is the first time LXD is started
if [ ! -d "${SNAP_COMMON}/lxd/database" ]; then
## Process preseed if present
if [ "${FIRSTRUN}" = "true" ]; then
set -e
echo "=> First LXD execution on this system"

## Process preseed if present
if [ -e "${SNAP_COMMON}/init.yaml" ]; then
echo "==> Running LXD preseed file"
${LXD} init --preseed < "${SNAP_COMMON}/init.yaml"
Expand Down

0 comments on commit d34d19b

Please sign in to comment.