|
2 | 2 | set -e |
3 | 3 | set -o pipefail |
4 | 4 |
|
5 | | -readonly VER=2.1.2 |
| 5 | +readonly VER=2.1.3 |
6 | 6 |
|
7 | 7 | # Remove the longest `*/` prefix |
8 | 8 | readonly SCRIPT_NAME_WITH_EXT="${0##*/}" |
@@ -150,10 +150,14 @@ if [[ $port ]]; then |
150 | 150 | # `--ssh-public-key-file` is required |
151 | 151 | # `--target-private-ip` "${OCI_INSTANCE}" |
152 | 152 | # shellcheck disable=SC2086 # $PROFILE_OPT is a two-word CLI option |
153 | | - session_ocid=$(time oci bastion session create-port-forwarding $PROFILE_OPT --bastion-id "$OCI_BASTION_OCID" \ |
154 | | - --target-resource-id "$OCI_INSTANCE_OCID" --target-port "$port" \ |
155 | | - --session-ttl $MAX_TTL --ssh-public-key-file $SSH_PUB_KEY --wait-for-state SUCCEEDED --wait-for-state FAILED \ |
156 | | - --wait-interval-seconds $CHECK_INTERVAL_SEC | jq --raw-output '.data.resources[0].identifier') |
| 153 | + session_ocid=$(time ( # `time` prints to stderr so it does not interfere with the pipe |
| 154 | + oci bastion session create-port-forwarding $PROFILE_OPT --bastion-id "$OCI_BASTION_OCID" \ |
| 155 | + --target-resource-id "$OCI_INSTANCE_OCID" --target-port "$port" --session-ttl $MAX_TTL \ |
| 156 | + --ssh-public-key-file $SSH_PUB_KEY --wait-for-state SUCCEEDED --wait-for-state FAILED \ |
| 157 | + --wait-interval-seconds $CHECK_INTERVAL_SEC | jq --raw-output '.data.resources[0].identifier'; |
| 158 | + >&2 printf "It took:" |
| 159 | + ) |
| 160 | + ) |
157 | 161 | echo "Created the bastion port forwarding session: $session_ocid" |
158 | 162 |
|
159 | 163 | # shellcheck disable=SC2086 # $PROFILE_OPT is a two-word CLI option |
@@ -183,10 +187,14 @@ if [[ $HOST_USER ]]; then |
183 | 187 | # `--wait-interval-seconds`: state check interval (defaults to 30 seconds). |
184 | 188 | # `--ssh-public-key-file` is required |
185 | 189 | # shellcheck disable=SC2086 # $PROFILE_OPT is a two-word CLI option |
186 | | - session_ocid=$(time oci bastion session create-managed-ssh $PROFILE_OPT --bastion-id "$OCI_BASTION_OCID" \ |
187 | | - --target-resource-id "$OCI_INSTANCE_OCID" --target-os-username "$HOST_USER" --session-ttl $MAX_TTL \ |
188 | | - --ssh-public-key-file $SSH_PUB_KEY --wait-for-state SUCCEEDED --wait-for-state FAILED \ |
189 | | - --wait-interval-seconds $CHECK_INTERVAL_SEC | jq --raw-output '.data.resources[0].identifier') |
| 190 | + session_ocid=$(time ( # `time` prints to stderr so it does not interfere with the pipe |
| 191 | + oci bastion session create-managed-ssh $PROFILE_OPT --bastion-id "$OCI_BASTION_OCID" \ |
| 192 | + --target-resource-id "$OCI_INSTANCE_OCID" --target-os-username "$HOST_USER" --session-ttl $MAX_TTL \ |
| 193 | + --ssh-public-key-file $SSH_PUB_KEY --wait-for-state SUCCEEDED --wait-for-state FAILED \ |
| 194 | + --wait-interval-seconds $CHECK_INTERVAL_SEC | jq --raw-output '.data.resources[0].identifier'; |
| 195 | + >&2 printf "It took:" |
| 196 | + ) |
| 197 | + ) |
190 | 198 | echo "Created the bastion session: $session_ocid" |
191 | 199 |
|
192 | 200 | # shellcheck disable=SC2086 # $PROFILE_OPT is a two-word CLI option |
|
0 commit comments