/google/devshell/start-shell.sh

1 개요[ | ]

/google/devshell/start-shell.sh
#!/bin/bash
# The start up script for the Devshell. Exports the proper environment
# variables, and then runs a shell. The following arguments are required and
# will set the corresponding environment variables.
# 1 - Client info port
# 2 - Project ID
# 3 - Unused (used to be the Cloud Source Repositories workspace name)
# 4 - Tmux session ID
# 5 - Whether to launch the editor

# TODO(kangy): Clean up once client fully rolls out.
if [ $# -ne 4 -a $# -ne 5 ]; then
  echo "Usage: start-shell.sh <client port> <project ID> <unused> <tmux session ID> <launch orion>" >&2
  exit 1
fi

CLIENT_PORT="$1"
PROJECT_ID="$2"
UNUSED="$3"
TMUX_ID="$4"
UNUSED_LAUNCH_ORION="$5"

export DEVSHELL_CLIENTS_DIR=/var/run/google/devshell
export CLOUDSHELL_OPEN_DIR=cloudshell_open

if [[ -n "$PROJECT_ID" ]]; then
  export DEVSHELL_PROJECT_ID="$PROJECT_ID"
  export GOOGLE_CLOUD_PROJECT=$DEVSHELL_PROJECT_ID
  export GOOGLE_CLOUD_QUOTA_PROJECT=$DEVSHELL_PROJECT_ID
  if [[ -n "$TMUX_ID" ]]; then
    tmux set-env -g DEVSHELL_PROJECT_ID "$PROJECT_ID" >/dev/null 2>&1
    tmux set-env -g GOOGLE_CLOUD_PROJECT "$PROJECT_ID" >/dev/null 2>&1
    tmux set-env -g GOOGLE_CLOUD_QUOTA_PROJECT "$PROJECT_ID" >/dev/null 2>&1
  fi
fi

if  [[ -n "$CLIENT_PORT" ]]; then
  sudo touch ${DEVSHELL_CLIENTS_DIR}/${CLIENT_PORT}
  trap "sudo rm -f ${DEVSHELL_CLIENTS_DIR}/${CLIENT_PORT}" \
       EXIT HUP INT QUIT PIPE TERM

fi

if [[ -n "$TMUX_ID" ]]; then
  tmux new-session -A -D -n "cloudshell" -s "$TMUX_ID"
else
  bash --login
fi

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}