25 lines
1.1 KiB
Bash
25 lines
1.1 KiB
Bash
#!/bin/bash
|
|
echo "Gathering you ip for dev container"
|
|
|
|
##############################################################################################
|
|
# en (Ethernet) - ib (InfiniBand) - sl (Serial line IP (slip)) - wl (Wireless local area network (WLAN)) - ww (Wireless wide area network (WWAN))
|
|
#############################################################################################
|
|
your_interface_name="eno"
|
|
interface_prefix="en" # Choose the interface network.
|
|
|
|
# OS 확인
|
|
OS=$(uname)
|
|
|
|
if [[ "$OS" == "Darwin" ]]; then
|
|
# macOS의 경우 ifconfig를 사용하여 인터페이스명 추출
|
|
#iname=$(ifconfig | awk -v p="$interface_prefix" '/^[a-z0-9]+: / {gsub(":", "", $1); if($1 ~ "^"p) print $1}' | head -n1)
|
|
iname='en0'
|
|
ip=$(ifconfig "$iname" | awk '/inet /{print $2}' | head -n1)
|
|
else
|
|
# Linux의 경우 기존 ip 명령어 사용
|
|
iname=$(ip -o link show | sed -rn "/^[0-9]+: $interface_prefix/{s/.: ([^:]*):.*/\1/p}" | head -n1)
|
|
ip=$(ifconfig "$iname" | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | sed 's/inet //g' | head -n1)
|
|
fi
|
|
|
|
echo "REACT_NATIVE_PACKAGER_HOSTNAME=$ip" > .devcontainer/.env
|