@@ -85,7 +85,54 @@ update_env() {
8585 fi
8686}
8787
88- CURRENT_HOST=$( hostname -i)
88+ CURRENT_HOST=" 127.0.0.1"
89+ # Function to get IP address on Ubuntu/CentOS using ip command
90+ get_linux_ip () {
91+ local interface=$( ip route | awk ' /^default/ { print $5 }' )
92+ if [ -n " $interface " ]; then
93+ CURRENT_HOST=$( ip addr show $interface | grep ' inet\b' | grep -v 127.0.0.1 | awk ' {print $2}' | cut -d/ -f1 | head -n 1)
94+ else
95+ echo " Failed to get local route interface, so use 127.0.0.1 as default host ip."
96+ fi
97+ }
98+
99+ # Function to get IP address on macOS using ifconfig command
100+ get_mac_ip () {
101+ local default_interface=$( route -n get default | awk ' /interface:/ {print $2}' )
102+
103+ if [ -z " $default_interface " ]; then
104+ echo " Failed to get local route interface, so use 127.0.0.1 as default host ip."
105+ return
106+ fi
107+
108+ CURRENT_HOST=$( ifconfig " $default_interface " | grep " inet " | grep -v 127.0.0.1 | awk ' {print $2}' )
109+
110+ }
111+
112+ get_local_ip () {
113+
114+ # Determine the OS and call the appropriate function
115+ case " $( uname) " in
116+ Darwin)
117+ # macOS
118+ get_mac_ip
119+ ;;
120+ Linux)
121+ get_linux_ip
122+ ;;
123+ * )
124+ echo " Failed to get to know host's os, so use 127.0.0.1 as default host ip."
125+ CURRENT_HOST=" 127.0.0.1"
126+ ;;
127+ esac
128+
129+ }
130+
131+ get_local_ip
132+ if [ -z " $CURRENT_HOST " ]; then
133+ echo " Failed to get local ip, so use 127.0.0.1 as default host ip."
134+ CURRENT_HOST=" 127.0.0.1"
135+ fi
89136
90137print_message " info" " Please fill in the database parameters:"
91138
@@ -119,6 +166,35 @@ else
119166 fi
120167fi
121168
169+ check_db_link_params () {
170+ if [ -z " $DB_HOST " ]; then
171+ print_message " error" " ERROR: Database Host is not set"
172+ exit 1
173+ fi
174+ if [ -z " $DB_PORT " ]; then
175+ print_message " error" " ERROR: Database Port is not set"
176+ exit 1
177+ fi
178+ if [ -z " $DB_USERNAME " ]; then
179+ print_message " error" " ERROR: Database Username is not set"
180+ exit 1
181+ fi
182+ if [ -z " $DB_PASSWORD " ]; then
183+ print_message " error" " ERROR: Database Password is not set"
184+ exit 1
185+ fi
186+ if [ -z " $DB_DATABASE " ]; then
187+ print_message " error" " ERROR: Database Name is not set"
188+ exit 1
189+ fi
190+ if [ -z " $DB_PLUGIN_DATABASE " ]; then
191+ print_message " error" " ERROR: Plugin Database Name is not set"
192+ exit 1
193+ fi
194+ }
195+
196+ check_db_link_params
197+
122198if [ " $USE_AS_VECTOR_STORE " == " Y" ]; then
123199 update_env " OCEANBASE_VECTOR_HOST" " $DB_HOST "
124200 update_env " OCEANBASE_VECTOR_PORT" " $DB_PORT "
@@ -187,3 +263,6 @@ print_message "success" "\nDatabase parameters are written into .env successfull
187263
188264print_message " success" " \nConnect to metadata database:"
189265print_message " success" " \n mysql -h$DB_HOST -P$DB_PORT -u$DB_USERNAME -p$DB_PASSWORD -D$DB_DATABASE "
266+
267+
268+
0 commit comments