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, list available Arvados configurations.
21 Save 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, list available arvboxes.
32 Open an Arvados uuid in web browser (http://arvadosapi.com)
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 "Usage: arvswitch name"
65 echo "Available confs:" $((cd $HOME/.config/arvados && ls --indicator-style=none *.conf) | rev | cut -c6- | rev)
70 if [[ -n "$1" ]] ; then
71 touch $HOME/.config/arvados/$1.conf
72 chmod 0600 $HOME/.config/arvados/$1.conf
73 env | grep ARVADOS_ > $HOME/.config/arvados/$1.conf
75 echo "Save current Arvados environment variables to conf file"
76 echo "Usage: arvsave name"
81 if [[ -n "$1" ]] ; then
82 if [[ -f $HOME/.config/arvados/$1.conf ]] ; then
83 rm $HOME/.config/arvados/$1.conf
88 echo "Delete Arvados environment conf"
89 echo "Usage: arvrm name"
94 if [[ -n "$1" ]] ; then
95 if [[ -d $HOME/.arvbox/$1 ]] ; then
96 export ARVBOX_CONTAINER=$1
97 echo "Arvbox switched to $1"
102 if test -z "$ARVBOX_CONTAINER" ; then
103 ARVBOX_CONTAINER=arvbox
105 echo "Switch Arvbox environment conf"
106 echo "Usage: arvboxswitch name"
107 echo "Your current container is: $ARVBOX_CONTAINER"
108 echo "Available confs:" $(cd $HOME/.arvbox && ls --indicator-style=none)
113 if [[ -n "$1" ]] ; then
114 xdg-open https://arvadosapi.com/$1
116 echo "Open Arvados uuid in browser"
117 echo "Usage: arvopen uuid"
122 if [[ -n "$1" ]] ; then
123 xdg-open https://dev.arvados.org/issues/$1
125 echo "Open Arvados issue in browser"
126 echo "Usage: arvissue uuid"