Project

General

Profile

Arvswitch » History » Version 7

Peter Amstutz, 03/03/2016 06:57 PM

1 1 Peter Amstutz
h1. Arvswitch
2
3
Copy this into your @.bashrc@ or create a new file called something like "arvswitch.sh" and add the line ". arvswitch.sh" to your @.bashrc@
4
5
<pre>
6
HISTIGNORE=$HISTIGNORE:'export ARVADOS_API_TOKEN=*'
7
8
arvswitch() {
9
    if [[ -n "$1" ]] ; then
10
        if [[ -f $HOME/.config/arvados/$1.conf ]] ; then
11 3 Peter Amstutz
            unset ARVADOS_API_HOST_INSECURE
12 1 Peter Amstutz
            for a in $(cat $HOME/.config/arvados/$1.conf) ; do export $a ; done
13 7 Peter Amstutz
            echo "Switched to $1"
14 1 Peter Amstutz
        else
15
            echo "$1 unknown"
16
        fi
17
    else
18
        echo "Switch Arvados environment conf"
19
        echo "Usage: arvswitch name"
20 7 Peter Amstutz
        echo "Available confs:" $((cd $HOME/.config/arvados && ls --indicator-style=none *.conf) | rev | cut -c6- | rev)
21 1 Peter Amstutz
    fi
22
}
23
24
arvsave() {
25
    if [[ -n "$1" ]] ; then
26 7 Peter Amstutz
	touch $HOME/.config/arvados/$1.conf
27
	chmod 0600 $HOME/.config/arvados/$1.conf
28 5 Peter Amstutz
        env | grep ARVADOS_ > $HOME/.config/arvados/$1.conf
29 1 Peter Amstutz
    else
30
        echo "Save current Arvados environment variables to conf file"
31
        echo "Usage: arvsave name"
32
    fi
33
}
34
35
arvrm() {
36
    if [[ -n "$1" ]] ; then
37
        if [[ -f $HOME/.config/arvados/$1.conf ]] ; then
38
            rm $HOME/.config/arvados/$1.conf
39
        else
40
            echo "$1 unknown"
41
        fi
42
    else
43
        echo "Delete Arvados environment conf"
44
        echo "Usage: arvrm name"
45 7 Peter Amstutz
    fi
46
}
47
48
arvboxswitch() {
49
    if [[ -n "$1" ]] ; then
50
        if [[ -d $HOME/.arvbox/$1 ]] ; then
51
            export ARVBOX_CONTAINER=$1
52
            echo "Arvbox switched to $1"
53
        else
54
            echo "$1 unknown"
55
        fi
56
    else
57
        if test -z "$ARVBOX_CONTAINER" ; then
58
            ARVBOX_CONTAINER=arvbox
59
        fi
60
        echo "Switch Arvbox environment conf"
61
        echo "Usage: arvboxswitch name"
62
        echo "Your current container is: $ARVBOX_CONTAINER"
63
        echo "Available confs:" $(cd $HOME/.arvbox && ls --indicator-style=none)
64
    fi
65
}
66
67
arvopen() {
68
    if [[ -n "$1" ]] ; then
69
        xdg-open https://curover.se/$1
70
    else
71
        echo "Open Arvados uuid in browser"
72
        echo "Usage: arvopen uuid"
73 1 Peter Amstutz
    fi
74
}
75
</pre>
76 6 Ward Vandewege
77
h2. Alternatives
78
79
See DJB's "envdir":http://cr.yp.to/daemontools/envdir.html