]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
src/cstart.sh: initial version
authorSage Weil <sage@redhat.com>
Tue, 31 Mar 2020 22:47:21 +0000 (18:47 -0400)
committerSage Weil <sage@redhat.com>
Fri, 17 Apr 2020 22:05:44 +0000 (18:05 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/ckill.sh [new file with mode: 0755]
src/cstart.sh [new file with mode: 0755]

diff --git a/src/ckill.sh b/src/ckill.sh
new file mode 100755 (executable)
index 0000000..3225155
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash -e
+
+# fsid
+if [ -e fsid ] ; then
+    fsid=`cat fsid`
+else
+    echo 'no fsid file, so no cluster?'
+    exit 0
+fi
+echo "fsid $fsid"
+
+sudo ../src/cephadm/cephadm rm-cluster --force --fsid $fsid
+
diff --git a/src/cstart.sh b/src/cstart.sh
new file mode 100755 (executable)
index 0000000..5baf85f
--- /dev/null
@@ -0,0 +1,61 @@
+#!/bin/bash -e
+
+image_base="quay.io/ceph-ci/ceph"
+
+# fsid
+if [ -e fsid ] ; then
+    fsid=`cat fsid`
+else
+    fsid=`uuidgen`
+    echo $fsid > fsid
+fi
+echo "fsid $fsid"
+
+shortid=`echo $fsid | cut -c 1-8`
+echo "shortid $shortid"
+
+# ip
+if [ -z "$ip" ]; then
+    if [ -x "$(which ip 2>/dev/null)" ]; then
+       IP_CMD="ip addr"
+    else
+       IP_CMD="ifconfig"
+    fi
+    # filter out IPv4 and localhost addresses
+    ip="$($IP_CMD | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' | head -n1)"
+    # if nothing left, try using localhost address, it might work
+    if [ -z "$ip" ]; then ip="127.0.0.1"; fi
+fi
+echo "ip $ip"
+
+# port
+if [ -z "$port" ]; then
+    while [ true ]
+    do
+        port="$(echo $(( RANDOM % 1000 + 40000 )))"
+        ss -a -n | grep LISTEN | grep "${ip}:${port} " 1>/dev/null 2>&1 || break
+    done
+fi
+echo "port $port"
+
+# make sure we have an image
+if ! podman image inspect $image_base:$shortid 2>/dev/null; then
+    echo "building initial $image_base:$shortid image..."
+    sudo ../src/script/cpatch -t $image_base:$shortid
+fi
+
+sudo ../src/cephadm/cephadm rm-cluster --force --fsid $fsid
+sudo ../src/cephadm/cephadm --image ${image_base}:${shortid} bootstrap \
+     --skip-pull \
+     --fsid $fsid \
+     --mon-addrv "[v2:$ip:$port]" \
+     --output-dir . \
+     --allow-overwrite
+
+# kludge to make 'bin/ceph ...' work
+sudo chmod 755 ceph.client.admin.keyring
+echo 'keyring = ceph.client.admin.keyring' >> ceph.conf
+
+echo
+echo "sudo ../src/script/cpach -t $image_base:$shortid"
+echo