From 1e9b2d599cb6f20d7067910915e8f1d959d08e7e Mon Sep 17 00:00:00 2001 From: Rodolfo Carvalho Date: Sun, 24 May 2015 14:32:06 +0200 Subject: [PATCH] Add script to run command in container --- scripts/run-in-container.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 scripts/run-in-container.sh diff --git a/scripts/run-in-container.sh b/scripts/run-in-container.sh new file mode 100755 index 0000000..a60c8cd --- /dev/null +++ b/scripts/run-in-container.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Use this script to run one-off commands inside a container of a pod +# (where your application code lives in) +# +# Examples: +# ./run-in-container.sh web date +# ./run-in-container.sh database env +# ./run-in-container.sh web ./manage.py migrate +# ./run-in-container.sh web ./manage.py createsuperuser +# ./run-in-container.sh web tail -f access.log +# POD_INDEX=1 ./run-in-container.sh web tail -f access.log + +POD_NAME="$1" +if [[ -z "$POD_NAME" ]]; then + echo "missing pod name" + exit 1 +fi +shift + +quoted_args="$(printf " %q" "${@:-echo}")" +osc exec -p $(osc get pods -l "name=$POD_NAME" -t "{{ with index .items ${POD_INDEX:-0} }}{{ .metadata.name }}{{ end }}") -it -- bash -c "cd \$HOME && scl enable python33 \"$quoted_args\"" +