Skip to content

Commit c36fed8

Browse files
committed
fix: #239 ip address selection
1 parent d82db3d commit c36fed8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Diff for: scripts/self-hosted/install-server.sh

+8-2
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ choose_ip_address() {
144144
header "$prompt"
145145
echo "$help_text"
146146

147+
if [ ${#ip_array[@]} -eq 0 ]; then
148+
echo "$(red "No IP addresses found.")"
149+
echo "$(red "Please check your network configuration.")"
150+
exit 1
151+
fi
152+
147153
if [ ${#ip_array[@]} -eq 1 ]; then
148154
local chosen_ip="${ip_array[0]}"
149155
echo -e "$(green "Only one IP address available:") $(cyan "$chosen_ip")\n"
@@ -156,7 +162,7 @@ choose_ip_address() {
156162
echo "$(gray "(Enter the number of your choice)")"
157163

158164
while true; do
159-
read -p "$(green ">") " choice
165+
read -r -p "$(green ">") " choice
160166
if [[ "$choice" =~ ^[0-9]+$ ]] && [ "$choice" -ge 1 ] && [ "$choice" -le "${#ip_array[@]}" ]; then
161167
local chosen_ip="${ip_array[$((choice-1))]}"
162168
echo -e "\n$(green "You selected:") $(cyan "$chosen_ip")\n"
@@ -214,7 +220,7 @@ get_user_credentials() {
214220
echo -e "\n$(green "Credentials saved successfully.")"
215221
}
216222

217-
IP_LIST=$(/tmp/ptah-agent list-ips)
223+
IP_LIST="$(/tmp/ptah-agent list-ips | tr -d '\n')"
218224
choose_ip_address "$IP_LIST" "Advertised IP addresses" "ADVERTISE_ADDR" "$ADVERTISED_IP_HELP"
219225
choose_ip_address "$IP_LIST" "Public IP address" "PUBLIC_IP" "$PUBLIC_IP_HELP"
220226

0 commit comments

Comments
 (0)