2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: AGPL-3.0
6 # bash functions for managing Arvados tokens and other conveniences.
8 read -rd "\000" helpmessage <<EOF
9 $(basename $0): bash functions for managing Arvados tokens and other shortcuts.
12 . $0 # activate for current shell
13 $0 --install # install into .bashrc
16 Set ARVADOS_API_HOST and ARVADOS_API_TOKEN in the current environment based on
17 $HOME/.config/arvados/<name>.conf
18 With no arguments, print current API host and available Arvados configurations.
21 Save current values of ARVADOS_API_HOST and ARVADOS_API_TOKEN in the current environment to
22 $HOME/.config/arvados/<name>.conf
25 Delete $HOME/.config/arvados/<name>.conf
28 Set ARVBOX_CONTAINER to <name>
29 With no arguments, print current arvbox and available arvboxes.
32 Open an Arvados uuid in web browser (http://arvadosapi.com)
34 arvissue <issue number>
35 Open an Arvados ticket in web browser (http://dev.arvados.org)
39 if [[ "$1" = "--install" ]] ; then
40 this=$(readlink -f $0)
41 if ! grep ". $this" ~/.bashrc >/dev/null ; then
42 echo ". $this" >> ~/.bashrc
43 echo "Installed into ~/.bashrc"
45 echo "Already installed in ~/.bashrc"
47 elif ! [[ $0 =~ bash$ ]] ; then
51 HISTIGNORE=$HISTIGNORE:'export ARVADOS_API_TOKEN=*'
54 if [[ -n "$1" ]] ; then
55 if [[ -f $HOME/.config/arvados/$1.conf ]] ; then
56 unset ARVADOS_API_HOST_INSECURE
57 for a in $(cat $HOME/.config/arvados/$1.conf) ; do export $a ; done
63 echo "Switch Arvados environment conf"
64 echo "Current host: ${ARVADOS_API_HOST}"
65 echo "Usage: arvswitch <name>"
66 echo "Available confs:" $((cd $HOME/.config/arvados && ls --indicator-style=none *.conf) | rev | cut -c6- | rev)
71 if [[ -n "$1" ]] ; then
72 touch $HOME/.config/arvados/$1.conf
73 chmod 0600 $HOME/.config/arvados/$1.conf
74 env | grep ARVADOS_ > $HOME/.config/arvados/$1.conf
76 echo "Save current Arvados environment variables to conf file"
77 echo "Usage: arvsave <name>"
82 if [[ -n "$1" ]] ; then
83 if [[ -f $HOME/.config/arvados/$1.conf ]] ; then
84 rm $HOME/.config/arvados/$1.conf
89 echo "Delete Arvados environment conf"
90 echo "Usage: arvrm <name>"
95 if [[ -n "$1" ]] ; then
96 export ARVBOX_CONTAINER=$1
97 if [[ -d $HOME/.arvbox/$1 ]] ; then
98 echo "Arvbox switched to $1"
100 echo "Warning: $1 doesn't exist, will be created."
103 if test -z "$ARVBOX_CONTAINER" ; then
104 ARVBOX_CONTAINER=arvbox
106 echo "Switch Arvbox environment conf"
107 echo "Your current container is: $ARVBOX_CONTAINER"
108 echo "Usage: arvboxswitch <name>"
109 echo "Available confs:" $(cd $HOME/.arvbox && ls --indicator-style=none)
114 if [[ -n "$1" ]] ; then
115 xdg-open https://arvadosapi.com/$1
117 echo "Open Arvados uuid in browser"
118 echo "Usage: arvopen <uuid>"
123 if [[ -n "$1" ]] ; then
124 xdg-open https://dev.arvados.org/issues/$1
126 echo "Open Arvados issue in browser"
127 echo "Usage: arvissue <issue number>"