From e86dd6fb12c657e927ae2479b541e7ea04a5f8d0 Mon Sep 17 00:00:00 2001 From: gryf Date: Thu, 6 May 2021 14:49:45 +0200 Subject: [PATCH] Move out search for firts ip to the separate script. --- bootstrap.sh | 11 ----------- get_first_dev_ip.sh | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) create mode 100755 get_first_dev_ip.sh diff --git a/bootstrap.sh b/bootstrap.sh index a47ae1b..aa85264 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -277,16 +277,6 @@ common_conf() { cp "${DIR}/.gitconfig" ~/ cp "${DIR}/cleanup.sh" ~/ - for i in $(seq 0 3); do - ifname=$(ip -j a|jq -r .[$i].ifname) - if [[ "${ifname}" = "lo" ]]; then - continue - fi - ipaddr=$(ip -j a|jq -r \ - ".[$i].addr_info[] | select(.family == \"inet\") | .local") - break; - done - { echo 'source ~/.bash_prompt' echo "alias ipc='ip -c'" @@ -299,7 +289,6 @@ common_conf() { echo "if which kubectl 2>/dev/null >/dev/null; then" echo " source <(kubectl completion bash)" echo "fi" - echo "export HOST_IP=${ipaddr}" } >> ~/.bashrc if [ ! -d ~/.vim ]; then diff --git a/get_first_dev_ip.sh b/get_first_dev_ip.sh new file mode 100755 index 0000000..b216765 --- /dev/null +++ b/get_first_dev_ip.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +for i in $(seq 0 3); do + ifname=$(ip -j a|jq -r .[$i].ifname) + if [[ "${ifname}" = "lo" ]]; then + continue + fi + echo $(ip -j a|jq -r \ + ".[$i].addr_info[] | select(.family == \"inet\") | .local") + break; +done