]> git.proxmox.com Git - ceph.git/blame - ceph/src/cstart.sh
import ceph quincy 17.2.4
[ceph.git] / ceph / src / cstart.sh
CommitLineData
f67539c2
TL
1#!/bin/bash -e
2
3image_base="quay.io/ceph-ci/ceph"
4
5if which podman 2>&1 > /dev/null; then
6 runtime="podman"
7else
8 runtime="docker"
9fi
10
11# fsid
12if [ -e fsid ] ; then
13 fsid=`cat fsid`
14else
15 fsid=`uuidgen`
16 echo $fsid > fsid
17fi
18echo "fsid $fsid"
19
20shortid=`echo $fsid | cut -c 1-8`
20effc67 21echo $shortid > shortid
f67539c2
TL
22echo "shortid $shortid"
23
24# ip
25if [ -z "$ip" ]; then
26 if [ -x "$(which ip 2>/dev/null)" ]; then
27 IP_CMD="ip addr"
28 else
29 IP_CMD="ifconfig"
30 fi
31 # filter out IPv4 and localhost addresses
32 ip="$($IP_CMD | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' | head -n1)"
33 # if nothing left, try using localhost address, it might work
34 if [ -z "$ip" ]; then ip="127.0.0.1"; fi
35fi
36echo "ip $ip"
37
38# port
20effc67
TL
39if [ -e port ] ; then
40 port=`cat port`
41else
f67539c2
TL
42 while [ true ]
43 do
44 port="$(echo $(( RANDOM % 1000 + 40000 )))"
20effc67 45 ss -a -n | grep LISTEN | grep "${ip}:${port} " 2>&1 >/dev/null || break
f67539c2 46 done
20effc67 47 echo $port > port
f67539c2 48fi
20effc67
TL
49echo "mon port $port"
50
f67539c2
TL
51
52# make sure we have an image
20effc67 53if ! sudo $runtime image inspect $image_base:$shortid 1>/dev/null 2>/dev/null; then
f67539c2
TL
54 echo "building initial $image_base:$shortid image..."
55 sudo ../src/script/cpatch -t $image_base:$shortid
56fi
57
58sudo ../src/cephadm/cephadm rm-cluster --force --fsid $fsid
59sudo ../src/cephadm/cephadm --image ${image_base}:${shortid} bootstrap \
60 --skip-pull \
61 --fsid $fsid \
62 --mon-addrv "[v2:$ip:$port]" \
63 --output-dir . \
20effc67
TL
64 --allow-overwrite \
65 $@
f67539c2
TL
66
67# kludge to make 'bin/ceph ...' work
68sudo chmod 755 ceph.client.admin.keyring
69echo 'keyring = ceph.client.admin.keyring' >> ceph.conf
70
20effc67
TL
71# don't use repo digests; this implicitly does a pull and we don't want that
72bin/ceph config set mgr mgr/cephadm/use_repo_digest false
73
f67539c2
TL
74echo
75echo "sudo ../src/script/cpatch -t $image_base:$shortid"
76echo