description "Ceph MON (start all instances)"

start on starting ceph-mon-all
stop on runlevel [!2345]

task

script
  set -e
  # TODO what's the valid charset for cluster names and mon ids?
  find /var/lib/ceph/mon/ -mindepth 1 -maxdepth 1 -regextype posix-egrep -regex '.*/[a-z0-9]+-[a-z0-9._-]+' -printf '%P\n' \
  | while read f; do
    if [ -e "/var/lib/ceph/mon/$f/done" ]; then
        cluster="${f%%-*}"
        id="${f#*-}"

	initctl emit ceph-mon cluster="$cluster" id="$id"
    fi
  done
end script