diff options
Diffstat (limited to 'packages/cern-scripts/resources/lib')
-rw-r--r-- | packages/cern-scripts/resources/lib/activate.inc.sh | 68 | ||||
-rw-r--r-- | packages/cern-scripts/resources/lib/aisadm-fingerprint | 1 | ||||
-rw-r--r-- | packages/cern-scripts/resources/lib/environments.inc.sh | 6 |
3 files changed, 75 insertions, 0 deletions
diff --git a/packages/cern-scripts/resources/lib/activate.inc.sh b/packages/cern-scripts/resources/lib/activate.inc.sh new file mode 100644 index 0000000..79bed6b --- /dev/null +++ b/packages/cern-scripts/resources/lib/activate.inc.sh @@ -0,0 +1,68 @@ + +# non-interactive activate + __activate_env() { + for func in $(typeset -F | cut -f 3 -d ' ' | grep -E '^__env_'); do + if [[ "$func" == "__env_$1" ]]; then + $func + echo "Activated $1" + return 0 + fi + done + echo "Error: Environment not found $1" >&2 + return 1 +} + +# print all defined envs +list_envs() { + for env in $(typeset -F | sed -n -e 's/^declare -f __env_//p'); do + active=false + for env_active in $ENV_ACTIVE; do + if [ "$env_active" == "$env" ]; then + active=true + fi + done + if $active; then + echo -n "${env}* " + else + echo -n "$env " + fi + done + echo "" +} + +plain_list_envs() { + typeset -F | sed -n -e 's/^declare -f __env_//p' +} + +# Interactive activate +activate() { + err=false + for env in $*; do + if ! typeset -F | grep -q -E "^declare -f __env_${env}$"; then + echo "Environment not defined: $env" + err=true + fi + done + if $err; then + return 1 + fi + + for env in $*; do + if typeset -F | grep -q -E "^declare -f __env_${env}$"; then + export ENV_ACTIVE="$ENV_ACTIVE${ENV_ACTIVE:+ }$env" + __env_${env} + fi + done + echo "Active: $ENV_ACTIVE" +} + +# initialization +for env_request in $ENV_ACTIVE; do + __activate_env $env_request +done + +# bash-completion for `activate' +_activate() { + _init_completion -s || return + COMPREPLY=( $(compgen -W "$(list_envs)" -- $cur) ) +} && complete -F _activate activate diff --git a/packages/cern-scripts/resources/lib/aisadm-fingerprint b/packages/cern-scripts/resources/lib/aisadm-fingerprint new file mode 100644 index 0000000..23becf9 --- /dev/null +++ b/packages/cern-scripts/resources/lib/aisadm-fingerprint @@ -0,0 +1 @@ +|1|OsR/sAjrVPr+fcFcuD9RvXs5VdQ=|WV2xLsZ+NDr54Iuyxcl8sghHhtM= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4bg2L316l/5zs7S7hE69fev4tWYczJy/Yf2AI1rhG5j1+EXZKMnCUkm1bpZUNu8g2fzg/P6wPSTQyZmc7ieQaKoiz69ZQ2mr+bIi2ET+50DDO9ZzrVFnKeOzs669fSfWp3Y7o8ubTRx5t/nLrMTxSDUQxXitk1UV5mosE5yzlJ665zlEE8+rVsqhhBC7bfg2lJR5HptxpCR9kVSyLkHydEXC8WltW06bpBHEuvKWAkAMMfftOHowWLCEslOFUirpjR65uqK+da9v3SfUvOYF8JZCrw7yDutyx5bzqFVS3N39T/7QPGJLYRJip1DPh8OvtPOPLLbdPY76NrodmRn9aw== diff --git a/packages/cern-scripts/resources/lib/environments.inc.sh b/packages/cern-scripts/resources/lib/environments.inc.sh new file mode 100644 index 0000000..517f500 --- /dev/null +++ b/packages/cern-scripts/resources/lib/environments.inc.sh @@ -0,0 +1,6 @@ +__env_java8() { + export JAVA_HOME=/usr/lib/jvm/java-8.66-oraclejdk/ + export PATH=$JAVA_HOME/bin:$PATH + + +}
\ No newline at end of file |