123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #!/bin/bash
- CONTEXT="$1"; shift
- ARGS=($@)
- if [ "$CONTEXT" = "-c" ]; then
- ARGS_ALL=($@)
- CONTEXT="${ARGS_ALL[0]}"
- ARGS=(${ARGS_ALL[@]:1})
- fi
- RUBYVERSION="${ARGS[0]}"
- CMD="${ARGS[1]}"
- ARGS=(${ARGS[@]:2})
- if [ "$CONTEXT" = "" ]; then
- echo " Error: /opt context is not set" >&2
- exit 2
- fi
- if [ "$RUBYVERSION" = "" ]; then
- echo " Error: Ruby version is not set" >&2
- exit 2
- fi
- run() {
- exec sudo context-chruby-run "$CONTEXT" "$RUBYVERSION" gem $@
- }
- forbidden() {
- echo ' This command is forbidden' >&2
- exit 1
- }
- help() {
- gem help $@ | sed -e 's/ gem/ srv0-gem/g'
- exit 0
- }
- cmd_proc() {
- case "$CMD" in
- install)
- run install $@
- ;;
- list)
- run list $@
- ;;
- env)
- run env $@
- ;;
- build)
- forbidden $@
- ;;
- server)
- forbidden $@
- ;;
- help)
- help $@
- ;;
- "")
- help $@
- ;;
- *)
- #exec gem help
- echo " Unknown or forbidden command $CMD" >&2
- exit 1
- ;;
- esac
- }
- cmd_proc $ARGS
|