#!/usr/bin/with-contenv sh

# #
#   Store env variables in s6
# #

ip_gateway=$(/sbin/ip route|awk '/default/ { print $3 }')
ip_container=$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1')

printf "$ip_gateway" > /var/run/s6/container_environment/IP_GATEWAY
printf "$ip_container" > /var/run/s6/container_environment/IP_CONTAINER

export IP_GATEWAY=$ip_gateway
export IP_GATEWAY=$ip_container

# #
#   install and startup for tvapp2
# #

cp -r ${DIR_BUILD}/* ${DIR_RUN}
rm -rf ${DIR_BUILD}/*
cd ${DIR_RUN}
npm install --omit=dev
npm start
