-
Notifications
You must be signed in to change notification settings - Fork 29
/
juju-activate
executable file
·44 lines (38 loc) · 1.36 KB
/
juju-activate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash -i
#
# Copyright 2014 Marco Ceppi <[email protected]>
#
# juju-list is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# juju-activate is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# For a full copy of the GNU General Public License, see
# <http://www.gnu.org/licenses/>.
# This is a script for a juju plugin to activate a specific environment.
set -e
if [ ! "$1" ]; then
echo "Need to supply an environment" >&2
exit 1
fi
if [ "$1" == '--description' ]; then
echo "Sets the JUJU_ENV to the requested Juju environment and updates the prompt."
exit 0
fi
if [ "$1" == '--help' ]; then
echo "juju activate <juju-env>"
echo ""
echo "Set the JUJU_ENV to the requested Juju environment and update the command prompt."
exit 0
fi
if ! juju switch -l | grep "$1" > /dev/null; then
echo "Environment does not exist; Have you executed `juju init` and edited ~/.juju/environments.yaml?" >&2
exit 1
fi
echo "Activating $1, to end session type 'exit'"
env PS1="($1)$PS1" JUJU_ENV="$1" bash --norc -i