2 # bash functions for managing Arvados tokens and other conveniences.
4 read -rd "\000" helpmessage <<EOF
5 $(basename $0): bash functions for managing Arvados tokens and other shortcuts.
8 . $0 # activate for current shell
9 $0 --install # install into .bashrc
12 Set ARVADOS_API_HOST and ARVADOS_API_TOKEN in the current environment based on
13 $HOME/.config/arvados/<name>.conf
14 With no arguments, list available Arvados configurations.
17 Save values of ARVADOS_API_HOST and ARVADOS_API_TOKEN in the current environment to
18 $HOME/.config/arvados/<name>.conf
21 Delete $HOME/.config/arvados/<name>.conf
24 Set ARVBOX_CONTAINER to <name>
25 With no arguments, list available arvboxes.
28 Open an Arvados uuid in web browser (http://curover.se)
31 Open an Arvados ticket in web browser (http://dev.arvados.org)
35 if [[ "$1" = "--install" ]] ; then
36 this=$(readlink -f $0)
37 if ! grep ". $this" ~/.bashrc >/dev/null ; then
38 echo ". $this" >> ~/.bashrc
39 echo "Installed into ~/.bashrc"
41 echo "Already installed in ~/.bashrc"
43 elif ! [[ $0 =~ bash$ ]] ; then
47 HISTIGNORE=$HISTIGNORE:'export ARVADOS_API_TOKEN=*'
50 if [[ -n "$1" ]] ; then
51 if [[ -f $HOME/.config/arvados/$1.conf ]] ; then
52 unset ARVADOS_API_HOST_INSECURE
53 for a in $(cat $HOME/.config/arvados/$1.conf) ; do export $a ; done
59 echo "Switch Arvados environment conf"
60 echo "Usage: arvswitch name"
61 echo "Available confs:" $((cd $HOME/.config/arvados && ls --indicator-style=none *.conf) | rev | cut -c6- | rev)
66 if [[ -n "$1" ]] ; then
67 touch $HOME/.config/arvados/$1.conf
68 chmod 0600 $HOME/.config/arvados/$1.conf
69 env | grep ARVADOS_ > $HOME/.config/arvados/$1.conf
71 echo "Save current Arvados environment variables to conf file"
72 echo "Usage: arvsave name"
77 if [[ -n "$1" ]] ; then
78 if [[ -f $HOME/.config/arvados/$1.conf ]] ; then
79 rm $HOME/.config/arvados/$1.conf
84 echo "Delete Arvados environment conf"
85 echo "Usage: arvrm name"
90 if [[ -n "$1" ]] ; then
91 if [[ -d $HOME/.arvbox/$1 ]] ; then
92 export ARVBOX_CONTAINER=$1
93 echo "Arvbox switched to $1"
98 if test -z "$ARVBOX_CONTAINER" ; then
99 ARVBOX_CONTAINER=arvbox
101 echo "Switch Arvbox environment conf"
102 echo "Usage: arvboxswitch name"
103 echo "Your current container is: $ARVBOX_CONTAINER"
104 echo "Available confs:" $(cd $HOME/.arvbox && ls --indicator-style=none)
109 if [[ -n "$1" ]] ; then
110 xdg-open https://curover.se/$1
112 echo "Open Arvados uuid in browser"
113 echo "Usage: arvopen uuid"
118 if [[ -n "$1" ]] ; then
119 xdg-open https://dev.arvados.org/issues/$1
121 echo "Open Arvados issue in browser"
122 echo "Usage: arvissue uuid"