|
| 1 | +#!/bin/bash |
| 2 | +# Copyright (c) 2021 Oracle Corporation |
| 3 | +# Licensed under the Universal Permissive License v 1.0 |
| 4 | +# as shown at https://oss.oracle.com/licenses/upl/ |
| 5 | + |
| 6 | +save_oracle_path="$ORACLE_PATH" |
| 7 | + |
| 8 | +. oltp-setup-env |
| 9 | + |
| 10 | +# This shell script will return the credentials for the specified connection |
| 11 | +# |
| 12 | + |
| 13 | +# History |
| 14 | +# |
| 15 | +# 4-jun-2024 bengsig Created |
| 16 | +help=no |
| 17 | +side2=no |
| 18 | +username='' |
| 19 | +password='' |
| 20 | +usage="Usage: $commandname [-2] [-b|--batch] [-p|--pool] [-H|--help] [-C|--cruser] [-A|--awr] [-S|--system] [-R|--results] [-r|--run] [-a|--aw] [-o|--oe]" |
| 21 | + |
| 22 | +# Get directory names from parameters.rwl |
| 23 | + |
| 24 | +eval `rwloadsim -q parameters2shell.rwl` |
| 25 | + |
| 26 | +export ORACLE_PATH="$save_oracle_path" |
| 27 | + |
| 28 | +options='2pbhHASCRrao -l cruser,help,awr,system,results,run,aw,oe,batch,pool' |
| 29 | + |
| 30 | +if getopt -Q -o $options -- "$@" |
| 31 | +then |
| 32 | + : |
| 33 | +else |
| 34 | + # output something likely to cause proper errors in |
| 35 | + # actual utility if $(oltpconnect) is given invalid options |
| 36 | + tty -s <&1 || echo unknown/{password}@unknown |
| 37 | + exit 1 |
| 38 | +fi |
| 39 | + |
| 40 | +set -- `getopt -u -n $commandname -o $options -- "$@"` |
| 41 | + |
| 42 | +while test $1 != '--' |
| 43 | +do |
| 44 | + case $1 in |
| 45 | + --system|-S) |
| 46 | + username=$system_username |
| 47 | + password=$system_password |
| 48 | + connect=$system_connect |
| 49 | + shift |
| 50 | + ;; |
| 51 | + --awr|-A) |
| 52 | + username=$sysawr_username |
| 53 | + password=$sysawr_password |
| 54 | + connect=$sysawr_connect |
| 55 | + shift |
| 56 | + ;; |
| 57 | + --cruser|-C) |
| 58 | + username=$cruser_username |
| 59 | + password=$cruser_password |
| 60 | + connect=$cruser_connect |
| 61 | + shift |
| 62 | + ;; |
| 63 | + --oe|-o) |
| 64 | + username=$rwl_oe_username |
| 65 | + password=$rwl_oe_password |
| 66 | + shift |
| 67 | + ;; |
| 68 | + --aw|-a) |
| 69 | + username=$rwl_aw1_username |
| 70 | + password=$rwl_aw1_password |
| 71 | + shift |
| 72 | + ;; |
| 73 | + --run|-r) |
| 74 | + username=$rwl_run1_username |
| 75 | + password=$rwl_run1_password |
| 76 | + shift |
| 77 | + ;; |
| 78 | + --results|-R) |
| 79 | + username=$results_username |
| 80 | + password=$results_password |
| 81 | + connect=$results_connect |
| 82 | + shift |
| 83 | + ;; |
| 84 | + -b|--batch) |
| 85 | + if test -z "$connect" |
| 86 | + then |
| 87 | + connect=$batch_connect |
| 88 | + fi |
| 89 | + shift |
| 90 | + ;; |
| 91 | + -p|--pool) |
| 92 | + if test -z "$connect" |
| 93 | + then |
| 94 | + connect=$pool_connect |
| 95 | + fi |
| 96 | + shift |
| 97 | + ;; |
| 98 | + -2) |
| 99 | + side2=yes; |
| 100 | + shift; |
| 101 | + ;; |
| 102 | + --help|-H|-h) help=yes; shift; |
| 103 | + ;; |
| 104 | + esac |
| 105 | +done |
| 106 | + |
| 107 | +if test x$help = xyes |
| 108 | +then |
| 109 | + echo "$usage" |
| 110 | +cat <<END |
| 111 | +-H : Show this help |
| 112 | +-A --awr : Return credentials for the user doing awr etc |
| 113 | +-S --system : Return credentials for the user running v$ queries etc |
| 114 | +-C --cruser : Return credentials for the user creating schemas |
| 115 | +-R --results : Return credentials for your repository user |
| 116 | +-r --run : Return credentials for the normal runtime user |
| 117 | +-a --aw : Return credentials for the user owning the artificial workload tables |
| 118 | +-o --oe : Return credentials for the user owning the order entry tables |
| 119 | +-2 : Use side 2 as used by oltpforever2 for -r, or -a |
| 120 | +-p --pool : Use the pool_connect connect string rather than normal_connect |
| 121 | + for -r, -o, -a |
| 122 | +-b --batch : Use the batch_connect connect string rather than normal_connect |
| 123 | + for -r, -o, -a |
| 124 | +END |
| 125 | + exit |
| 126 | +fi |
| 127 | + |
| 128 | +if test -z "$username" |
| 129 | +then |
| 130 | + # use --run as default |
| 131 | + username=$rwl_run1_username |
| 132 | + password=$rwl_run1_password |
| 133 | +fi |
| 134 | + |
| 135 | +# If no connect, it must be the normal |
| 136 | +if test -z "$connect" |
| 137 | +then |
| 138 | + connect=$normal_connect |
| 139 | +fi |
| 140 | + |
| 141 | +if test $side2 = yes |
| 142 | +then |
| 143 | + # Change the username/password |
| 144 | + if test $username = $rwl_run1_username |
| 145 | + then |
| 146 | + username=$rwl_run2_username |
| 147 | + password=$rwl_run2_password |
| 148 | + fi |
| 149 | + if test $username = $rwl_aw1_username |
| 150 | + then |
| 151 | + username=$rwl_aw2_username |
| 152 | + password=$rwl_aw2_password |
| 153 | + fi |
| 154 | +fi |
| 155 | + |
| 156 | +if tty -s <&1 |
| 157 | +then |
| 158 | + echo $username/@$connect |
| 159 | +else |
| 160 | + echo $username/$password@$connect |
| 161 | +fi |
0 commit comments