diff --git a/snapcraft/commands/common b/snapcraft/commands/common new file mode 100644 index 00000000..46cd49d2 --- /dev/null +++ b/snapcraft/commands/common @@ -0,0 +1,20 @@ +wait_for_config() { + + local confpath="${SNAP_DATA}/conf/ceph.conf" + local search_str="^run dir = ${SNAP_DATA}/run" + local max_attempts=300 + local attempt=0 + + while [ $attempt -lt $max_attempts ]; do + if [ -f "${confpath}" ]; then + if grep -q "${search_str}" "${confpath}"; then + return 0 + fi + fi + attempt=$((attempt + 1)) + sleep 2 + done + + echo "No updated conf found in ${confpath}" + return 1 +} diff --git a/snapcraft/commands/mds.start b/snapcraft/commands/mds.start index 29dbcc29..74d313b9 100755 --- a/snapcraft/commands/mds.start +++ b/snapcraft/commands/mds.start @@ -1,2 +1,7 @@ #!/bin/sh + +. "${SNAP}/commands/common" + +wait_for_config + exec ceph-mds -f --cluster ceph --id "$(hostname)" diff --git a/snapcraft/commands/mgr.start b/snapcraft/commands/mgr.start index 6a171762..71aff201 100755 --- a/snapcraft/commands/mgr.start +++ b/snapcraft/commands/mgr.start @@ -1,2 +1,7 @@ #!/bin/sh + +. "${SNAP}/commands/common" + +wait_for_config + exec ceph-mgr -f --cluster ceph --id "$(hostname)" diff --git a/snapcraft/commands/mon.start b/snapcraft/commands/mon.start index 8609cf9d..249b7ee2 100755 --- a/snapcraft/commands/mon.start +++ b/snapcraft/commands/mon.start @@ -1,2 +1,7 @@ #!/bin/sh + +. "${SNAP}/commands/common" + +wait_for_config + exec ceph-mon -f --cluster ceph --id "$(hostname)" diff --git a/snapcraft/commands/osd.start b/snapcraft/commands/osd.start index f35da6d8..bfbf2632 100755 --- a/snapcraft/commands/osd.start +++ b/snapcraft/commands/osd.start @@ -6,6 +6,7 @@ export SNAP_CURRENT="$(realpath "${SNAP_DATA}/..")/current" echo $$ > "${SNAP_CURRENT}/run/ceph-osd.pid" cd "${SNAP}" +. "${SNAP}/commands/common" maybe_unlock() { dev="${1:?missing}" @@ -59,5 +60,7 @@ spawn() { } trap spawn HUP +wait_for_config + spawn exit 0 diff --git a/snapcraft/commands/rados b/snapcraft/commands/rados index 9117b49d..bb4f04d6 100755 --- a/snapcraft/commands/rados +++ b/snapcraft/commands/rados @@ -1,2 +1,3 @@ #!/bin/sh + exec "${SNAP}/bin/rados" "$@" diff --git a/snapcraft/commands/rgw.start b/snapcraft/commands/rgw.start index fb131f18..b677b14f 100755 --- a/snapcraft/commands/rgw.start +++ b/snapcraft/commands/rgw.start @@ -1,4 +1,9 @@ #!/bin/sh + +. "${SNAP}/commands/common" + +wait_for_config + conf="${SNAP_DATA}/conf/radosgw.conf" if [ -n "${conf}" ] ; then