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