start.sh 512 B

12345678910111213141516
  1. #!/bin/sh
  2. # Bind linked docker container to localhost socket using socat
  3. env | sed -En 's|(.*)_PORT_([0-9]*)_TCP=tcp://(.*):(.*)|\1_\2 socat -ls TCP4-LISTEN:\2,fork,reuseaddr TCP4:\3:\4|p' | \
  4. while read NAME CMD; do
  5. mkdir -p /app/gogs/docker/s6/$NAME
  6. echo -e "#!/bin/sh\nexec $CMD" > /app/gogs/docker/s6/$NAME/run
  7. chmod +x /app/gogs/docker/s6/$NAME/run
  8. done
  9. # Exec CMD or S6 by default if nothing present
  10. if [ $# -gt 0 ];then
  11. exec "$@"
  12. else
  13. exec /usr/bin/s6-svscan /app/gogs/docker/s6/
  14. fi