import upstart scripts from argonaut

This commit is contained in:
Paul Collins 2012-10-03 21:19:53 +13:00
parent 75d8f0feef
commit e37e6cc9e6
6 changed files with 104 additions and 0 deletions

View File

@ -0,0 +1,8 @@
description "Create Ceph client.admin key when possible"
start on started ceph-mon
stop on runlevel [!2345]
task
exec /usr/sbin/ceph-create-keys --cluster="${cluster:-ceph}" -i "${id:-$(hostname)}"

View File

@ -0,0 +1,11 @@
description "Ceph hotplug"
start on block-device-added \
DEVTYPE=partition \
ID_PART_ENTRY_TYPE=4fbd7e29-9d25-41b8-afd0-062c0ceff05d
stop on runlevel [!2345]
task
instance $DEVNAME
exec /usr/sbin/ceph-disk-activate --mount -- "$DEVNAME"

View File

@ -0,0 +1,20 @@
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

View File

@ -0,0 +1,4 @@
description "Ceph monitor (all instances)"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [!2345]

View File

@ -0,0 +1,24 @@
description "Ceph MON"
start on ceph-mon
stop on runlevel [!2345] or stopping ceph-mon-all
respawn
respawn limit 5 30
pre-start script
set -e
test -x /usr/bin/ceph-mon || { stop; exit 0; }
test -d "/var/lib/ceph/mon/${cluster:-ceph}-$id" || { stop; exit 0; }
install -d -m0755 /var/run/ceph
end script
instance ${cluster:-ceph}/$id
export cluster
export id
# this breaks oneiric
#usage "cluster = name of cluster (defaults to 'ceph'); id = monitor instance id"
exec /usr/bin/ceph-mon --cluster="${cluster:-ceph}" -i "$id" -f

View File

@ -0,0 +1,37 @@
description "Ceph OSD"
start on ceph-osd
stop on runlevel [!2345]
respawn
respawn limit 5 30
pre-start script
set -e
test -x /usr/bin/ceph-osd || { stop; exit 0; }
test -d "/var/lib/ceph/osd/${cluster:-ceph}-$id" || { stop; exit 0; }
install -d -m0755 /var/run/ceph
# update location in crush; put in some suitable defaults on the
# command line, ceph.conf can override what it wants
location="$(ceph-conf --cluster="${cluster:-ceph}" --name="osd.$id" --lookup osd_crush_location || :)"
weight="$(ceph-conf --cluster="$cluster" --name="osd.$id" --lookup osd_crush_weight || :)"
ceph \
--cluster="${cluster:-ceph}" \
--name="osd.$id" \
--keyring="/var/lib/ceph/osd/${cluster:-ceph}-$id/keyring" \
osd crush set \
-- \
"$id" "osd.$id" "${weight:-1}" \
pool=default \
host="$(hostname -s)" \
$location \
|| :
end script
instance ${cluster:-ceph}/$id
export cluster
export id
exec /usr/bin/ceph-osd --cluster="${cluster:-ceph}" -i "$id" -f