Skip to content

Commit

Permalink
add bosh completion
Browse files Browse the repository at this point in the history
  • Loading branch information
ogrand committed Jul 6, 2018
1 parent 179dd5f commit f56e045
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ENV CONTAINER_LOGIN="bosh" CONTAINER_PASSWORD="welcome" \
CF_PLUGINS="CLI-Recorder,doctor,manifest-generator,Statistics,Targets,Usage Report"

ADD scripts/supervisord scripts/check_ssh_security scripts/disable_ssh_password_auth scripts/init-ca scripts/log-bosh scripts/log-cf scripts/log-credhub scripts/log-fly scripts/log-mc scripts/log-openstack scripts/tools /usr/local/bin/
ADD scripts/bosh_completion /etc/bash_completion.d/
ADD supervisord/sshd.conf /etc/supervisor/conf.d/

RUN echo "=====================================================" && \
Expand Down Expand Up @@ -77,6 +78,7 @@ RUN echo "=====================================================" && \
mkdir -p /var/run/sshd /var/log/supervisor /data/shared/tools && \
find /data -print0 | xargs -0 chown ${CONTAINER_LOGIN}:users && \
chmod 700 /home/${CONTAINER_LOGIN} && chown -R ${CONTAINER_LOGIN}:users /home/${CONTAINER_LOGIN} && \
chmod 644 /etc/bash_completion.d/bosh_completion && \
echo "=====================================================" && \
echo "=> Install ops tools" && \
echo "=====================================================" && \
Expand Down
18 changes: 18 additions & 0 deletions scripts/bosh_completion
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#===========================================================================
# bosh cli completion
# This script is installed in "/etc/bash_completion.d/"
#===========================================================================

_bosh2() {
#--- Catch all arguments except the first one
args=("${COMP_WORDS[@]:1:$COMP_CWORD}")

#--- Only split on newlines
local IFS=$'\n'

#--- Call completion (first element of COMP_WORDS is the executable itself)
COMPREPLY=($(GO_FLAGS_COMPLETION=1 ${COMP_WORDS[0]} "${args[@]}"))
return 0
}

complete -o default -F _bosh2 bosh
14 changes: 7 additions & 7 deletions scripts/profile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if [ ! -d ${HOME} ] ; then
fi

#--- Bosh CA cert (on persistant disk)
export BOSH_CA_CERT="/data/shared/tools/certs/server-ca.crt"
export BOSH_CA_CERT="${DATA_SHARED_TOOLS_DIR}/certs/server-ca.crt"

#--- Redefine GIT config file path
export XDG_CONFIG_HOME=${HOME}
Expand Down Expand Up @@ -49,7 +49,7 @@ if [ ! -L ${HOME}/.cf/plugins ] ; then
fi

#--- Redefine Path to binary
export PATH=.:/data/shared/${MY_BOSH_USER}/bin:/data/shared/tools:${PATH}:/usr/local/go/bin:${GOPATH}/bin
export PATH=.:/data/shared/${MY_BOSH_USER}/bin:${DATA_SHARED_TOOLS_DIR}:${PATH}:/usr/local/go/bin:${GOPATH}/bin

#--- Init ".bash_aliases"
echo "#--- Aliases" > ${HOME}/.bash_aliases
Expand All @@ -65,14 +65,14 @@ echo "alias log-openstack='. log-openstack'" >> ${HOME}/.bash_aliases
echo "alias os='openstack'" >> ${HOME}/.bash_aliases

#--- Adapt user prompt and terminal name
if [ -f /data/shared/tools/bosh_cli_env ] ; then
export BOSH_CLI_ENV=`cat /data/shared/tools/bosh_cli_env`
if [ -f ${DATA_SHARED_TOOLS_DIR}/bosh_cli_env ] ; then
export BOSH_CLI_ENV=`cat ${DATA_SHARED_TOOLS_DIR}/bosh_cli_env`
else
if [ ! -d /data/shared/tools ] ; then
mkdir -p /data/shared/tools
if [ ! -d ${DATA_SHARED_TOOLS_DIR} ] ; then
mkdir -p ${DATA_SHARED_TOOLS_DIR}
fi
export BOSH_CLI_ENV="bosh-cli"
echo "${BOSH_CLI_ENV}" > /data/shared/tools/bosh_cli_env
echo "${BOSH_CLI_ENV}" > ${DATA_SHARED_TOOLS_DIR}/bosh_cli_env
fi

echo ". ~/.bashrc" > ${HOME}/.bash_profile
Expand Down

0 comments on commit f56e045

Please sign in to comment.