]> git.proxmox.com Git - ceph.git/blob - ceph/src/cstart.sh
update source to Ceph Pacific 16.2.2
[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
23 # ip
24 if [ -z "$ip" ]; then
25 if [ -x "$(which ip 2>/dev/null)" ]; then
26 IP_CMD="ip addr"
27 else
28 IP_CMD="ifconfig"
29 fi
30 # filter out IPv4 and localhost addresses
31 ip="$($IP_CMD | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' | head -n1)"
32 # if nothing left, try using localhost address, it might work
33 if [ -z "$ip" ]; then ip="127.0.0.1"; fi
34 fi
35 echo "ip $ip"
36
37 # port
38 if [ -z "$port" ]; then
39 while [ true ]
40 do
41 port="$(echo $(( RANDOM % 1000 + 40000 )))"
42 ss -a -n | grep LISTEN | grep "${ip}:${port} " 1>/dev/null 2>&1 || break
43 done
44 fi
45 echo "port $port"
46
47 # make sure we have an image
48 if ! $runtime image inspect $image_base:$shortid 2>/dev/null; then
49 echo "building initial $image_base:$shortid image..."
50 sudo ../src/script/cpatch -t $image_base:$shortid
51 fi
52
53 sudo ../src/cephadm/cephadm rm-cluster --force --fsid $fsid
54 sudo ../src/cephadm/cephadm --image ${image_base}:${shortid} bootstrap \
55 --skip-pull \
56 --fsid $fsid \
57 --mon-addrv "[v2:$ip:$port]" \
58 --output-dir . \
59 --allow-overwrite
60
61 # kludge to make 'bin/ceph ...' work
62 sudo chmod 755 ceph.client.admin.keyring
63 echo 'keyring = ceph.client.admin.keyring' >> ceph.conf
64
65 echo
66 echo "sudo ../src/script/cpatch -t $image_base:$shortid"
67 echo