summaryrefslogtreecommitdiffstats
path: root/ceph-menv
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /ceph-menv
parentInitial commit. (diff)
downloadceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz
ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ceph-menv')
-rw-r--r--ceph-menv/.menvrc16
-rw-r--r--ceph-menv/INSTALL19
-rw-r--r--ceph-menv/README21
-rwxr-xr-xceph-menv/build_links.sh16
-rwxr-xr-xceph-menv/mdo.sh16
-rwxr-xr-xceph-menv/mset.sh21
6 files changed, 109 insertions, 0 deletions
diff --git a/ceph-menv/.menvrc b/ceph-menv/.menvrc
new file mode 100644
index 000000000..38f743203
--- /dev/null
+++ b/ceph-menv/.menvrc
@@ -0,0 +1,16 @@
+MENV_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd)"
+
+export PATH=${MENV_ROOT}/bin:$PATH
+alias mset='source $MENV_ROOT/mset.sh'
+
+case "$TERM" in
+xterm-*color)
+ PS1='\[\033[$MRUN_PROMPT_COLOR;1m\]${MRUN_PROMPT}\[\033[00m\]'${PS1}
+ ;;
+*)
+ PS1='${MRUN_PROMPT}'${PS1}
+ ;;
+esac
+
+export MRUN_CEPH_ROOT=$HOME/ceph
+
diff --git a/ceph-menv/INSTALL b/ceph-menv/INSTALL
new file mode 100644
index 000000000..8a9d85b1e
--- /dev/null
+++ b/ceph-menv/INSTALL
@@ -0,0 +1,19 @@
+ceph-menv
+
+Installation
+
+1. Build links
+
+# assuming ceph build directory is at $HOME/ceph/build
+$ cd ceph-menv
+$ ./build_links.sh
+
+A different ceph repository can be passed as the first argument to build_links.sh.
+
+2. Configure shell environment
+
+To your shell startup script (such as $HOME/.bashrc) add the following:
+
+source ~/ceph-menv/.menvrc
+
+(modify line appropriately if ceph-menv was installed at a different location)
diff --git a/ceph-menv/README b/ceph-menv/README
new file mode 100644
index 000000000..badbd3a02
--- /dev/null
+++ b/ceph-menv/README
@@ -0,0 +1,21 @@
+ceph-menv
+
+Environment assistant for use in conjuction with multiple ceph vstart (or more accurately mstart) clusters. Eliminates the need to specify the cluster that is being used with each and every command. Can provide a shell prompt feedback about the currently used cluster.
+
+
+Usage:
+
+$ mset <cluster>
+
+
+For example:
+
+$ mstart.sh c1 -n
+$ mset c1
+[ c1 ] $ ceph -w
+
+
+To un-set cluster:
+
+$ mset
+
diff --git a/ceph-menv/build_links.sh b/ceph-menv/build_links.sh
new file mode 100755
index 000000000..c4c9da34c
--- /dev/null
+++ b/ceph-menv/build_links.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+DIR=`dirname $0`
+ROOT=$1
+
+[ "$ROOT" == "" ] && ROOT="$HOME/ceph"
+
+mkdir -p $DIR/bin
+
+echo $PWD
+for f in `ls $ROOT/build/bin`; do
+ echo $f
+ ln -sf ../mdo.sh $DIR/bin/$f
+done
+
+echo "MRUN_CEPH_ROOT=$ROOT" > $DIR/.menvroot
diff --git a/ceph-menv/mdo.sh b/ceph-menv/mdo.sh
new file mode 100755
index 000000000..443613e63
--- /dev/null
+++ b/ceph-menv/mdo.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+cmd=`basename $0`
+MENV_ROOT=`dirname $0`/..
+
+if [ -f $MENV_ROOT/.menvroot ]; then
+ . $MENV_ROOT/.menvroot
+fi
+
+[ "$MRUN_CEPH_ROOT" == "" ] && MRUN_CEPH_ROOT=$HOME/ceph
+
+if [ "$MRUN_CLUSTER" == "" ]; then
+ ${MRUN_CEPH_ROOT}/build/bin/$cmd "$@"
+ exit $?
+fi
+
+${MRUN_CEPH_ROOT}/src/mrun $MRUN_CLUSTER $cmd "$@"
diff --git a/ceph-menv/mset.sh b/ceph-menv/mset.sh
new file mode 100755
index 000000000..b9cb5b4df
--- /dev/null
+++ b/ceph-menv/mset.sh
@@ -0,0 +1,21 @@
+get_color() {
+ s=$1
+ sum=1 # just so that 'c1' isn't green that doesn't contrast with the rest of my prompt
+ for i in `seq 1 ${#s}`; do
+ c=${s:$((i-1)):1};
+ o=`printf '%d' "'$c"`
+ sum=$((sum+$o))
+ done
+ echo $sum
+}
+
+if [ "$1" == "" ]; then
+ unset MRUN_CLUSTER
+ unset MRUN_PROMPT
+else
+ export MRUN_CLUSTER=$1
+ export MRUN_PROMPT='['${MRUN_CLUSTER}'] '
+ col=$(get_color $1)
+ MRUN_PROMPT_COLOR=$((col%7+31))
+fi
+