mirror of https://github.com/OpenVidu/openvidu.git
Docker build: single discover_my_public_ip.sh script
parent
b5e1ce6b1f
commit
3bebe99ee5
|
@ -5,7 +5,7 @@ RUN apt-get update \
|
||||||
|
|
||||||
COPY ./configuration-files.sh /tmp/
|
COPY ./configuration-files.sh /tmp/
|
||||||
COPY ./entrypoint.sh /usr/local/bin
|
COPY ./entrypoint.sh /usr/local/bin
|
||||||
COPY ./discover_my_public_ip.sh /usr/local/bin
|
COPY ../utils/discover_my_public_ip.sh /usr/local/bin
|
||||||
|
|
||||||
RUN chmod +x /tmp/configuration-files.sh \
|
RUN chmod +x /tmp/configuration-files.sh \
|
||||||
&& chmod +x /usr/local/bin/entrypoint.sh \
|
&& chmod +x /usr/local/bin/entrypoint.sh \
|
||||||
|
|
|
@ -13,7 +13,7 @@ COPY ./default.conf /etc/nginx/conf.d/default.conf
|
||||||
COPY ./default_nginx_conf /default_nginx_conf
|
COPY ./default_nginx_conf /default_nginx_conf
|
||||||
|
|
||||||
# Entrypoint and discover public ip scripts
|
# Entrypoint and discover public ip scripts
|
||||||
COPY ./discover_my_public_ip.sh /usr/local/bin
|
COPY ../utils/discover_my_public_ip.sh /usr/local/bin
|
||||||
COPY ./entrypoint.sh /usr/local/bin
|
COPY ./entrypoint.sh /usr/local/bin
|
||||||
|
|
||||||
RUN mkdir -p /var/www/certbot && \
|
RUN mkdir -p /var/www/certbot && \
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Check if a txt is a valid ip
|
|
||||||
function valid_ip()
|
|
||||||
{
|
|
||||||
local ip=$1
|
|
||||||
local stat=1
|
|
||||||
|
|
||||||
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
|
||||||
OIFS=$IFS
|
|
||||||
IFS='.'
|
|
||||||
ip=($ip)
|
|
||||||
IFS=$OIFS
|
|
||||||
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
|
|
||||||
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
|
|
||||||
stat=$?
|
|
||||||
fi
|
|
||||||
return $stat
|
|
||||||
}
|
|
||||||
|
|
||||||
# Services to get public ip
|
|
||||||
SERVICES=(
|
|
||||||
"curl --silent -sw :%{http_code} ipv4.icanhazip.com"
|
|
||||||
"curl --silent -sw :%{http_code} ifconfig.me"
|
|
||||||
"curl --silent -sw :%{http_code} -4 ifconfig.co"
|
|
||||||
"curl --silent -sw :%{http_code} ipecho.net/plain"
|
|
||||||
"curl --silent -sw :%{http_code} ipinfo.io/ip"
|
|
||||||
"curl --silent -sw :%{http_code} checkip.amazonaws.com"
|
|
||||||
"curl --silent -sw :%{http_code} v4.ident.me"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Get public ip
|
|
||||||
for service in "${SERVICES[@]}"; do
|
|
||||||
RUN_COMMAND=$($service | tr -d '[:space:]')
|
|
||||||
IP=$(echo "$RUN_COMMAND" | cut -d':' -f1)
|
|
||||||
HTTP_CODE=$(echo "$RUN_COMMAND" | cut -d':' -f2)
|
|
||||||
|
|
||||||
if [ "$HTTP_CODE" == "200" ]; then
|
|
||||||
if valid_ip "$IP"; then
|
|
||||||
printf "%s" "$IP"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
printf "error"
|
|
||||||
exit 0
|
|
|
@ -18,7 +18,7 @@ RUN mkdir -p /opt/openvidu /usr/local/bin/
|
||||||
COPY openvidu-server.jar /opt/openvidu/openvidu-server.jar
|
COPY openvidu-server.jar /opt/openvidu/openvidu-server.jar
|
||||||
|
|
||||||
COPY ./entrypoint.sh /usr/local/bin
|
COPY ./entrypoint.sh /usr/local/bin
|
||||||
COPY ./discover_my_public_ip.sh /usr/local/bin
|
COPY ../utils/discover_my_public_ip.sh /usr/local/bin
|
||||||
|
|
||||||
RUN mkdir -p /opt/openvidu/recordings && \
|
RUN mkdir -p /opt/openvidu/recordings && \
|
||||||
chmod +x /usr/local/bin/entrypoint.sh && \
|
chmod +x /usr/local/bin/entrypoint.sh && \
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Check if a txt is a valid ip
|
|
||||||
function valid_ip()
|
|
||||||
{
|
|
||||||
local ip=$1
|
|
||||||
local stat=1
|
|
||||||
|
|
||||||
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
|
||||||
OIFS=$IFS
|
|
||||||
IFS='.'
|
|
||||||
ip=($ip)
|
|
||||||
IFS=$OIFS
|
|
||||||
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
|
|
||||||
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
|
|
||||||
stat=$?
|
|
||||||
fi
|
|
||||||
return $stat
|
|
||||||
}
|
|
||||||
|
|
||||||
# Services to get public ip
|
|
||||||
SERVICES=(
|
|
||||||
"curl --silent -sw :%{http_code} ipv4.icanhazip.com"
|
|
||||||
"curl --silent -sw :%{http_code} ifconfig.me"
|
|
||||||
"curl --silent -sw :%{http_code} -4 ifconfig.co"
|
|
||||||
"curl --silent -sw :%{http_code} ipecho.net/plain"
|
|
||||||
"curl --silent -sw :%{http_code} ipinfo.io/ip"
|
|
||||||
"curl --silent -sw :%{http_code} checkip.amazonaws.com"
|
|
||||||
"curl --silent -sw :%{http_code} v4.ident.me"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Get public ip
|
|
||||||
for service in "${SERVICES[@]}"; do
|
|
||||||
RUN_COMMAND=$($service | tr -d '[:space:]')
|
|
||||||
IP=$(echo "$RUN_COMMAND" | cut -d':' -f1)
|
|
||||||
HTTP_CODE=$(echo "$RUN_COMMAND" | cut -d':' -f2)
|
|
||||||
|
|
||||||
if [ "$HTTP_CODE" == "200" ]; then
|
|
||||||
if valid_ip "$IP"; then
|
|
||||||
printf "%s" "$IP"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
printf "error"
|
|
||||||
exit 0
|
|
|
@ -12,7 +12,7 @@ RUN apt-get update && apt-get install -y \
|
||||||
# Copy OpenVidu Server
|
# Copy OpenVidu Server
|
||||||
COPY openvidu-server.jar /
|
COPY openvidu-server.jar /
|
||||||
COPY ./entrypoint.sh /usr/local/bin
|
COPY ./entrypoint.sh /usr/local/bin
|
||||||
COPY ./discover_my_public_ip.sh /usr/local/bin
|
COPY ../utils/discover_my_public_ip.sh /usr/local/bin
|
||||||
RUN chmod +x /usr/local/bin/entrypoint.sh && \
|
RUN chmod +x /usr/local/bin/entrypoint.sh && \
|
||||||
chmod +x /usr/local/bin/discover_my_public_ip.sh
|
chmod +x /usr/local/bin/discover_my_public_ip.sh
|
||||||
|
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Check if a txt is a valid ip
|
|
||||||
function valid_ip()
|
|
||||||
{
|
|
||||||
local ip=$1
|
|
||||||
local stat=1
|
|
||||||
|
|
||||||
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
|
||||||
OIFS=$IFS
|
|
||||||
IFS='.'
|
|
||||||
ip=($ip)
|
|
||||||
IFS=$OIFS
|
|
||||||
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
|
|
||||||
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
|
|
||||||
stat=$?
|
|
||||||
fi
|
|
||||||
return $stat
|
|
||||||
}
|
|
||||||
|
|
||||||
# Services to get public ip
|
|
||||||
SERVICES=(
|
|
||||||
"curl --silent -sw :%{http_code} ipv4.icanhazip.com"
|
|
||||||
"curl --silent -sw :%{http_code} ifconfig.me"
|
|
||||||
"curl --silent -sw :%{http_code} -4 ifconfig.co"
|
|
||||||
"curl --silent -sw :%{http_code} ipecho.net/plain"
|
|
||||||
"curl --silent -sw :%{http_code} ipinfo.io/ip"
|
|
||||||
"curl --silent -sw :%{http_code} checkip.amazonaws.com"
|
|
||||||
"curl --silent -sw :%{http_code} v4.ident.me"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Get public ip
|
|
||||||
for service in "${SERVICES[@]}"; do
|
|
||||||
RUN_COMMAND=$($service | tr -d '[:space:]')
|
|
||||||
IP=$(echo "$RUN_COMMAND" | cut -d':' -f1)
|
|
||||||
HTTP_CODE=$(echo "$RUN_COMMAND" | cut -d':' -f2)
|
|
||||||
|
|
||||||
if [ "$HTTP_CODE" == "200" ]; then
|
|
||||||
if valid_ip "$IP"; then
|
|
||||||
printf "%s" "$IP"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
printf "error"
|
|
||||||
exit 0
|
|
Loading…
Reference in New Issue