mirror of
https://github.com/logos-storage/logos-storage-testnet-starter.git
synced 2026-01-05 23:13:11 +00:00
Set auto IP (#30)
* Add Codex data-dir and ethereum keypair to the .gitignore * Add get_ip_public and unify all functions syntax * Set Public IP and Bootstrap based on the NETWORK variable, defaults to testnet
This commit is contained in:
parent
6296b07bab
commit
9f7ac4a17c
5
.gitignore
vendored
5
.gitignore
vendored
@ -4,5 +4,10 @@
|
||||
|
||||
# Datadir
|
||||
*-data
|
||||
data_client
|
||||
|
||||
# Ethereum keypair
|
||||
eth.address
|
||||
eth.key
|
||||
|
||||
.DS_Store
|
||||
|
||||
@ -4,13 +4,19 @@ set -e
|
||||
source ./utils.sh
|
||||
|
||||
if [ -z "$LOCALIP" ]; then
|
||||
if [ "${NETWORK}" == "workshop" ]; then
|
||||
LOCALIP=$(get_ip)
|
||||
else
|
||||
LOCALIP=$(get_ip_public)
|
||||
fi
|
||||
fi
|
||||
echo "LOCAL IP: ${LOCALIP}"
|
||||
|
||||
if [ -z "$BOOTSPR" ]; then
|
||||
if [ "${NETWORK}" == "workshop" ]; then
|
||||
# Local network SPR (Workshop NUC):
|
||||
# BOOTSPR="spr:CiUIAhIhAnBsex_7L5xKJQpmAuOtubQEtKsgCOXE2vaJoTJXrprbEgIDARo8CicAJQgCEiECcGx7H_svnEolCmYC4625tAS0qyAI5cTa9omhMleumtsQnbm0tAYaCwoJBMCoWP2RAh-aKkcwRQIhANjwAV9DGFe4zcMUEHjuTsGWAPc7WB7uoSS86HATwouqAiA8dFhsALCSLsQbSOPF1j7NF643oEmPEJAwU9dIwjM6TA"
|
||||
BOOTSPR="spr:CiUIAhIhAnBsex_7L5xKJQpmAuOtubQEtKsgCOXE2vaJoTJXrprbEgIDARo8CicAJQgCEiECcGx7H_svnEolCmYC4625tAS0qyAI5cTa9omhMleumtsQnbm0tAYaCwoJBMCoWP2RAh-aKkcwRQIhANjwAV9DGFe4zcMUEHjuTsGWAPc7WB7uoSS86HATwouqAiA8dFhsALCSLsQbSOPF1j7NF643oEmPEJAwU9dIwjM6TA"
|
||||
else
|
||||
# Cloud-Node-01 SPR:
|
||||
BOOTSPR="spr:CiUIAhIhAiJvIcA_ZwPZ9ugVKDbmqwhJZaig5zKyLiuaicRcCGqLEgIDARo8CicAJQgCEiECIm8hwD9nA9n26BUoNuarCEllqKDnMrIuK5qJxFwIaosQ3d6esAYaCwoJBJ_f8zKRAnU6KkYwRAIgM0MvWNJL296kJ9gWvfatfmVvT-A7O2s8Mxp8l9c8EW0CIC-h-H-jBVSgFjg3Eny2u33qF7BDnWFzo7fGfZ7_qc9P"
|
||||
# All Codex Testnet Cloud Bootstrap Node SPRs:
|
||||
@ -22,6 +28,7 @@ if [ -z "$BOOTSPR" ]; then
|
||||
# BOOTSPR="spr:CiUIAhIhAgybmRwboqDdUJjeZrzh43sn5mp8jt6ENIb08tLn4x01EgIDARo8CicAJQgCEiECDJuZHBuioN1QmN5mvOHjeyfmanyO3oQ0hvTy0ufjHTUQh4ifsAYaCwoJBI_0zSiRAnVsKkcwRQIhAJCb_z0E3RsnQrEePdJzMSQrmn_ooHv6mbw1DOh5IbVNAiBbBJrWR8eBV6ftzMd6ofa5khNA2h88OBhMqHCIzSjCeA"
|
||||
# BOOTSPR="spr:CiUIAhIhAntGLadpfuBCD9XXfiN_43-V3L5VWgFCXxg4a8uhDdnYEgIDARo8CicAJQgCEiECe0Ytp2l-4EIP1dd-I3_jf5XcvlVaAUJfGDhry6EN2dgQsIufsAYaCwoJBNEmoCiRAnV2KkYwRAIgXO3bzd5VF8jLZG8r7dcLJ_FnQBYp1BcxrOvovEa40acCIDhQ14eJRoPwJ6GKgqOkXdaFAsoszl-HIRzYcXKeb7D9"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f eth.key ]; then
|
||||
echo "eth.key does not exist. Please run generate.sh to create it."
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Variables
|
||||
NETWORK="${NETWORK:-testnet}"
|
||||
|
||||
# Function to detect OS
|
||||
get_os() {
|
||||
case "$(uname -s)" in
|
||||
@ -25,18 +28,9 @@ change_permissions() {
|
||||
local permissions="$2"
|
||||
|
||||
case "$OS" in
|
||||
linux|darwin)
|
||||
# Use chmod for Linux and macOS
|
||||
chmod $permissions "$file_path"
|
||||
;;
|
||||
windows)
|
||||
# For Windows, we'll skip changing permissions
|
||||
echo "Skipping permission change on Windows for $file_path"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported OS for changing permissions"
|
||||
return 1
|
||||
;;
|
||||
linux|darwin) chmod $permissions "$file_path" ;;
|
||||
windows) echo "Skipping permission change on Windows for $file_path" ;;
|
||||
*) echo "Unsupported OS for changing permissions"; return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
@ -57,18 +51,16 @@ get_ip_windows() {
|
||||
ipconfig | grep -i "IPv4 Address" | awk '{print $NF}' | head -n 1
|
||||
}
|
||||
|
||||
# Function to get Public IP using ip lookup service
|
||||
get_ip_public() {
|
||||
curl -m 5 -s https://ip.codex.storage
|
||||
}
|
||||
|
||||
# Detect the operating system and call the appropriate function
|
||||
get_ip() {
|
||||
case "$(uname -s)" in
|
||||
Linux*|Darwin*)
|
||||
echo $(get_ip_unix)
|
||||
;;
|
||||
CYGWIN*|MINGW32*|MSYS*|MINGW*)
|
||||
echo $(get_ip_windows)
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported operating system"
|
||||
exit 1
|
||||
;;
|
||||
Linux*|Darwin*) echo $(get_ip_unix) ;;
|
||||
CYGWIN*|MINGW32*|MSYS*|MINGW*) echo $(get_ip_windows) ;;
|
||||
*) echo "Unsupported operating system"; exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user